The merge programming is as follows so far. [F21] is the problem LE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> var vFileHandle as Int // For writing data file var vHeader as String // Data file header line var vData as String // Data file data line var n as Int = 1 // General purpose counter var vSelectedDoc as String // Document selected from menu var vOneOrAll as String // Include record(s) option var F as array[25] of String // Mergeable fields array var vStartingRec = @ResultSetCurrentPosition() var vGoPrint as String
// Next 3 lines user modifiable var vDataPath as String = "C:\critical files\myfiles\word docs\flower.txt" var vDocsPath as String = "C:\critical files\myFiles\word docs\" var vWordPath as String = "c:\word.bat"
SUBROUTINE PrintCurrentRecordOnly()
If @Askuser("Merge print the " + vSelectedDoc + " for " + vOneOrAll + "?","","") Then {
vGoPrint = "Yes"
n = 1 While F[n] <> "" { vHeader = vHeader + F[n] + "^" vData = vData + @(F[n]) + "^" n = n + 1 }
vFileHandle = fileOpen(vDataPath) fileSeek(vFileHandle, 0) fileWriteLn(vFileHandle, vHeader + @NewLine() + vData) fileClose(vFileHandle)
}
END SUBROUTINE
SUBROUTINE PrintAllRetrievedRecords()
var n as Int var i as Int = 1
If @Update Then {
If @Askuser("Merge Print " + vSelectedDoc + " for these " + @ResultSetTotal() + " retrieved records?", "( If not, cancel this task, press F7 for a new search,"," and retrieve the records DO you want to print. )") Then {
vGoPrint = "Yes"
n = 1 While F[n] <> "" { vHeader = vHeader + F[n] + "^" n = n + 1 }
vFileHandle = fileOpen(vDataPath) fileSeek(vFileHandle, 0) fileWriteLn(vFileHandle, vHeader)
For n = 1 to @ResultSetTotal()
ResultSetCurrentPosition(n)
While F[i] <> "" { vData = vData + @(F[i]) + "^" i = i + 1 }
FileWriteLn(vFileHandle, vData)
@Msg("Processed Record " + n + " of " + @ResultSetTotal()) vData = "" i = 1
Next
fileClose(vFileHandle)
// Rewind to record where it all started ResultSetCurrentPosition(vStartingRec)
} } Else @Msgbox("Printing retrieved records can only be done in Update mode.","","")
END SUBROUTINE
// BEGIN MAIN PROGRAM
// Build documents menu
vSelectedDoc = @PopupMenu( "Flowersheet.doc;" + "wreathsheet.doc;", "SELECT MERGE DOCUMENT" )
// Build which record(s) menu
vOneOrAll = @PopupMenu( "THIS Record Only;" + "ALL Retrieved Records;" , "SELECT RECORD(S) TO MERGE PRINT" )
If vSelectedDoc <> "" and vOneOrAll <> "" Then {
// Delete existing data file. A new one will be generated. If FileExists(vDocsPath + vSelectedDoc) Then { fileDelete(vDataPath)
// Fields available for merging F[1] = "Search"; F[2] = "First_name"; F[3] = "Last_Name" F[4] = "Street_Address" ; F[5] = "Town"; F[6] = "Postal_Code" F[7] = "Province_State"; F[8] = "Country" ; F[9] = "Range" F[10]= "Section"; F[11]= "Lot"; F[12]= "Bed_Size" F[13]= "Ger_,_Beg"; F[14]= "Ger_,_Aly"; F[15]= "Beg_,_aly" F[16]= "Pet_,_Aly"; F[17]= "IMP_ONLY"; F[18]= "Planting_Charge"; F[19]= "Service_Charge"; F[20]= "Monument_Marker_Name"; F[21]= "Decoration_Day_is";
If vOneOrAll = "THIS Record Only" Then PrintCurrentRecordOnly() Else PrintAllRetrievedRecords()
If vGoPrint = "Yes" Then { // Start Word via Word.bat and pass doc filename. n = @Shell(vWordPath + " " + @Chr(34) + vDocsPath + vselectedDoc + @Chr(34)) If n = 1 Then @Msgbox(vDocsPath + vSelectedDoc,"word.bat not found or something else wrong.","") } } Else @Msgbox(vDocsPath + vSelectedDoc + " doesn't exist.","","Please be sure that Flowersheet.doc is in the directory C:\myfiles\word docs\, Please Try Again!") }
|