Questions Regarding AppleScript and JavaScript for Automation

well I had to change it to this:

if (JA_eight_bit_integer_incrementer < JA_Number) {
  JA_Variant_Type = JA_Variant_Type + 'u8,';
  myVariant_type = JA_Variant_Type;
} else {
  JA_Variant_Type = JA_Variant_Type + 'u8';
  myVariant_type = JA_Variant_Type;
}

console.log(myVariant_type)

cos ive never seen that other kind of syntax before getVariable and setVariable in javascript so I stripped it out. lol, i never did test the while loop inside javascript.

I think you may be trying to run before you can walk.

I would suggest that you put all these actions aside for the moment, and simply describe what value you are actually trying to define.

Show us an example of:

  • the output you hope for, and
  • the input(s) that went into it.

(Not as as screenshot, just as text)

Dont worry. I figured it out.

its setvariable not setVariable. Just simply ridiculous. Hours on some ridiculous problem. Is there some static analysis tool coming for the AS or JA?

Yes, all names are context sensitive in JS, and the sdef listings for AS and JS in Script Editor are always useful:

Screenshot 2022-03-19 at 18.39.19

Incidentally, Array.join(",") may turn out to be simpler (fewer moving parts – more maintainable) than trudging through a loop with conditionals and mutating variables:

Group.kmactions (4.8 KB)

(() => {
    "use strict";

    const
        app = Object.assign(
            Application.currentApplication(), {
                includeStandardAdditions: true
            }),
        kmInst = app.systemAttribute("KMINSTANCE"),
        km = Application("Keyboard Maestro Engine");

    const
        JA_eight_bit_integer_incrementer = parseInt(
            km.getvariable("local_eight_bit_integer_incrementer", {
                instance: kmInst
            }), 10
        ),
        JA_Number = parseInt(km.getvariable("Number"), 10);

    km.setvariable("Variant type", {
        to: Array.from({
                length: 1 + (
                    JA_Number - JA_eight_bit_integer_incrementer
                )
            }, () => "u8")
            .join(",")
    });
})();

what is that image?
The one that says Terminology, Kind, Suite. Ive never seen that before.
How do I get that?

Ben

Hide and show the macro again.

Cmd-Opt-G then Cmd-Opt-M

Drop the Keyboard Maestro Editor on the Apple Script Editor.app to show its available scripting dictionaries.

Ok in your suite column, it says Keyboard Maestro Engine.
In my suite column, it says Keyboard Maestro Suite.

Why am I not seeing the engine?
Why is this not in the manual?

Ben

Whups. I missed “Engine Suite” when I looked at the image.

Finding the Keyboard Maestro Engine in the Finder

and another approach is to:

  • open Script Editor (with the language drop-down at top left set to either JavaScript or AppleScript)
  • choose File > Open Dictionary...
  • browse through the apps there to Keyboard Maestro Engine