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="'
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;
}
}
}
'" args="" />
</actions>
<nextscreens timeout="0" >
</nextscreens>
</screen>
</HAScript>
Hello @Michael Swenson, is this something you could possibly assist with? Please sir?
------------------------------
Cal Moffitt
------------------------------
#IBMiAccessClientSolutions