@otistdog After integrating the WORDSIZE change (I’d seen that all over and not understood what it was for, much clearer now, thank you), I had to change the code to what’s shown below to make it work.
[ Initialise val;
! reduced test statements for readability
val = BuildString("The answer is ", 42);
print val-->0, "^"; ! still outputs 16, all good
print (char) val->(0 + WORDSIZE), "^"; ! had to change the index to 0 as 2 printed the third character 'e'
];
[ StringOrArray str i;
if (str ofclass String) {
print (string) str;
} else {
for (i = 0: i < str-->0: i++) {
print (char) str->(i + WORDSIZE);
}
}
];
The call print (StringOrArray)val;
now works in Initialize
as long as the changes to StringOrArray shown above are made.
There seems to an inconsistency somewhere regarding the -->0 value. Your explanation makes sense but then doesn’t seem to be the case in the code.