• Welcome, Guest. Please login.
 
May 26, 2019, 04:29:08 am

News:

Welcome to the SQLitening support forums!


"Flat file" capabilities

Started by Haakon Birkeland, September 21, 2011, 05:01:10 pm

Previous topic - Next topic

Haakon Birkeland

slGetFile refers to working with a "... flat file (standard or INI) ...

What's the definition/layout of a standard "flat file" in this case
Haakon 8o)

Programming is like sex - one error and you will have to support it for years.

Fred Meier

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. 

cj

September 29, 2011, 05:13:45 am #2 Last Edit: September 29, 2011, 05:16:44 am by cj
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

cj

October 01, 2011, 03:32:01 pm #3 Last Edit: October 01, 2011, 04:03:58 pm by cj
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.