Page 3 of 3
Re: Please help with syntax
Posted: Wed Mar 11, 2015 6:41 pm
by robbie73
serge_girard wrote:Robbie,
May I suggest to examine to valueof vfield before using the Alltrim function; vfield is probably empty.
Serge
Thank you serge, Yes, examining the data in the field is what i'm trying to do. But I am very beginner.
I need to clear EVERYTHING that is not an alpha-numeric character. Oddly, the exact code example I posted will work perfectly well when compiled in clipper/linker in DOS with the same sample data. Compiling in hmg won't work. I'm not saying HMG is the cause. merely that is seems to compile 'differently' or perhaps less forgiving of bad code?
Anyway, i still need a procedure that will examine the field and remove allnon alpha-numeric characters.. thinking about it... it needs to not only trim from both ends, but examine the entire string and remove/replace non alphanumeric characters that can be compiled in hmg unicode.
Do you know of the existence of such a procedure please??
Re: Please help with syntax
Posted: Wed Mar 11, 2015 7:29 pm
by Javier Tovar
Robbie,
Please why not post your code and your DBF or where you ontienes your information seriously that easier.
I would say that Uses the VALTYPE() functions and function TYPE().
regards
Re: Please help with syntax
Posted: Wed Mar 11, 2015 8:12 pm
by esgici
robbie73 wrote:...i still need a procedure that will examine the field and remove allnon alpha-numeric characters.. thinking about it... it needs to not only trim from both ends, but examine the entire string and remove/replace non alphanumeric characters that can be compiled in hmg unicode.
Do you know of the existence of such a procedure please??
Code: Select all
#include <hmg.ch>
/*
Remove all non alpha-numeric characters from a string
*/
PROC MAIN
cOriginal := "=<abc_-.#@123>#+-.,"
cCleaned := RemNAN( cOriginal )
MsgBox( "Original : " + cOriginal + STR( LEN( cOriginal ), 3 ) + CRLF + ;
"Cleaned : " + cCleaned + STR( LEN( cCleaned ), 3 ) )
RETU
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FUNC RemNAN( cString )
LOCAL cRVal := "",;
c1Char := ""
FOR EACH c1Char IN cString
cRVal += IF( ISALPHA( c1Char ) .OR. ISDIGIT( c1Char ), c1Char, "" )
NEXT
RETU cRVal
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Re: Please help with syntax
Posted: Thu Mar 12, 2015 2:53 am
by esgici
A sample test program that scan any table records for empty fields in any type ,
and reports number of record(s) included empty field(s) with number of FIRST empty field.
Code: Select all
#include <hmg.ch>
PROC MAIN
SET( _SET_EOF, .F. )
USE TEST
nFldCount := FCOU()
cTestFNam := "empties.txt"
nEmptyRec := 0
SET ALTERNATE TO (cTestFNam)
SET ALTERNATE ON
WHIL ! EOF()
FOR nFld := 1 TO nFldCount
IF EMPTY( FIELDGET( nFld ) )
? RECN(), nFld
++nEmptyRec
EXIT
ENDI
NEXT
SKIP
ENDD
SET ALTE OFF
SET ALTE TO
MsgBox( LTRIM( STR( RECC() ) ) + " records with " + LTRIM( STR( nFldCount ) ) + " field(s) scanned ;" + CRLF + ;
LTRIM( STR( nEmptyRec ) ) + " records found with empty field." )
EXECUTE FILE "NOTEPAD.EXE" PARAMETERS cTestFNam
RETU
- ScanFile.PNG (4.15 KiB) Viewed 3355 times
Re: Please help with syntax
Posted: Thu Mar 12, 2015 8:29 am
by serge_girard
Brilliant Esgici !
Serge
Re: Please help with syntax
Posted: Thu Mar 12, 2015 11:19 am
by esgici
Thanks Serge
Brilliant is HMG and supporters
Viva HMG
Re: Please help with syntax
Posted: Thu Mar 12, 2015 4:01 pm
by andyglezl
Esgici Many thanks, we apply