Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Vfp50 - Stripping spaces out of text.
Message
De
02/04/1997 20:43:05
Larry Long
ProgRes (Programming Resources)
Georgie, États-Unis
 
 
À
02/04/1997 15:02:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00026447
Message ID:
00026703
Vues:
45
>>>>>>What does table_fld look like?
>>>>>
>>>>>table)fld is 254 characters long. It will work when I say
>>>>>WHERE 'MODEM' $ table_fld
>>>>>but.. when I replace 'MODEM' with THISFORM.fld.VALUE, it will not work..
>>>>>
>>>>>help
>>>>
>>>>Ok....have you tried AT(thisform.fld.vlaue,table_fld)?
>>>>
>>>>Basically
>>>>
>>>>SELECT .....;
>>>>
>>>>WHERE AT(thisform.fld.vlaue,table_fld) > 0
>>>
>>>does not work, but thanks
>>How is your field getting its original value? What I am getting at is there might be some imbedded (unreadable) characters in your field. At the command prompt, open the dbf and select a record where your field = "MODEM". Does...
>>
>>? upper(alltrim(field))="MODEM"
>>
>>return .t. or .f.?
>>
>>If it returns .f. you will need to parse your field and get rid of the imbedded characters
>>
>>To parse try something like
>>
>>STORE UPPER(ALLTRIM(FIELD)) TO mTEST
>>STORE SPACE(0) TO mFieldString
>>FOR i=1 TO len(mTEST)
>> *TEST FOR A-Z
>> IF BETWEEN(ASC(SUBSTR(mTEST,i,1)),65,90)
>> STORE mFieldString + SUBSTR(mTEST,i,1) TO mFieldString
>> ENDIF
>>ENDFOR
>>
>>REPL Field WITH mFieldString
>
>thanks for the code... I need to strip out all characters, not just a through z.
>How would I do this?
>thanks again.. rob
1)You need to decide what characters you will allow as valid.
2)Look at an ascii chart and get the decimal equivalents (ie "A"=65)
3)Add to the IF by adding "OR ...."

For a range of values I would use the BETWEEN(....) again. For misc valid characters
I would use the INLIST(...).

I just tried a slightly different way and it works better (less coding & less CPU time)...
Assuming you want your letters, 0-9, a dash,slash as valid, I would use
-------------------------------------------------------------------------------------------------------------------------
STORE UPPER(ALLTRIM(FIELD)) TO mTEST
STORE SPACE(0) TO mFieldString

FOR i=1 TO len(mTEST)
STORE SUBSTR(mTEST,i,1) TO mTestChar

IF BETWEEN(mTestChar,"A","Z") OR BETWEEN(mTestChar,"0","9") OR INLIST(mTestChar,"-","/")
STORE mFieldString +mTestChar TO mFieldString
ENDIF
ENDFOR

REPL Field WITH mFieldString
--------------------------------------------------------------------------------------------------------------------------

You can add other characters to the INLIST, but there is a limit of 23 (or 26 can't remember right off hand) allowed per INLIST. If you need more just add another OR INLIST(....) to the IF...
L.A.Long
ProgRes
lalong1@charter.net
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform