Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOWTO DELETE A SINGLE CHAR FROM STRGETC

Status
Not open for further replies.

teletubby5e

Technical User
Oct 31, 2002
147
US
Hello all,
I have a script that gets screen output from a 5e switch via a telnet session, reads a string from a line, and then performs some "scrubbing " to get it into a manageable format for us to use. Is there a "STRDELC" sort of command. I am trying to read a string NUM1, and see if there are any nonnumeric characters, then del them. leaving only the numbers.

here is part of a scrpt that I cant remember where I got, called isnum.was

func ISNUM : integer
param string NUM1
integer iLen, iCount, iVal
strlen NUM1 iLen ; PUTS LENGTH OF NUM1 INTO ILEN
for iCount = 0 upto iLen-1 ; LOOPSTO END OF NUM1
strgetc NUM1 iCount iVal
; IF A NONNUMERIC CHARACTER
if ((iVal < 48) || (iVal > 57))
return 0 ; DO THIS
endif
endfor
return 1 ; ELSE DO THAT
endfunc

WHERE IT SAYS RETURN 0, I AM WANTING TO DELETE ONLY THE CHARACTER IF IT IS NOT A NUMBER. AM I GOING TO NEED TO DO AN ITOA CONVERSION YOU THINK?

THANKS, JEFF
 
Here is a little different code that builds a second string composed of only the numeric values from the string in NUM1:

proc main
string NUM1
string sFilteredNum
string sChar
integer iLen, iCount, iVal
strlen NUM1 iLen ; PUTS LENGTH OF NUM1 INTO ILEN
for iCount = 0 upto iLen-1 ; LOOPSTO END OF NUM1
strgetc NUM1 iCount iVal
; IF A NUMERIC CHARACTER
if ((iVal > 48) && (iVal < 58))
strputc sChar 0 iVal
strcat sFilteredNum sChar
endif
endfor
endproc

aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top