by sbennet1 » Sun Nov 09, 2025 10:55 am
I may be missing something but I can get the askOnce function and the setEnv and getEnv var to work using the JavaScript test button see attached code
- Code: Select all
// askOnce(prompt, defaultValue) shows a prompt dialog only once per batch with the given prompt text and optional default value.
// It returns the user's input as a string. Subsequent calls with the same prompt text return the stored answer without showing the dialog again.
// If the user cancels, an exception is thrown and execution stops.
// Here we just assign ENV to the result of askOnce with a prompt and default value.
ENV = askOnce("Enter new name for the file:", "xxx"); // default to current name if user leaves blank // SLB ask once is not working ?????????????????????????????????
alert ("ENV = " , ENV ); // SLB aksOnce is not working ?????????????????????????????????????????????????????????
setEnv("BRU_ENV", "YYY");
YYY = getEnv("BRU_ENV");
alert ("YYY =" , YYY ); // SLB setEnv & getEnv is not working ?????????????????????????????????????????????????????
// To get the value of an environment variable, use getEnv("VAR_NAME").
// Example: if environment variable USERNAME = "Alice"
// If the original name is "file1", newName will be set to the value of USERNAME, e.g. "Alice"
newName = getEnv("PATH");
alert ("newName = " , newName ); // SLB get environment var not working ????????????????????????????????????????????????
// To generate an exception in JavaScript, you can throw an error.
// This code will throw an error every time it runs, stopping the renaming process.
// Example: if name = "file", this script will throw an exception and not set newName.
throw new Error("This is a generated exception.");