Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

[JS] CS3 pageRange conversions & validation

New Here ,
Jul 03, 2008 Jul 03, 2008
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
TOPICS
Scripting
263
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jul 06, 2008 Jul 06, 2008
LATEST
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 == "I" && string.charAt[x+1] == "V" mypgnb -= 1;
Tricky and painfull but may finally get a integer value.
Hope it helps.
Loic
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines