Hi Bill,
I understand you *must* specify the number of chars of the label
prefix that may vary in my solution and I understand also it might
bother you :-)
So:
function NumericSuffix pStr
local tCount
-----
if pStr = empty then return "error: empty string."
repeat with tCount = the number of chars of pStr down to 1
if char tCount of pStr is not an integer then return char
(tCount + 1) to -1 of pStr
end repeat
return "error: could not determine numeric suffix."
end NumericSuffix
In most cases, timings will not be noticeably affected when running
this additional function: about 2 ms for 100 iterations.
On the other hand, I take the opportunity (and I am sure you are
aware of it) to point out errors management handling in the above code.
But that's another story :-)
OK: I stop to split hairs...
No :-)
Just a pointer:
When variables checking is on (always here), variables that are used
in a 'repeat with' form (like tCount above) are never taken into
account.
I think they should, of course ;-)
Best regards from Paris,
Eric Chatonet.
Le 20 avr. 07 à 10:44, Bill Marriott a écrit :
Eric,
I prefer to name any object with a single word
("LastBackupDate5" for instance) and *always* quoted even if XTalks
don't make it compulsory in this case.
And to retrieve the right suffix, instead of using last word, I just
use char x to -1:
<<<
Right! I always, always quote string literals as well, even though
Rev will handle it for me if I don't.
But on the other idea, this is exactly the problem I'm trying to
solve. :) It's cumbersome because you've got the problem of a
variant number of items and length of the label prefix.
If you have more than 10 items (as in my example) you can't use
digits 0-9 and instead have to force your numbering system to two
digits. Rev doesn't comprehend "last 2 char" so you instead have to
write something like
put "0" & i into n; put thePrefix & char (the length of n) to -2 of
n into itemName --for <100 items
or add a FileMaker-esque "RightString(string,numchars)" custom
function to get your "fixed length" serial number.
vs the bog-simple "put thePrefix && i into itemName" when building
the reference.
Then, when you're parsing out the item, unless all your prefixes
have exactly the same number of characters, you have to say
char (the length of itemName) to -2 of itemName
or hard-code the length of the prefix, vs "last word of itemName"
which works no matter what.
I like my system because it's more generalized. Building a name
just takes && instead of &, and "last word" is easier/quicker for
me to write and parse than the "char x to -1" construction. I can
use it in every situation without modification, whatever prefix I
select and whether it's 9 or 900 items I'm trying to keep track of.
----------------------------------------------------------------
http://www.sosmartsoftware.com/
[EMAIL PROTECTED]/
----------------------------------------------------------------
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution