root/trunk/orca/tests/working/inc_num.r

Revision 1, 0.7 kB (checked in by krobillard, 3 years ago)

Import orca & thune.

Line 
1REBOL []
2
3comment {
4http://discuss.joelonsoftware.com/default.asp?design.4.195596.22
5
6During data entry, we want the number code of the last part (token) to
7increment by one.
8
9So, if you pass the above values, you get
10
11AH-1-1   -->  AH-1-2   --> AH-1-3
12AH-1-1G  -->  AH-1-2G  --> AH-1-3G
13AH-1-G1  -->  AH-1-G2  --> AH-1-G3
14}
15
16
17inc-last: func [str /local other digits start end] [
18    other: complement digits: charset "0123456789"
19    parse/all find/last str #"-" [
20        any other start: some digits end: any other
21            (change/part start
22             to-string 1 + to-integer copy/part start end
23             end)
24    ]
25    str
26]
27
28print inc-last "ah-1-9"
29print inc-last "ah-1-9g"
30print inc-last "ah-1-g9"
31
Note: See TracBrowser for help on using the browser.