IBM i Access Client Solutions

IBM i Access Client Solutions

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

 View Only
Expand all | Collapse all

Help Please, is there someone who might be able to answer some advanced ACS macro scripting questions?

  • 1.  Help Please, is there someone who might be able to answer some advanced ACS macro scripting questions?

    Posted Tue August 20, 2024 02:08 PM
    Edited by Cal Moffitt Tue August 20, 2024 02:20 PM
    The HAScript language seems to be so uncommon that I get crickets at StackOverflow. ChatGPT gives me answers that might work in regular XML, but doesn't work in HAScript. The IBM Host On-Demand Macro Programming Guide is really vague at best.
    I am trying to use the <custom> element to run Java to interate over rows of Excel. But I cannot seem to get the syntax right. This is literally the example in the Advanced Programming guide "<custom id="'MyProgram1'" args="'arg1 arg2 arg3'" />".
    I keep getting the error message: "Macro: java_script(28): Element type "custom" must be followed by either attribute specifications, ">" or "/>"
    It appears I'm putting the Java script in the wrong place.
    Can someone please tell me what I'm doing wrong? Any help is very much appreciated!
    Thanks!
    My code is below:
    <HAScript name="java_script" description="" timeout="60000" pausetime="300" promptall="true" blockinput="true" author="Cal.Moffitt" creationdate="Aug 20, 2024, 9:43:02 AM" supressclearevents="false" usevars="true" ignorepauseforenhancedtn="true" delayifnotenhancedtn="0" ignorepausetimeforenhancedtn="true" continueontimeout="false">
    <import>
    <type class="java.io.File"/>
    <type class="java.io.IOException"/>
    <type class="java.text.DateFormat"/>
    <type class="java.text.SimpleDateFormat"/>
    <type class="java.util.Date"/>
    <type class="org.apache.poi.openxml4j.exceptions.InvalidFormatException"/>
    <type class="org.apache.poi.ss.format.CellDateFormatter"/>
    <type class="org.apache.poi.ss.usermodel.Cell"/>
    <type class="org.apache.poi.ss.usermodel.DateUtil"/>
    <type class="org.apache.poi.ss.usermodel.Row"/>
    <type class="org.apache.poi.ss.usermodel.Sheet"/>
    <type class="org.apache.poi.ss.usermodel.Workbook"/>
    <type class="org.apache.poi.ss.usermodel.WorkbookFactory"/>
    <type class="org.apache.poi.xssf.usermodel.XSSFCell"/>
    </import>
        <screen name="Screen1" entryscreen="true" exitscreen="true" transient="false">
            <description >
                <oia status="NOTINHIBITED" optional="false" invertmatch="false" />
            </description>
            <actions>
                <custom id="&apos;
    public class Testing {
    public static void main(String args[]) throws InvalidFormatException, IOException {
    Workbook wb = WorkbookFactory.create(new File("Authors.xlsx"));
    Sheet firstSheet = wb.getSheetAt(0); // get the first sheet
    for (Row row : firstSheet) {
    for (Cell cell : row) {
    print(cell);
    }
    System.out.println(""); // to start displaying each row in separate line
    }
    }
    public static void print(Cell cell) {
    switch (cell.getCellType()) {
    case XSSFCell.CELL_TYPE_STRING:
    System.out.printf("%s\t", cell.getRichStringCellValue().getString());
    break;
    case XSSFCell.CELL_TYPE_NUMERIC:
    System.out.printf("%s\t", cell.getNumericCellValue());
    default:
    break;
    }
    }
    }
    &apos;" args="" />
            </actions>
            <nextscreens timeout="0" >
            </nextscreens>
        </screen>
    </HAScript>

    Hello @Michael Swenson, is this something you could possibly assist with? Please sir?

    ------------------------------
    Cal Moffitt
    ------------------------------



  • 2.  RE: Help Please, is there someone who might be able to answer some advanced ACS macro scripting questions?

    Posted Thu August 22, 2024 02:22 PM

    I have the same experience.  HAScript is so obsure, and just can't do as much as you want it to.  I miss Personal Communications, where I could make a script sing and dance with VBScript.

    Watching with interest.  If you can figure out how to script creation and manipulation of Excel documents, I have some uses for that.



    ------------------------------
    Greg Cornett
    ------------------------------



  • 3.  RE: Help Please, is there someone who might be able to answer some advanced ACS macro scripting questions?

    Posted Thu August 22, 2024 02:38 PM

    You and me both brother. Doesn't even need to be Excel, I can put the integers in a text file. I just need it to iterate through them and perform actions on each. In theory we should be able to do with Java, and HAScript is "supposed" to run Java using the <custom> element. But I can't find an example anywhere. I also tried naming the Java script in the element and adding the file path as an "argument", but that didn't work either. Hopefully some of the smart folks at IBM who created it might be willing to help us out. Fingers crossed!



    ------------------------------
    Cal Moffitt
    ------------------------------



  • 4.  RE: Help Please, is there someone who might be able to answer some advanced ACS macro scripting questions?

    Posted Mon August 26, 2024 12:47 AM

    The EHLLAPI plugin for ACS allows the VBA script approach with Excel using the same (ish) syntax as before. 

    EHLLAPI Functions - IBM Documentation

    EHLLAPI With the Access Client Solutions Emulator (ibm.com) - Note Tim Rowe has just finished the beta development for the 64 bit API. Being tested and hopefully will be GA release soon.



    ------------------------------
    Greg Craill
    ------------------------------



  • 5.  RE: Help Please, is there someone who might be able to answer some advanced ACS macro scripting questions?

    Posted Fri August 23, 2024 02:35 AM

    Hi,

    if you have access to past COMMON EUROPE presentations, here you can watch Juan Manuel Alcudia session ...

    https://commoneuropecongress2022.sched.com/event/zrCW/acs-macros-beyond-the-basics



    ------------------------------
    Fernando Plaza
    IBM i System Administrator
    CD INVEST
    MADRID
    ------------------------------



  • 6.  RE: Help Please, is there someone who might be able to answer some advanced ACS macro scripting questions?

    Posted Fri August 23, 2024 10:54 AM

    Thank you Fernando, I would love to watch that, but I do not have access. It does not give me a link to the video.



    ------------------------------
    Cal Moffitt
    ------------------------------



  • 7.  RE: Help Please, is there someone who might be able to answer some advanced ACS macro scripting questions?

    Posted Fri August 23, 2024 11:07 AM

    I went through the sign-up page for the 2022 conference so I could try to access the content.  Surprisingly, it let me in.  There was no link to a video, but there was a PDF of the presentation.  It looks very promising!  Unfortunately, it is in Spanish and I only speak English.  The first page of the PDF, however, said he was preparing an English version and to email him a request for it.   I emailed him, and got an auto-response that he is on holiday until early September 2024.  If I get a response, I will ask his permission to share it with this group.

    Fernando, would you be so kind as to share a direct link to the video?



    ------------------------------
    Greg Cornett
    ------------------------------



  • 8.  RE: Help Please, is there someone who might be able to answer some advanced ACS macro scripting questions?

    Posted Fri August 23, 2024 11:58 AM

    I got the PDF and sent the request for the English version also. It does look promising! Thanks!



    ------------------------------
    Cal Moffitt
    ------------------------------



  • 9.  RE: Help Please, is there someone who might be able to answer some advanced ACS macro scripting questions?

    Posted Fri August 23, 2024 01:22 PM

    Hi Cal, I think only is in Spanish. Perhaps you can contact with Common Europe President (is the author)



    ------------------------------
    Fernando Plaza
    IBM i System Administrator
    CD INVEST
    MADRID
    ------------------------------



  • 10.  RE: Help Please, is there someone who might be able to answer some advanced ACS macro scripting questions?

    Posted 7 days ago

    Hi Cal, I think its not allowed to use embedded raw java source code directly inside the id attribute. I would try to import/call the compiled java method. which acs version do you have? we struggle with similar issues and found out that import of apache poi classes does not work with acs version 1.1.9.7 so we downgraded to 1.1.7.3. For reading text files we use io.file (filereader) / util.scanner (linescanner) which also work with 1.1.9.7 (for writing files this would be io.filewriter).



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