1 Reply Latest reply on Jul 6, 2008 11:38 AM by Loic.Aigon

[JS] CS3 pageRange conversions & validation

Hi there

Is there an easy way to convert page range string to absolute page numbers (especially when it contains characters or Roman numerals).

We use a custom rubber stamp on the back of our draft pages during the proofing process. I'd like to create a temporary page at the end of document, then capture the page range entered by user and interleave it with the "stamp page" When combined with double sided printing this might save us considerable amount of time.

Now, I can only do this with digits as page numbers. (and possibly ASCII characters). But I'm totally clueless when it come to Roman numerals.

My second question is about validating page range before I feed it to the printPreference. I didn't want to reinvent the wheel so I'm using the try...catch workaround so far. I just don't feel it's fair to the user to tell him "wrong page range you numpty" even when it's not case of him being a numpty.

Please can anyone give me some hint to point me to the right direction?
Thanks

weller
• 1. Re: [JS] CS3 pageRange conversions & validation
I am not sure to get the idea but regarding to Roman numerals, you may write a analysis function that will consist in attributing value to letters.
so "V" = 5;
X = 10;
I = 1;
...
then check for values and apply values
var mypgnb = 0;
if string.charAt[0] == "V" mypgnb += 5;
if string.charAt[0] == "X" mypgnb += 10;
if string.charAt[0] == "I" mypgnb += 1;
etc. A loop seems imperative through the length of the roman letters length.
The main point is to check for letters placement so IV has a diiferent sum than VI
But you can place conditions like
if string.charAt[x] == "I" && string.charAt[x+1] == "V" mypgnb -= 1;
Tricky and painfull but may finally get a integer value.
Hope it helps.
Loic