Sami,
Buddy inspired me to create the following as a possible stored
procedure that returns only digits. I think it follows all the
rules for while optimization.
CLEAR ALL VAR
SET VAR vInp TEXT = ('00 051-334944XYZ')
-- ONLYDIGT: Stored procedure to return only digits from text
input
-- Paramter one is TEXT value
-- RETURN TEXT value
SET VAR vOut TEXT
SET VAR vCtl INTEGER = 1
WHILE vCtl <= (SLEN(.vInp)) THEN
IF 1 = (ISDIGIT(SGET(.vInp,1,.vCtl))) THEN
SET VAR vOut = (.vOut + SGET(.vInp,1,.vCtl))
ENDIF
SET VAR vCtl = (.vCtl + 1)
ENDWHILE
--CLEAR VAR vCtl, vInp
--RETURN vOut
--- remove comments on above 2 lines if you define as stored procedure
SHOW VAR vInp
SHOW VAR vOut
RETURN
Feel free to adapt it.
--
Jim Bentley
American Celiac Society
[EMAIL PROTECTED] - email
(973) 325-8837 voice
(973) 669-8808 Fax
---- "Walker, Buddy" <[EMAIL PROTECTED]> wrote:
> Sami
> I can't think of anyway to do it in one step. Maybe this can
> help.
>
> Buddy
>
> ********************
> CLE ALL VAR
>
> SET VAR V1 TEXT = ('00 051 334944')
> SET VAR V2 INTEGER = (SLEN(.V1))
> SET VAR VLoop INTEGER = 1
> SET VAR VFinal TEXT
> SET VAR V3 TEXT
>
> WHILE VLoop <= V2 THEN
> SET VAR V3 = (SGET(.V1,1,.VLoop))
> SET VAR VTest = (ISDIGIT(.V3))
> IF VTest = 0 THEN
> GOTO GetNext
> ENDIF
> IF VFinal IS NULL THEN
> SET VAR VFinal = (.v3)
> ELSE
> SET VAR VFinal = (.VFinal + .V3)
> ENDIF
> LABEL GetNext
> SET VAR VLoop = (.VLoop + 1)
> ENDWHILE
>
> SHO VAR V1
> SHO VAR VFinal
>
>
> *****************
>
> -----Original Message-----
> From: Sami Aaron [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 11, 2002 11:50 AM
> To: [EMAIL PROTECTED]
> Subject: Removing blank from data
>
>
> I am trying to compare data entered into a new record with existing
> data in
> the table.
>
> The data could be entered as:
>
> 00-051-334944
> 00051334944
> 00 051 334944
> 00-051-334944CZA
> Y 00 051-334944
>
> I want to compare JUST the NUMBERS entered into the field, so
> in this case,
> I want to get the value to:
>
> 00051334944
>
> then see if that value exists in the table, in any of the above
> formats.
>
> I can use the FORMAT function to strip out all non-numeric characters:
> SET VAR vtest TEXT = (FORMAT(.ftest,'99999999999999999999'))
>
> However, this function leaves a blank (CHAR(32))? anywhere there
> are
> non-numeric values. So, if the user entered, 00-051-334944,
> this function
> would give me 00 051 334944.
>
> Does anyone know a function or one-step SET VAR command to eliminate
> the
> remaining spaces within the field? I've tried the SRPL with
> the (CHAR(0))
> and with the (CHAR(8)) (backspace) but to no avail.
>
> I want to be able to issue the command:
>
> SELECT COUNT(*) INTO vcount FROM table WHERE (format(columnname,something,
> something)) = .vtest.
>
> example: SELECT COUNT(*) INTO vcount FROM table WHERE 00051334944
> =
> 00051334944
>
> Thanks,
> Sami
>
> -----------------------------------------------------------
> Sami Aaron
> Software Management Specialists
> 19312 W 63rd Terr
> Shawnee KS 66218
> 913-915-1971
> http://www.softwaremgmt.com
>
> ================================================
> TO SEE MESSAGE POSTING GUIDELINES:
> Send a plain text email to [EMAIL PROTECTED]
> In the message body, put just two words: INTRO rbase-l
> ================================================
> TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
> In the message body, put just two words: UNSUBSCRIBE rbase-l
> ================================================
> TO SEARCH ARCHIVES:
> http://www.mail-archive.com/rbase-l%40sonetmail.com/
>
>
>
> ================================================
> TO SEE MESSAGE POSTING GUIDELINES:
> Send a plain text email to [EMAIL PROTECTED]
> In the message body, put just two words: INTRO rbase-l
> ================================================
> TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
> In the message body, put just two words: UNSUBSCRIBE rbase-l
> ================================================
> TO SEARCH ARCHIVES:
> http://www.mail-archive.com/rbase-l%40sonetmail.com/
> ================================================
> TO SEE MESSAGE POSTING GUIDELINES:
> Send a plain text email to [EMAIL PROTECTED]
> In the message body, put just two words: INTRO rbase-l
> ================================================
> TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
> In the message body, put just two words: UNSUBSCRIBE rbase-l
> ================================================
> TO SEARCH ARCHIVES:
> http://www.mail-archive.com/rbase-l%40sonetmail.com/
>
================================================
TO SEE MESSAGE POSTING GUIDELINES:
Send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: INTRO rbase-l
================================================
TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: UNSUBSCRIBE rbase-l
================================================
TO SEARCH ARCHIVES:
http://www.mail-archive.com/rbase-l%40sonetmail.com/