| View previous topic :: View next topic |
| Author |
Message |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Sun Apr 11, 2004 9:01 am Post subject: Help with strdel please |
|
|
I have written this code to remove comment lines and comments from the end of strings. but its only removing full lines and that the comments after the text.
a comment always starts with #
| Code: |
:Remove Commentsmenu
list create,1
list seek,list1,0
repeat
if @equal(@pos(#,@item(list1)),1)
list delete,list1
else
%%POSFIND = @pos(#,@item(list1))
%%LEN = @len(@item(list1))
if @equal(%%POSFIND,0)
list add,1,@item(list1)
list delete,list1
else
%%NEWITEM = @item(list1)
%%STRDEL = @strdel(%%NEWITEM,%%POSFIND,%%LEN)
list add,1,%%NEWITEM
list delete,list1
end
end
until @equal(@count(list1),0)
list clear,list1,
list assign,list1,1
list close,1
goto evloop
|
What is wrong with my strdel?
Thank you |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Sun Apr 11, 2004 11:58 am Post subject: |
|
|
I don't have time to throughly investigate the code, but you can also
delete beginning from the end of the string by using something like:
| Code: | | %a = @strdel(%a,5,-2) |
_________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Sun Apr 11, 2004 8:20 pm Post subject: |
|
|
| I was thinking the pos # might not be legal, maybe replace the # with a number.. |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Sun Apr 11, 2004 9:00 pm Post subject: |
|
|
"#" is what is trying to be found, so it would be indeed a legal character.
You could try putting it in quotes, but I don't think that will really help.
Are you sure you're managing your list right? Are the comments whole-line
comments? If not, then you shouldn't be deleting the whole list item. _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Sun Apr 11, 2004 9:21 pm Post subject: |
|
|
I was in a rush when I posted that.
Sorry about that
I should have refreshed my self with the @POS before I tryed to help, my mistake  |
|
| Back to top |
|
 |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Mon Apr 12, 2004 9:26 am Post subject: |
|
|
Never mind i fixed it.
Thanks anyway |
|
| Back to top |
|
 |
|