Intrigued
11-07-2005, 07:56 PM
Have you found a time when you needed to check for a certain number between a range of numbers? Say for example you want to see if a variable in your program (that changes often) is between say once (1) and eight (8)? Well, here is an example on how you can check such variable:
-- First define a variable to hold a random number to check against
n = 5
-- Note 'string.find' is all lower-case! It's a LUA function (not AMS created)
result = string.find(n, '[1-8]')
--[[
If there is an instance of '5' between 1 and 8, then show confirmation.
otherwise, show the second (no instances found) dialog. This is a good way
to easily check a "range" of numbers! Forum member TJ_Tigger first alerted us to this LUA innate function. Remember, type 'string.find' in all lower-case or the function will not work!
]]
if result then
Dialog.Message("", "Found at least one instance!")
else
Dialog.Message("", "Did not find any instances!")
end
-- First define a variable to hold a random number to check against
n = 5
-- Note 'string.find' is all lower-case! It's a LUA function (not AMS created)
result = string.find(n, '[1-8]')
--[[
If there is an instance of '5' between 1 and 8, then show confirmation.
otherwise, show the second (no instances found) dialog. This is a good way
to easily check a "range" of numbers! Forum member TJ_Tigger first alerted us to this LUA innate function. Remember, type 'string.find' in all lower-case or the function will not work!
]]
if result then
Dialog.Message("", "Found at least one instance!")
else
Dialog.Message("", "Did not find any instances!")
end