Page 2 of 2
Re: Delete part of text
Posted: Sun Nov 18, 2018 4:27 pm
by AlessioForconi
Klaus wrote: Sun Nov 18, 2018 10:37 am
OK, OK, let me put it this way, I think this is also what the dictionary means.
In a
repeat for each loop like this:
Code: Select all
...
repeat for each line temp in tFiles
## do whatever you want to with temp:
delete char -4 to -1 of temp
## if temp was -> my_image.jpg
## then it now is in fact -> my_image
end repeat
...
You can modify
temp and do with it whatever you like, but the "container" (
tFiles in this case) will NOT change in the end, means
tFiles BEFORE the loop = tFiles AFTER the loop.
It is always difficult to explain something like this in your non-native language.
Thank you Klaus
Re: Delete part of text
Posted: Sun Nov 18, 2018 5:28 pm
by dunbarx
@Klaus.
Oh, that is what you meant. Well, sure.
@ Jacque.
I thought so. But you can indeed (at least these days) fool around with the index midstream. I will test HC tomorrow. I have a feeling my little handler will not like it there.
Craig
Re: Delete part of text
Posted: Mon Nov 19, 2018 4:51 am
by hpsh
just wonder a bit about this, deleting chars -1 to -4 in a filename, where the end could be something like mytext.lz would make it to mytex.
would it not be better to set itemdel to "." transfer item 1 to a new string, and then replace the original with the new string?
would also fix a problem on Unix like system where the filename could be something like mytext.tar.gz
maybe just me that is tired, or something I don't get, would not be the first time
Re: Delete part of text
Posted: Mon Nov 19, 2018 7:44 am
by AlessioForconi
hpsh wrote: Mon Nov 19, 2018 4:51 am
just wonder a bit about this, deleting chars -1 to -4 in a filename, where the end could be something like mytext.lz would make it to mytex.
would it not be better to set itemdel to "." transfer item 1 to a new string, and then replace the original with the new string?
would also fix a problem on Unix like system where the filename could be something like mytext.tar.gz
maybe just me that is tired, or something I don't get, would not be the first time
You are right. The fact is that in this case I know exactly what I want to eliminate. It is always and only the last four letters of the file, the point and the extension, so it is a code that must do only that and only in this case with those files.
Re: Delete part of text
Posted: Mon Nov 19, 2018 3:33 pm
by dunbarx
@hpsh
Your thinking is correct; it is much more robust.
I have often chosen "the easy" way in a handler, thinking surely I did not need to deal with anything unexpected. Just as often, I had to go back and rework. Those unexpected things keep popping up.
Craig