Please help with syntax

Moderator: Rathinagiri

robbie73
Posts: 11
Joined: Sat Jan 05, 2013 6:59 pm

Re: Please help with syntax

Post 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??
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Please help with syntax

Post 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
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Please help with syntax

Post 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

*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Attachments
remNAN.PNG
remNAN.PNG (16.68 KiB) Viewed 3354 times
Viva INTERNATIONAL HMG :D
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Please help with syntax

Post 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
ScanFile.PNG (4.15 KiB) Viewed 3333 times
Viva INTERNATIONAL HMG :D
User avatar
serge_girard
Posts: 3167
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Please help with syntax

Post by serge_girard »

Brilliant Esgici !


Serge
There's nothing you can do that can't be done...
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Please help with syntax

Post by esgici »

Thanks Serge :oops:

Brilliant is HMG and supporters :)

Viva HMG :D
Viva INTERNATIONAL HMG :D
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Please help with syntax

Post by andyglezl »

Esgici Many thanks, we apply
Andrés González López
Desde Guadalajara, Jalisco. México.
Post Reply