Re: more sequence help
- Posted by Irv Mullins <irv at ELLIJAY.COM> Feb 19, 2000
- 483 views
On Fri, 18 Feb 2000, you wrote: > >%_Once again I throw myself at the feet of the masters and humbly beg for > >help. . . . . . > > here is what I am trying to do > > supplierfname= open(sname & ".dat", "w") > > printf( supplierfname, "%s", {supplierdata} ) > > close(supplierfname) > > what am I doing wrong? I want to save this sequence into a file and it keeps > giving me errors? I always use print() and get() to write and read files of this sort, not printf. Using print and get is very simple, one-line of code to read or to write the entire list, no matter how long the list may be. Code is posted at the end of this message. There is a drawback to this method: the files are written in Euphoria format, which means they are not readily readable by text editors, etc. This may also be considered a benefit, because it makes the data a little more difficult for the casual unauthorized browser to read. Without more information, I can't give more specific instructions, except that there is no way I can see for printf( supplierfname, "%s",{supplierdata}) to work with a list of suppliers, no matter _how_ supplierdata is constructed. --General hints for debugging-- How far does it get before you get an error? I'm guessing you don't have the registered version, which would have given a detailed explanation of the error., so... One way to debug without the registered version is to insert a trace(1) just before this code, and step thru the code. When you get to the problem line, the program will halt. Now you know which line is at fault, so investigate the line for correct syntax. Assuming that it is correct, then step thru again, this time inspecting the data that is being handed to the function or command in question. If all else fails, ask someone who has a registered version to run your program and let you know what ex.err says. Regards, Irv constant CustFileName = "C:\\Demo\\Customer.dat" global constant -- these are the "fields" of my customer data custRecordID = 1, custCode = 2, custName = 3, custContact = 4, custAddr1 = 5, custAddr2 = 6, custZip = 7, custPhone = 8, custCurr = 9, custPd30 = 10, custPd60 = 11, custPd90 = 12, custLastPayAmt = 13, custLastPayDate = 14, custRateSchedule = 15 object Customers -- container for records 1..n with above structure Customers = {} ---------------------------------------- global procedure ReadCustomerFile() ---------------------------------------- fn = open(CustFileName,"r") if fn > 0 then -- file exists Customers = get(fn) -- note: no loop is necessary close(fn) if equal(Customers, {1,0}) then -- file corrupt (not in Eu fmt) fn = message_box("Corrupt Customer data file","Error", MB_ICONERROR) return end if if Customers[1] = GET_SUCCESS then Customers = Customers[2] -- strip off the success flag, and for i = 1 to length(Customers) do -- append a unique record ID for use when Customers[i][custRecordID]= i -- the records are later re-ordered end for end if -- success else fn = message_box( "Cannot load "&CustFileName&" file", "File Read Error",MB_OK) end if -- file exists end procedure --------------------------- global procedure WriteCustomerFile() --------------------------- fn = open(CustFileName,"w") if fn > 0 then print(fn,Customers) -- again: no loop here, entire list is written close(fn) end if end procedure