SQLitening Support Forum

SQLitening Support => You've got Questions? We've got Answers! => Topic started by: Haakon Birkeland on September 21, 2011, 05:01:10 pm

Title: "Flat file" capabilities
Post by: Haakon Birkeland on September 21, 2011, 05:01:10 pm
slGetFile refers to working with a "... flat file (standard or INI) ...

What's the definition/layout of a standard "flat file" in this case
Title: Re: "Flat file" capabilities
Post by: Fred Meier on September 22, 2011, 07:07:22 pm
There is a good definition at http://en.wikipedia.org/wiki/Flat_file_database

I started calling them Binary files in release 1.4 because of the use of
PowerBasic binary file mode to Get$ and Put$ the contents of any file. 

I think of data files as two types: databases and flat/binary.  With
slGetFile and slPutFile you are able to manipulate(read/write) flat/binary
files anyway you want to.  The files may reside on the local computer or on the server.

An Ini file is a flat/binary file with a specific format that slGetFile
and slPutFile support.  A Csv file is a flat/binary file with a specific
format that also may be processed with slGetFile and slPutFile. 

Read the doc about slGetFile and slPutFile in SQLitening.Txt or
SQLitening.Chm and then you may want to write a simple program that reads
and writes a flat/binary file. 
Title: Re: "Flat file" capabilities
Post by: cj on September 29, 2011, 05:13:45 am
With text files it is easy to just let another program handle the data rather than loading into a control.
I just used the filename already in the FACT which is nice for passing data back and forth.


FUNCTION GetFile AS LONG
  LOCAL result AS LONG, sFileName, sData, rsModChars, NewFile AS STRING
  sFileName = "RemoteFileUploadDownloadExample.txt"
  result = slGetFile(sFileName,sData,rsModChars)
  IF result THEN EXIT FUNCTION
  NewFile = EXE.PATH$ + sFileName
  result = FREEFILE
  OPEN  NewFile FOR OUTPUT AS #result
  IF ERR THEN ? "error" + STR$(ERRCLEAR) + " opening for output " + NewFile:EXIT FUNCTION
  PRINT #result, sData
  IF ERR THEN ? "error" + STR$(ERRCLEAR) + " writing " + NewFile:CLOSE #result:EXIT FUNCTION
  FLUSH #result
  CLOSE #result
  ShellExecute(ghDlg, "Open", NewFile + CHR$(0), $NUL, $NUL, %SW_SHOWNORMAL)
END FUNCTION
Title: Re: "Flat file" capabilities
Post by: cj on October 01, 2011, 03:32:01 pm
slGetFile also works in a threaded environment where each thread must issue a  slConnect.
slDisconnect may be used after a thread finishes. 

Any file to be transferred must have its name in the [FACT] section of ..\bin\SqliteningServer.cfg.
The physical file on the server must be in ..\bin or underneath on the server.