How to select randomly from few numbers?
Forum rules
iMacros EOL - Attention!
The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely,
The Progress Team
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
iMacros EOL - Attention!
The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely,
The Progress Team
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
How to select randomly from few numbers?
Hello there,
I'm trying to fill a form and for the each line I want to fill the form with specific numbers I've wrote earlier.
I've tried to to it with min-max random numbers but it won't work since I want to select between 4,9,12 but with the min-max random code it gives me 4-5-6-7-8-9-10-11-12 numbers as output.
My random code is:
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
SET !VAR1 EVAL("var min = 1; var max = 5; var randomNumber = Math.floor(Math.random() * (max - min + 1)) + min; randomNumber;")
TAG POS={{!VAR1}} TYPE=LABEL ATTR=CLASS:freebirdFormviewerViewItemsGridCell&&TXT:
I need something like this
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
SET !VAR1 EVAL("var 4; 9; 12; var randomNumber = Math.floor(Math.random() * (max - min + 1)) + min; randomNumber;")
TAG POS={{!VAR1}} TYPE=LABEL ATTR=CLASS:freebirdFormviewerViewItemsGridCell&&TXT:
Bottom line is; how can I select randomly between pre defined numbers?
Thanks!
I'm trying to fill a form and for the each line I want to fill the form with specific numbers I've wrote earlier.
I've tried to to it with min-max random numbers but it won't work since I want to select between 4,9,12 but with the min-max random code it gives me 4-5-6-7-8-9-10-11-12 numbers as output.
My random code is:
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
SET !VAR1 EVAL("var min = 1; var max = 5; var randomNumber = Math.floor(Math.random() * (max - min + 1)) + min; randomNumber;")
TAG POS={{!VAR1}} TYPE=LABEL ATTR=CLASS:freebirdFormviewerViewItemsGridCell&&TXT:
I need something like this
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
SET !VAR1 EVAL("var 4; 9; 12; var randomNumber = Math.floor(Math.random() * (max - min + 1)) + min; randomNumber;")
TAG POS={{!VAR1}} TYPE=LABEL ATTR=CLASS:freebirdFormviewerViewItemsGridCell&&TXT:
Bottom line is; how can I select randomly between pre defined numbers?
Thanks!
Re: How to select randomly from few numbers?
FCIM...!komadayim wrote:Hello there,
I'm trying to fill a form and for the each line I want to fill the form with specific numbers I've wrote earlier.
I've tried to to it with min-max random numbers but it won't work since I want to select between 4,9,12 but with the min-max random code it gives me 4-5-6-7-8-9-10-11-12 numbers as output.
My random code is:
I need something like thisCode: Select all
VERSION BUILD=9030808 RECORDER=FX TAB T=1 SET !VAR1 EVAL("var min = 1; var max = 5; var randomNumber = Math.floor(Math.random() * (max - min + 1)) + min; randomNumber;") TAG POS={{!VAR1}} TYPE=LABEL ATTR=CLASS:freebirdFormviewerViewItemsGridCell&&TXT:
Bottom line is; how can I select randomly between pre defined numbers?Code: Select all
VERSION BUILD=9030808 RECORDER=FX TAB T=1 SET !VAR1 EVAL("var [b]4; 9; 12;[/b] var randomNumber = Math.floor(Math.random() * (max - min + 1)) + min; randomNumber;") TAG POS={{!VAR1}} TYPE=LABEL ATTR=CLASS:freebirdFormviewerViewItemsGridCell&&TXT:
Thanks!
=> iMacros for FF v9.0.3, FF53...?, OS...?
Assign your 3 Numbers to an Array and apply your Random Nb to the Index within the Array with [min,max]=[0,2]. (Is just one Solution...)
An easy way to get your Nb's in a Array is to define them all together in one String "4;9;12" and use 'split()' on the Separator in the String...
>>>
And hum, you never finished your previous Thread from 3.5 years ago a bit "neatly"...
You are expected to share your Solution / Final Script to finish a Thread a bit correctly and useful for other Users... (even if hum..., I'm not sure that Thread would help many People searching the Forum because of its useless (= non-Descriptive) Thread Title ("A complicated problem")...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: How to select randomly from few numbers?
Hello chivracq,
Thank you for your reply. I'm not FF 53.0.3 with the latest version of iMacros and windows 10. Sorry for not mentioning them.
I've tried to google your solutions but couldn't find anything.
Is there an example I can take a look at? I couldn't find arraying and using indexs for imacros. I guess i should use scripts but I have no idea about them.
--
Sorry about the earlier post, I couldn't find a solution to that problem as far as I can remember and end up doing it manually.
Thank you for your reply. I'm not FF 53.0.3 with the latest version of iMacros and windows 10. Sorry for not mentioning them.
I've tried to google your solutions but couldn't find anything.
Is there an example I can take a look at? I couldn't find arraying and using indexs for imacros. I guess i should use scripts but I have no idea about them.
--
Sorry about the earlier post, I couldn't find a solution to that problem as far as I can remember and end up doing it manually.
Re: How to select randomly from few numbers?
OK for FCI, even if still a bit unclear because of the "not", but never mind, it shouldn't play a role in this Case...komadayim wrote:Hello chivracq,
Thank you for your reply. I'mSorry for not mentioning them.Code: Select all
not FF 53.0.3 with the latest version of iMacros and windows 10.
I've tried to google your solutions but couldn't find anything.
Is there an example I can take a look at? I couldn't find arraying and using indexs for imacros. I guess i should use scripts but I have no idea about them.
--
Sorry about the earlier post, I couldn't find a solution to that problem as far as I can remember and end up doing it manually.
Well, you don't need to "search" anything, simply check how the JavaScript 'split()' Command works...
Code: Select all
SET Numbers "4;9;12"
SET !VAR1 EVAL("var min=0, max=2; var nb='{{Numbers}}'; var a=nb.split(';'); var rd=Math.floor(Math.random()*(max-min+1))+min; a[rd];")
PROMPT Numbers:<SP>_{{Numbers}}_<BR>VAR1:<SP>_{{!VAR1}}_
Or, if you prefer, maybe easier to follow/understand as it reuses directly your original Code..., and to debug, ah-ah...!:
Code: Select all
SET Numbers "4;9;12"
SET Random_Index EVAL("var min=0, max=2; var randomNumber=Math.floor(Math.random()*(max-min+1))+min; randomNumber;")
SET !VAR1 EVAL("var nb='{{Numbers}}'; var ri='{{Random_Index}}'; var a=nb.split(';'); a[ri];")
PROMPT Numbers:<SP>_{{Numbers}}_<BR><BR>Random_Index:<SP>_{{Random_Index}}_<BR>VAR1:<SP>_{{!VAR1}}_
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: How to select randomly from few numbers?
Dear chivracq,
Thank you for your reply, this one worked nicely! It's hard to find information when you don't know enough about something.
Sorry for my confusing reply earlier, I was a bit tired and couldn't get my words together.
Best wishes!
Thank you for your reply, this one worked nicely! It's hard to find information when you don't know enough about something.
Sorry for my confusing reply earlier, I was a bit tired and couldn't get my words together.
Best wishes!
Re: How to select randomly from few numbers?
Well, I tested both (Scripts) and they both work..., the 2nd one is maybe easier to understand as it goes a bit more Step by Step, and reuses what you were already trying to use... You were very close and only missing one Step...komadayim wrote:Dear chivracq,
Thank you for your reply, this one worked nicely! It's hard to find information when you don't know enough about something.
Sorry for my confusing reply earlier, I was a bit tired and couldn't get my words together.
Best wishes!
I normally don't/rarely write Scripts for Users, I prefer to let you understand what "you are doing" and let you find the Solution by yourself, which is more rewarding for yourself anyway than having sbd writing your Script..., so I hope you now understand a bit how "my" Solution works...
I hardly know anything about JavaScript myself, that's why I do all my Scripts in pure '.iim' and only use a few "simple" JS Commands like 'split()' in 'EVAL()' Statements...
Glad I could help and good luck for the "rest"...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...