Help!
The following example code (supllied with Sesame) does not now work with V1.0.3. I have not altered the example code since the original work on V1.0.0.
Using the same code, now I am able to choose ONLY the first option in the list. If I choose any other option (stored in Documents.txt file) I get an error message stating that the file does not exist.
Original Code as supplied . . .
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
/* This program differs slightly from the one in
Appendix 2 of the Sesame Programming Guide.
This one gets its listFirst of available merge documents
from an external text file (list.txt) instead of the
document names being hard-coded into the program.
One may then create any number of merge documents,
and simply edit the list.txt file (with Notepad) to
correspond to the available merge documents */
// Next 4 lines user modifiable
var vDataPath as String = "c:\SESAME\DATA\docs\Merge.txt"
var vDocsPath as String = "c:\SESAME\DATA\docs\"
var vWordPath as String = "c:\SESAME\DATA\Publisher.bat"
var vListPath as String = "c:\SESAME\DATA\docs\Documents.txt"
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 @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)
}
END SUBROUTINE
// BEGIN MAIN PROGRAM
// Build documents menu
vSelectedDoc = @PopupMenu(
@insert(vListPath), "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 exsting data file. New one will be generated.
If FileExists(vDocsPath + vSelectedDoc) Then
{
fileDelete(vDataPath)
// Fields available for merging
F[1] = "SSN";
F[2] = "SCN";
F[3] = "PRODUCT"
F[4] = "PRODUCTVERSIONNUMBER";
F[5] = "PURCHASED"
F[6] = "PURCHASEDFROM"
F[7] = "SUPPORTTYPE";
F[8] = "SUPPORTDESCRIPTION"
F[9] = "SUPPORTFROMTEXT"
F[10] = "SUPPORTEXPIRESTEXT";
F[11] = "COMPANYNAME";
F[12] = "TRADINGAS";
F[13] = "TITLE";
F[14] = "FIRSTNAME";
F[15] = "LASTNAME" ;
F[16] = "CONTACTNAME";
F[17] = "PADDRESS";
F[18] = "PADDRESS2";
F[19] = "PADDRESSTSP";
F[20] = "EMAIL";
F[21] = "PHONEBH";
F[22] = "PHONEFAX"
F[23] = "PHONEMOBILE";
F[24] = "PHONEAH"
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.","","Aw shucks!")
}
Documents.txt file contents . . .
DL Envelope.pub ;
V11.00 Upgrade Order Form MERGE FIELDS ONLY.pub ;
Order Form EASC Special Offer March 2004.pub ;
Thnaks in advance