Hi Gyroscope,
one variation of the itemdelimiter
Code: Select all
on mouseUp pMouseBtnNo
put line 1 of field 1 into tLine1
set the itemdelimiter to "/"
put item 1 of tLine1 & cr into tCollect
repeat with i = 2 to the number of items of tLine1
put "/" & item i of tLine1 & cr after tCollect
end repeat
delete last char of tCollect
put tCollect into line 1 of field 1
end mouseUp
I would go for
Code: Select all
on mouseUp pMouseBtnNo
put line 1 of field 1 into tLine1
put length(tLine1) into tSoOften
repeat with i = tSoOften down to 1
if char i of tLine1 = "/" then put return before char i of line 1 of field 1
end repeat
end mouseUp
In your case I like the repeat with x down to y because Rev is very fast with one character stepping and since you change the text (by putting a return into it) with counting from the end to the beginning you dont have problems with the number of characters. I you count up and put an extra character into the text you will have to take that into account.
find is not so good when you want to change the field where you found something. You would find the "/" with 'find chars "/" in field 1" not just 'find "/"'. Look in the documentation of the find command what it finds, the simple find command finds beginnings of words, I suppose that since "/" is in the middle of a word or since it is not considered a word it does not find it.
Offset would be a better alternative but is a little involved with repeated Offsets, since you have to indicate the start of the repeated offset because otherwise it always starts from the beginning.
both the code snippets are tested. They dont take care of the "http://", which obviously is a little in the way, since in your original post you did not have "http://"
regards
bernd