Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parsing a file that's not quite comma-delimited
Message
De
11/07/2007 20:06:42
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
 
 
À
11/07/2007 12:34:15
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01238841
Message ID:
01239555
Vues:
27
I usually don't ask for code reviews, but in this case, with so many people giving a hand, I would like to know if there are any glaring issues with the code below. It seems to take the HL7 message and parse it correctly and also populates the 7 cursors as well. It's not the finished version, but before I went to far along...
* This is the EMPSMain program code, but modified for simplified testing.

CLOSE ALL
CLEAR ALL
CLEAR

SET SAFETY OFF

* SET STEP ON

Convert_HL7_Billing_Data(FILETOSTR("c:\HL7_IN\HL7BB.tmp"))

CANCEL


*******************************************************************************
PROCEDURE Convert_HL7_Billing_Data
*******************************************************************************

PARAMETERS tInput

strProcessData = tInput

FOR ix=1 TO ALINES(laLines,strProcessData) STEP 7

 	* One block of tables is 7
	FOR jx = 0 TO 6
		STORE LineToObject(laLines[m.ix+m.jx]) TO ('loObj'+LTRIM(STR(m.jx+1)))
		m.CursorFieldList = ''
		FOR iCount = 1 TO EVALUATE('loObj'+LTRIM(STR(m.jx+1))+".FieldCount")
			m.CursorFieldList = m.CursorFieldList + 'Field'+PADL(iCount,3,'0') + ' M, '
		ENDFOR
		m.CursorFieldList = '(' + SUBSTR(m.CursorFieldList,1,LEN(m.CursorFieldList)-2) + ')'
		CREATE CURSOR ("Crs" + ALLTRIM(UPPER(EVALUATE('loObj'+LTRIM(STR(m.jx+1))+".TableName")))) &CursorFieldList
		INSERT INTO ("Crs" + ALLTRIM(UPPER(EVALUATE('loObj'+LTRIM(STR(m.jx+1))+".TableName")))) FROM NAME 'loObj'+LTRIM(STR(m.jx+1))
	ENDFOR

ENDFOR

SET STEP ON


*******************************************************************************
PROCEDURE LineToObject(tcLine)
*******************************************************************************

LOCAL loRecord,ix

loRecord = CREATEOBJECT('Empty')

ADDPROPERTY(loRecord, 'TableName', GETWORDNUM( m.tcLine,1,'|'))

FOR ix=1 TO OCCURS('|',m.tcLine)
	ADDPROPERTY(loRecord, ;
		'Field'+PADL(m.ix,3,'0'), ;
		STREXTRACT(m.tcLine,'|','|',m.ix,2))
ENDFOR

ADDPROPERTY(loRecord, 'FieldCount', ix-1)

RETURN loRecord

ENDPROC
*******************************************************************************
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform