IBM i Access Client Solutions

IBM i Access Client Solutions

Connect, learn, share, and engage with IBM Power.

 View Only
Expand all | Collapse all

Carriage returns in HAScript prompt windows?

  • 1.  Carriage returns in HAScript prompt windows?

    Posted Thu June 20, 2024 04:53 PM
      |   view attached

    I'm working on a way to quickly enter repetitive text into the terminal window. It'd really help if when I make a prompt pop up if the text in the window, or as it's called the "prompt name" could have multiple lines of text. So far everything I've tried to put in the string or concatenate into the string has failed. For example I've tried using character codes like 
 and formatting codes like \n, but I've had no luck. This is mostly just a side project I do on my breaks but any input would be appreciated. I've included a shot of what I've started. Where it says the 2 kinds of commodities is where I'd like to break it up.



    ------------------------------
    Christopher Verdon
    ------------------------------


  • 2.  RE: Carriage returns in HAScript prompt windows?

    Posted Fri June 21, 2024 02:13 AM

    Dear Christopher 

    Please try  <1st line Text> & chr(10) & <2nd line Text>  to see if it works or not.  If not, try chr(13).  



    ------------------------------
    Satid S
    ------------------------------



  • 3.  RE: Carriage returns in HAScript prompt windows?

    Posted Fri June 21, 2024 03:10 PM

    Thanks, Satid. Hasn't worked yet but maybe I'm doing it wrong. I'll show you more of what I'm working with. Here's the code in the code editor

    <prompt name="&apos;1 - Novelty Deodorants 2 - Light Bulbs&apos;" description="" row="0" col="0" len="2" default="" clearfield="false" encrypted="false" movecursor="true" xlatehostkeys="true" assigntovar="$commodity1$" varupdateonly="true" required="false" title="&apos;Select the commodity&apos;" />
    

    and here's the same prompt in the macro editor window



    ------------------------------
    Christopher Verdon
    ------------------------------



  • 4.  RE: Carriage returns in HAScript prompt windows?

    Posted Tue August 13, 2024 03:04 PM

    Luckily there's plenty to keep me busy at work but I'd still like to complete this project. If anyone thinks they can help, please chime in!



    ------------------------------
    Christopher Verdon
    ------------------------------



  • 5.  RE: Carriage returns in HAScript prompt windows?

    Posted Wed August 14, 2024 01:16 AM

    Did you try with CDATA, in Code Editor?



    ------------------------------
    Sylvain Manceau
    ------------------------------



  • 6.  RE: Carriage returns in HAScript prompt windows?

    Posted Wed August 14, 2024 03:15 PM
    Edited by Christopher Verdon Wed August 14, 2024 03:44 PM

    CDATA isn't even mentioned in the macro handbook so I hadn't tried it. Once again, I may be doing it wrong so please correct me. Here's the code that I tried. I got the following error window when I executed it and the craziest part is the code within CDATA was removed from the code editor when I went back to change it.

        <vars>
          <create name="$commodity1$" type="string" value="" />
          <create name="$doExit$" type="boolean" value="false" />
          /* <![CDATA[ */
          <create name="$promptName1$" type="string" value="&apos;1-Novelty Deodorants&apos;+chr(10)+&apos;2-Light Bulbs&apos;" />
          /* ]]> */
        </vars>
    an error window I received after trying this new method


    EDIT: I forgot the trailing greater than in that last tag. I tried it again after correcting it and got the same problem. I believe I don't need those comment indicators either so I tried it this way, but the results were the same.

        <vars>
          <create name="$commodity1$" type="string" value="" />
          <create name="$doExit$" type="boolean" value="false" />
          <![CDATA[
          <create name="$promptName1$" type="string" value="&apos;1-Novelty Deodorants&apos;+chr(10)+&apos;2-Light Bulbs&apos;" />
          ]]>
        </vars>


    ------------------------------
    Christopher Verdon
    ------------------------------



  • 7.  RE: Carriage returns in HAScript prompt windows?

    Posted Mon September 23, 2024 04:58 PM

    Hi, I have the same problem here with a message box, already tried to fix it with chr(10), chr(13), CDATA, unicode &#10;, &'x0A;,\n, \r\n, ASCII +char(10), HTML <br>.... nothing worked so far



    ------------------------------
    Sabine Rein
    ------------------------------



  • 8.  RE: Carriage returns in HAScript prompt windows?

    Posted 10 days ago

    Hi, found the solution:

    <HAScript name="test" description="0" timeout="20000" pausetime="20" promptall="true" blockinput="false" author="sabine rein" creationdate="09 2025" supressclearevents="false" usevars="true" ignorepauseforenhancedtn="true" delayifnotenhancedtn="0" ignorepausetimeforenhancedtn="true" continueontimeout="false">
        <import>
    <type class="javax.swing.JLabel" name="JavaLabel"/>
            <type class="java.awt.GridLayout" name="JavaGridLayout"/>
            <type class="javax.swing.JOptionPane" name="JavaOptionPane"/>
            <type class="javax.swing.JTextField" name="JavaTextField"/>
            <type class="javax.swing.JPanel" name="JavaPanel"/>
        </import>
        <vars>
            <create name="$str_deo$" type="string" />
            <create name="$str_bulbs$" type="string" />
            <create name="$panel$" type="JavaPanel" />
            <create name="$deo$" type="JavaTextField" />
            <create name="$bulbs$" type="JavaTextField" />
            <create name="$returnValue$" type="integer" />
        </vars>
        <screen name="start" entryscreen="true" exitscreen="false" transient="false">
            <description>
                <oia status="NOTINHIBITED" optional="false" invertmatch="false" />
            </description>
            <actions>
                <varupdate name="$panel$" value="$new JavaPanel($new JavaGridLayout(2, 2)$)$" />
                <perform value="$panel.add($new JavaLabel('Novelty Deodorants:')$)$" />
                <varupdate name="$deo$" value="$new JavaTextField()$" />
                <perform value="$panel.add($deo$)$" />
                <perform value="$panel.add($new JavaLabel('Light Bulbs:')$)$" />
                <varupdate name="$bulbs$" value="$new JavaTextField()$" />
                <perform value="$panel.add($bulbs$)$" />
                <varupdate name="$returnValue$" value="$JavaOptionPane.showConfirmDialog(null, $panel$, 'test', 2, 2)$" />
                <if condition="$returnValue$ == 0">
                    <varupdate name="$str_deo$" value="$deo.getText()$" />
                    <varupdate name="$str_bulbs$" value="$bulbs.getText()$" />
                    <message title="'test'" value="'deo: ' + $str_deo$ + ', bulbs: ' + $str_bulbs$" />
                </if>
                <if condition="$returnValue$ != 0">
                    <message title="'exit'" value="'exit'" />
                </if>
            </actions>
            <nextscreens timeout="0">
                <nextscreen name="end" />
            </nextscreens>
        </screen>
        <screen name="end" entryscreen="false" exitscreen="true" transient="false">
            <description>
                <oia status="NOTINHIBITED" optional="false" invertmatch="false" />
            </description>
            <actions>
            </actions>
        </screen>
    </HAScript>



    ------------------------------
    Sabine Rein
    ------------------------------



  • 9.  RE: Carriage returns in HAScript prompt windows?

    Posted 7 days ago

    I like what you did with Java to get it to work.  There was a question from someone about using radio buttons to select a value vs using a prompt to type the values.  I know using Java you can do this but not sure how to get it to work with the ha scripting. Thanks

    John



    ------------------------------
    John Pimentel
    ------------------------------



  • 10.  RE: Carriage returns in HAScript prompt windows?

    Posted 6 days ago

    Hi John, here's the solution for radio buttons: 

    <HAScript name="test" description="0" timeout="20000" pausetime="20" promptall="true" blockinput="false" author="sabine rein" creationdate="09 2025" supressclearevents="false" usevars="true" ignorepauseforenhancedtn="true" delayifnotenhancedtn="0" ignorepausetimeforenhancedtn="true" continueontimeout="false">
        <import>
            <type class="javax.swing.JLabel" name="JavaLabel"/>
            <type class="java.awt.GridLayout" name="JavaGridLayout"/>
            <type class="javax.swing.JOptionPane" name="JavaOptionPane"/>
            <type class="javax.swing.JPanel" name="JavaPanel"/>
            <type class="javax.swing.JRadioButton" name="JavaRadioButton"/>
            <type class="javax.swing.ButtonGroup" name="JavaButtonGroup"/>
        </import>
        <vars>
            <create name="$option1$" type="JavaRadioButton" />
            <create name="$option2$" type="JavaRadioButton" />
            <create name="$group$" type="JavaButtonGroup" />
            <create name="$panel$" type="JavaPanel" />
            <create name="$returnValue$" type="integer" />
            <create name="$selectedOption$" type="string" />
        </vars>
        <screen name="start" entryscreen="true" exitscreen="false" transient="false">
            <description>
                <oia status="NOTINHIBITED" optional="false" invertmatch="false" />
            </description>
            <actions>
                <!-- Panel with 3 rows, 1 col -->
                <varupdate name="$panel$" value="$new JavaPanel($new JavaGridLayout(3, 1)$)$" />
                <!-- create options -->
                <varupdate name="$option1$" value="$new JavaRadioButton('Novelty Deodorants')$" />
                <varupdate name="$option2$" value="$new JavaRadioButton('Light Bulbs')$" />
                <!-- Group for exclusivity (only one option can be selected) -->
                <varupdate name="$group$" value="$new JavaButtonGroup()$" />
                <perform value="$group.add($option1$)$" />
                <perform value="$group.add($option2$)$" />
                <!-- add to panel -->
                <perform value="$panel.add($new JavaLabel('please choose an option:')$)$" />
                <perform value="$panel.add($option1$)$" />
                <perform value="$panel.add($option2$)$" />
                <!-- show dialog -->
                <varupdate name="$returnValue$" value="$JavaOptionPane.showConfirmDialog(null, $panel$, 'test', 2, 2)$" />
                <!-- check selected option -->
    <if condition="$option1.isSelected()$">
                        <varupdate name="$selectedOption$" value="'Novelty Deodorants'" />
                    </if>
    <if condition="$option2.isSelected()$">
                        <varupdate name="$selectedOption$" value="'Light Bulbs'" />
                    </if>
    <!-- check dialog result -->
                <if condition="$returnValue$ == 0">
                    <message title="'test'" value="'Auswahl: ' + $selectedOption$" />
                </if>
                <if condition="$returnValue$ != 0">
                    <message title="'exit'" value="'exit'" />
                </if>
            </actions>
            <nextscreens timeout="0">
                <nextscreen name="end" />
            </nextscreens>
        </screen>
        <screen name="end" entryscreen="false" exitscreen="true" transient="false">
            <description>
                <oia status="NOTINHIBITED" optional="false" invertmatch="false" />
            </description>
            <actions>
            </actions>
        </screen>
    </HAScript>



    ------------------------------
    Sabine Rein
    ------------------------------



  • 11.  RE: Carriage returns in HAScript prompt windows?

    Posted 6 days ago

    It works.  Thanks for the quick reply.



    ------------------------------
    John Pimentel
    ------------------------------



  • 12.  RE: Carriage returns in HAScript prompt windows?

    Posted 7 days ago

    That's terrific, Sabine. Your grasp of HAScript definitely exceeds mine. Thank you for your help!



    ------------------------------
    Christopher Verdon
    ------------------------------



  • 13.  RE: Carriage returns in HAScript prompt windows?

    Posted 6 days ago

    Thanks Christopher, but the credit doesn't go to me but to my colleague who generally figured out how to import java classes in hascript :)

    Once you understand how it works its actually pretty easy and you have a lot of possibilities.



    ------------------------------
    Sabine Rein
    ------------------------------