Hi guys,
How can I make a script create an integer from a number with decimal places? I want it to always round up to the next whole number.
I have a script which generates webpages, each containing 5 images, from a list of raw image names in a text file. So if I have 17 images, it will make 4 pages - three with 5 images and one with 2. I then need MS to know how many pages it made, and start working on another macro which makes a menu along the line of - so MS needs to know how many items to add to the menu.
So if I was to count the number of image names in the textfile and divide 5 I would get 3.4. I need to round this number up to 4 automatically.
Can this be done?
need to create an integer
Moderators: JRL, Dorian (MJT support)
- Dorian (MJT support)
- Automation Wizard
- Posts: 1415
- Joined: Sun Nov 03, 2002 3:19 am

Check for the char "." in the output (I guess the Position> command would work).
If you've detected a dot - take the number in front of the dot (MidStr> command) and increase it with one.

BTW: There's definitely a VBS option, which will be provided by a MSched Pro !
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Quick and dirty approach:
1. Normally take value and add .5 to help with rounding if equal or greater than .5. So to take any fraction to next integer, add .9
2. Find position of decimal in value
3. Take all characters to left of decimal position.
Samples:
Original Number.............Add............Decimal position........Left of decimal
12.5..............................13.4......................3...........................13
312.0............................312.9.....................4.........................312
6177.8.........................6178.7.....................5.......................6178
15...................................15.9.....................3...........................15
11.1.................................12.0.....................3...........................12
1. Normally take value and add .5 to help with rounding if equal or greater than .5. So to take any fraction to next integer, add .9
2. Find position of decimal in value
3. Take all characters to left of decimal position.
Samples:
Original Number.............Add............Decimal position........Left of decimal
12.5..............................13.4......................3...........................13
312.0............................312.9.....................4.........................312
6177.8.........................6178.7.....................5.......................6178
15...................................15.9.....................3...........................15
11.1.................................12.0.....................3...........................12
Be sure to Remove Trailing Spaces after doing Cut/Paste from forum.Input>Original,Enter a value to be rounded
Let>N=%Original%+.9
Position>.,%N%,1,Decimal
If>%Decimal%=0,WholeNumber
Label>Fraction
Let>Stop=%Decimal%-1
MidStr>%N%,1,%Stop%,Answer
Goto>Finish
Label>WholeNumber
Let>Answer=%N%
Label>Finish
MsgBox>Original %Original% has been raised to %Answer%
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
- Dorian (MJT support)
- Automation Wizard
- Posts: 1415
- Joined: Sun Nov 03, 2002 3:19 am