I wish to changes some file names from camel case to delimited words e.g.
MyGreatLivecodeProject.livecode changes to My-Great-Livecode-Project.livecode
The only method that I can see having looked in the dictionary is to examine the Ascii character values and use the comparison that if greater than 96dec then lower case.
However, before I start writing code I thought I would ask if there is a more elegant way of inserting the delimiter character.
I am assuming you already have the camel case string. Otherwise, Richmond is right, head it off at the pass.
You have to loop through each char. If you find a capital letter, you then have to find the next one, or there will be no way to parse the word the first capital letter belonged to. With these start/end pairs, you can then add your delimiter.
Yes the filenames exist and use camel case so the problem is finding the word boundaries. I was hoping for a command that could be used in a statement like "if char n is a capital then..." but fear I will have to resort to ascii values.
Yes the filenames exist and use camel case so the problem is finding the word boundaries. I was hoping for a command that could be used in a statement like "if char n is a capital then..." but fear I will have to resort to ascii values.
Great stuff - so I'm in a new gang - the living fossils!
I love your variable names - have you ever worked in cryptology - fDICEDCARROTS, LYNE ?!!!
Thanks for the stack and reminding me of codepoints - bloody UTF almost as bad as XML and CSV. (There, that will start a fight).
Craig - yes I already have the camel text as I used it in many file names and I have decided to rename the files with a dash used to delimit key words. Key words being universal tags that will be visible anywhere in any OS that allows long file names, unlike extended attributes (I'm on a mac at the moment)
Simon Knight wrote: Mon Nov 23, 2020 10:10 pmbloody UTF almost as bad as XML and CSV. (There, that will start a fight).
or at least, elicit comment. UTF should have been implemented at the start, and been the de facto "ASCII" without the constant reworking to become an emoji repository. There. Now let the punches fly.
Didn't you want to parse words out of a string, based on the positions of Capital letters within that string? And reformat it with delimiter characters between those words? This seems like a ten-line handler, but I am not sure of the direction anymore.
I think the simple upper/lower case word delimiter based on 7 bit ASCII encoding was the original surmise, but got subverted by questions about non-English or other extended character set considerations.
on mouseUp
get fld 1
put 1 into y
repeat the number of chars of it
add 1 to y
if charToNum(char y of it) >= 65 and charToNum(char y of it) <= 90 then
put "-" before char y of it
add 1 to y
end if
end repeat
answer it
end mouseUp