General information
Category:
Coding, syntax & commands
Payback maybe? I too append into my VFP tables from text files. I have insured each text record is delimited with $, just to be safe.
My code is probably not as elegant as yours... but I am still learning. I have used this for 3.5 million records. Some may say it is 'slow', but it works for me.
Here is some excerpts..
LPARAMETER lcFile
*** lcFile is the text file....
_SCREEN.MousePointer = 11
lnHandle =FOPEN(THISFORM.cPath+lcWorkFile)
lnPoint =FSEEK( lnHandle,0,0)
lnCount= 0
** Here is my wait window... I also have a 'blinking screen' method which adds ** a pizazz to keep the user 'occupied' (the more color, the more it is
** working!) I use a WIN API to move the message box around a bit, here and
** there. The 'count' process immediately below can be long.
lcMessage = "Cross Checking Records - Upload....Please Be Patient....Counting Out "
DO WHIL .NOT. FEOF( lnHandle )
lcLine =FGETS(lnHandle)
lnCount = lnCount + 1
lcMessage1 = lcMessage + ALLTRIM(STR(lnCount))
******Show the window again spinning numbers make users feel important...
WAIT WIND lcMessage1 NOWAIT
ENDDO
** Empty file trap
IF lnCount < 1
_SCREEN.MousePointer = 0
RETURN
ENDIF
*** Do some stuff to set up my tables
** Reset my file pointer
lnPoint=FSEEK(lnHandle,0,0)
** setup thermo...
lnThermBasis = lnCount
lcThermTitle =IIF(SUBSTR(UPPER(ALLTRIM(lcWorkFile)),1,2)"CL","Client","Product")
lcThermTitle = lcThermTitle + " Update - Clearpath"
lcThermTaskTitle = "Cross Checking Records - Upload"
lcThermTaskName = "Loading From Clearpath Source File....."
oThermo =NewObject("c_thermo_form", "class\c_object\c_object_therm",.NULL., ;
lcThermTitle, lcThermTaskTitle, lnThermBasis, 0)
oThermo.Show()
****pick up records from text file....
DO WHIL .NOT. FEOF( lnHandle )
lnOnRecn = lnOnRecn + 1
lcLine =FGETS( lnHandle)
lcLine = ALLTRIM(lcLine)
lnDelimit =OCCURS("$",lcLine)
llIsError = .F.
*** Put the data where it belongs
*** Now, update our thermo.....
lcThermTaskName = "Loading From Clearpath Source File.....File Number: "
lcThermTaskName = lcThermTaskName + ALLTRIM(STR(lnOnRecn))
lcThermTaskName = lcThermTaskName + " Of Record Count Total: "
lcThermTaskName = lcThermTaskName + ALLTRIM(STR(lnCount))
lcThermTaskName = lcThermTaskName + " Update Procedures."
oThermo.therm_update(lnOnRecn,lcThermTaskName)
ENDDO
llClose =FCLOSE( lnHandle)
_SCREEN.MousePointer = 0
oThermo.therm_complete(lcThermTaskName)
IF TYPE("oThermo") == "O"
oThermo.Release()
ENDIF
RELEASE oThermo
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only