Hello Greg,
I've never written an HAScript before...but I've programmed in a lot of languages and environments. I dug into the doc a bit and found that in order to do what you want, you need to import the java classes to do that conversion. I did it with a simple String.replace() method call. Here's my simple script:
<HAScript name="ReplaceChars" description="" timeout="60000" pausetime="300" promptall="true" blockinput="true" author="MichaelSwenson" creationdate="Apr 24, 2024, 6:03:25 PM" supressclearevents="false" usevars="true" ignorepauseforenhancedtn="true" delayifnotenhancedtn="0" ignorepausetimeforenhancedtn="true" continueontimeout="false">
<import>
<type class="java.lang.String" name="javaString"/>
</import>
<vars>
<create name="$myString$" type="javaString" value="$new javaString('This Is A Test')$" />
<create name="$newString$" type="string" value="" />
</vars>
<screen name="Screen1" entryscreen="true" exitscreen="true" transient="false">
<description >
<oia status="NOTINHIBITED" optional="false" invertmatch="false" />
</description>
<actions>
<varupdate name="$newString$" value="$myString.replace(' ','+')$" />
<input value="$newString$" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
</actions>
<nextscreens timeout="0" >
</nextscreens>
</screen>
</HAScript>
------------------------------
Michael Swenson
Software Engineer
IBM
------------------------------
Original Message:
Sent: Tue April 23, 2024 10:12 AM
From: Greg Cornett
Subject: Advanced macro scripting?
Does have a contact with someone who might be able to answer some advanced ACS macro scripting questions?
I previously reached out to Scott Forstie, who is a Senior Technical Staff Member within IBM i development, explaining that I had reached the end of my limited technical ability and asking if he could refer me to somebody that I could pay to help me work on a couple macro scripts for ACS. He forwarded me to Ronald Bibby with IBM Systems Expert Labs, who set up a webex meeting with me.
They must have thought it was going to be a large enterprise project because, much to my surprise, there were three or four IBM employees in the meeting. When I made it clear I just had some scripting questions, the meeting was over pretty quickly. Ronald asked me to email him about our questions. I did, but I never heard back from anybody.
The HAScript language seems to be so uncommon that I got crickets at StackOverflow. ChatGPT gives me answers that might work in regular XML, but don't work in HAScript. The IBM Host On-Demand Macro Programming Guide didn't help at all.
I literally just want to have somebody teach me how to replace any blank spaces in a variable with a plus sign.
------------------------------
Greg Cornett
------------------------------