Random Col Number Without Repeating

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Random Col Number Without Repeating

by DejaQ on Fri Sep 08, 2017 3:34 pm

Firefox Version: 51.0.1
Imacros For Firefox Version: 8.9.7
Window 7 x64 or Windows Server 2012

Hey,

Hoping somebody can help. This will probably require Javascript or some really good Eval statement (if anyone has a template lying around).

I'm trying to randomise the !Col between 18 to 25 without using the same number twice. I can randomise them with Eval easily enough, but the same numbers will get used twice and I need them to all be unique. Essentially just reordering them each time

TAG POS=1 TYPE=TEXTAREA ATTR=DATA-REACTID:* CONTENT={{!COL18}}{{!COL19}}{{!COL20}}{{!COL21}}{{!COL22}}{{!COL23}}{{!COL24}}{{!COL25}}

Like so

TAG POS=1 TYPE=TEXTAREA ATTR=DATA-REACTID:* CONTENT={{!COL21}}{{!COL25}}{{!COL24}}{{!COL18}}{{!COL22}}{{!COL23}}{{!COL20}}{{!COL19}}

Any thoughts?
Last edited by DejaQ on Sat Sep 09, 2017 4:41 am, edited 1 time in total.
Firefox Version: 51.0.1
Imacros For Firefox Version: 8.9.7
Window 7 x64 or Windows Server 2012
DejaQ
 
Posts: 4
Joined: Thu Dec 29, 2016 7:54 am

Re: Random Col Number Without Repeating

by chivracq on Fri Sep 08, 2017 8:15 pm

DejaQ wrote:
Code: Select all
Firefox Version: 51.0.1
Imacros For Firefox Version: 8.9.7
Window 7 x64 or Windows Server 2012

Hey,

Hoping somebody can help. This will probably require Javascript or some really good Eval statement (if anyone has a template lying around).

I'm trying to randomise the !Col between 18 to 25 without using the same number twice. I can randomise them with Eval easily enough, but the same numbers will get used twice and I need them to all be unique. Essentially just reordering them each time
Code: Select all
TAG POS=1 TYPE=TEXTAREA ATTR=DATA-REACTID:* CONTENT={{!COL18}}{{!COL19}}{{!COL20}}{{!COL21}}{{!COL22}}{{!COL23}}{{!COL24}}{{!COL25}}

Like so
Code: Select all
TAG POS=1 TYPE=TEXTAREA ATTR=DATA-REACTID:* CONTENT={{!COL21}}{{!COL25}}{{!COL24}}{{!COL18}}{{!COL22}}{{!COL23}}{{!COL20}}{{!COL19}}

Any thoughts?

You should still hard-code your FCI in your OP once when you open a Thread, I cannot see your Sig when replying, and you only have one dynamic Sig for the whole Forum and all your Threads and the FCI mentioned in your Sig only reflects your current FCI and can be confusing for Users reading the Thread in a few weeks/months/years..., and even for me: Are you sure you are still on FF51...? It is not a "standard" FF Version anymore, (Septb 2017), I would rather expect FF52/54/55/56/57...?

1- But, euh..., yep can be done in '.js' Script by concatenating the '!COL' + n=[18|25], is not the easiest Solution, I would think...

Several Solutions in pure '.iim'... (I only do '.iim' anyway, I've never used any '.js' Script, ah-ah...!)
2- Using 'EVAL()', simply put your x8 '{{!COL18}}'|'{{!COL25}}' Vars in an Array like you did in your previous Thread and use a Double 'splice()' (or 'push()') in a Loop like you did within 'EVAL()' to randomly select and remove 1 of the 8 Elements of the Array to construct 1 by 1 a new Array... Doesn't sound very difficult to implement...
Strange btw that there is no 'shuffle()' Method in JS...!? :o

Hum, checking SOF and you have 33 Answers/Solutions, ah-ah...! Enough to choose, I would think...! :wink:
Rhooohh...!, and one of the Solutions (by @Tophe with (only!?) 11 Points (it had 10, I gave it 1 more, ah-ah...!)) is exactly the one I meant, ah-ah...! 8)

3- Some "Shortcut" to fetch all 8 Values from your DataSource in just one Statement instead of repeating '{{!COL18}}' ... '{{!COL25}}' is to "misuse" '!DATASOURCE_DELIMITER' as you are on FF to set it to some "fake" Delimiter, then you use 'EVAL()' + 'split()' on the "real" Delimiter to recreate an Array containing all Cells from one same Row, and then + 'slice()' to only keep Cells [18|25].
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Random Col Number Without Repeating

by chivracq on Wed Nov 29, 2017 7:52 am

Hum..., just saw you Online checking the Forum, and I realize that you never followed up on this Thread, except to update your OP after my Reply to include and confirm your FCI like I had "suggested"... (... Which is a good thing, ah-ah...! :D )

:idea: Thing is, next time you'll have a Pb/Qt and open a new Thread, I will first "force" you to follow up on this one and to finish it "correctly" and useful for other Users by mentioning which Solution you chose, and sharing your Final Script, before helping you again..., as I only help Users using the Forum "a bit correctly"..., and for all their Threads... :idea:
(And you then may have to wait for your next Thread for the same amount of time this current Thread will have waited for a Follow-up, oops...! :twisted: )
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to iMacros for Firefox

Who is online

Users browsing this forum: No registered users and 9 guests

cron
-->