Hello Adrian,
adryan wrote: ↑2025-08-17 19:38:55
First, how can a Macro determine whether a response to a Prompt Input command is an integer or a letter of the alphabet?
The easiest way to do this kind of thing in Nisus is with
Find:
Code: Select all
$prompt = Prompt Input
if $prompt.find('[A-Z]','Ei')
prompt "It's a letter"
elsif $prompt.find('\d','E')
prompt "It's a number"
end
In my example here the find will return
@true if there is
at least one letter in whatever the user types at the prompt. If you want to be sure the input is something more specific -- such as only a single letter -- you can write a more specific find expression.
Note that the result of the
Prompt command will always be a text string, even if it consists of numerals, If you want to do calculations with the number you can cast it to an integer, but usually the calculation should work even without that.
Next, how does one increment a letter of the alphabet (eg, get a variable to step through a set of consecutive letters, beginning with a specified letter)?
You'll have to turn numbers into characters using the character code:
Code: Select all
for $code = 65 to 90
$let = Text.newWithCharacter($code)
prompt $let
end
You can get the code for a specified letter with:
The "0" is the index of the character for which you want to know the code. So "0" means the first character of the string in the variable
$letter.
So if
$letter contains the string "1", you will get the code "49". I hope that makes sense.
Finally, what is the correct syntax for the following sample
while expression, where
x,
y are previously declared variables?
Code: Select all
while ((x is not equal to 3) and (y is not equal to "z"))
Basically as you have written it, or more precisely:
Note that in this case Nisus will treat
$x as a number, and
$y as a string, but it hardly matters in this case.