Thread View: adobe.scripting.indesign
4 messages
4 total messages
Started by loic_aigon
Wed, 14 Jan 2009 20:37
[JS CS3] Check the pattern of a random number given a specific data ?
Author: loic_aigon
Date: Wed, 14 Jan 2009 20:37
Date: Wed, 14 Jan 2009 20:37
17 lines
1123 bytes
1123 bytes
Hi all, I succeed getting a random number of this look : d.dd (8.73 for ex) I use Math.random()*(max-min)+min; I want to check that this number respect a specific given increment. To be clear : If I set min to 0 and max to 10 for example. The script returns a number like 8.56 Now, I have a increment like 0.2 I want the script to give me a number that can be d,d.2,d.4,d.6,d.8 BUT NOT d.78 or d.1 I guess I may use a while command but have no idea of the checking operation. Any idea ? Thanks in advance. Loic
Re: [JS CS3] Check the pattern of a random number given a specific data ?
Author: jongware
Date: Wed, 14 Jan 2009 20:40
Date: Wed, 14 Jan 2009 20:40
3 lines
748 bytes
748 bytes
Math to the rescue. You want a random integer div 5. Math.floor(5*(Math.random()*(max-min)+min))/5 should do it.
Re: [JS CS3] Check the pattern of a random number given a specific data ?
Author: loic_aigon
Date: Sat, 17 Jan 2009 00:01
Date: Sat, 17 Jan 2009 00:01
4 lines
732 bytes
732 bytes
Hi jongware, Thanks a lot, that's really what I needed. I hope I can master your logic one day ;-) Loic
Re: [JS CS3] Check the pattern of a random number given a specific data ?
Author: jongware
Date: Sat, 17 Jan 2009 15:48
Date: Sat, 17 Jan 2009 15:48
8 lines
746 bytes
746 bytes
I hope I can master your logic one day
Ho boy. Be careful what you wish for :D
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads