|
Revision 1, 0.7 kB
(checked in by krobillard, 3 years ago)
|
|
Import orca & thune.
|
| Line | |
|---|
| 1 | REBOL [] |
|---|
| 2 | |
|---|
| 3 | comment { |
|---|
| 4 | http://discuss.joelonsoftware.com/default.asp?design.4.195596.22 |
|---|
| 5 | |
|---|
| 6 | During data entry, we want the number code of the last part (token) to |
|---|
| 7 | increment by one. |
|---|
| 8 | |
|---|
| 9 | So, if you pass the above values, you get |
|---|
| 10 | |
|---|
| 11 | AH-1-1 --> AH-1-2 --> AH-1-3 |
|---|
| 12 | AH-1-1G --> AH-1-2G --> AH-1-3G |
|---|
| 13 | AH-1-G1 --> AH-1-G2 --> AH-1-G3 |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | inc-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 | |
|---|
| 28 | print inc-last "ah-1-9" |
|---|
| 29 | print inc-last "ah-1-9g" |
|---|
| 30 | print inc-last "ah-1-g9" |
|---|
| 31 | |
|---|