External files

Using (Foxpro) functions filetostr and strtofile to read and write a specific file (f.e. e:\xxx\yyy\z.txt) on my server is ok in DeskApp but not in WebApp.
Error message: File not exists. Error number: 15
Is it not possible to use these functions in a Webapp?
filetostr() will run where the code runs, which is on the server, not on the client. Could that be the issue?

You can upload a file using networkrequest (http://www.lianja.com/community/show…load-in-Lianja) Here’s a thread for further reference: http://www.lianja.com/community/arch…hp/t-3027.html

Note that you can upload a file from the user’s desktop into a data file using the Attachments section, and then can run filetostr() on the memofield using mtos() .
assuming you have deployed the app to the server on the APaaS, and are calling the filetostr() through a call on the server (using Lianja.evaluate() from the JavaScript, or using an .rsp page) there should be no issue.

I would like to store some text from a .txt file to a memory variable. Below is what I did, but It does not work. invmemo still does not have the string from the text file. Any suggestions.

ans = messagebox("Do you want to add a memo to the invoice?", 36, "ADD MEMO")
if ans = 6
memofilename=GETFILE('txt',"","",2,'Add a .txt file to memo')
invmemo = filetostr(memofilename)


REPLACE invmemo with filetostr(memofilename)
APPEND MEMO invmemo FROM memofilename

Is it possible to get a return value from a run or spawn command
Yes, using spawnid() etc. you can know when the process ends.
So, the spawned
process writes to SessionStorage, and the calling process picks up the result from SessionStorage.

What would be a step by step to create a Lianja windows service?
Method 1: .bat file calling app with lianjaruntime.exe –app appname Run as Windows Scheduled Task, set to run on startup, with highest permissions.

Method 2: srvany.exe — blog post by Calvin Hsai here: http://blogs.msdn.com/b/calvin_hsia/…13/282351.aspx

I have an older VFP App where I use the run command to run some background processes. I have replaced them with the Lianja spawn command

The Spawn command uses the same syntax as the run command.
Spawn will run your process in the background and return control of your app back to while it is running.

Thats very handy if you need to run simultaneous operations while not relinquishing control of your application.
1) if you are running a lot of processes, you can end up overloading the processor and hurting UI performance. This would especially be the case if you were running a Lianja Desktop App on a remote desktop-type (RDP or ICA) environment.
2) you can monitor what processes you have running by getting the pid of a spawned process using ActivePid().
3) If you do have a cajillion background processes to run, you can run the spawn off a web service call to another server where the Lianja Cloud Server is running. Maintaining a central database with server and pid will allow you to coordinate all this.
4) You can get return values in a variety of ways. SharedMemory is one way (google Lianja Shared Memory). Another way is to the use monitoring database table entry for a given server and pid to hold the return value.

In my program, I have a canvas section with a command button.
When the button is clicked, I access a local database then transfer the rows of data to an excel sheet.
So far it’s all working fine except for the processing speed.
It starts off by processing approx. 4 rows every second. Shortly afterwards, the process slows down.

  scatter to ExcelExport
  WITH oExcel
    .Range("A" + ALLTRIM(str(excelRowCount))).Value = ALLTRIM(LNAME)

  // Activate another table
  select ...
  append blank
  gather FROM ExcelExport
  replace DATEARCHIVED with date()
  skip 0
  excelRowCount = excelRowCount + 1
  progBarCount = progBarCount + 1
  Lianja.Get("page.section.pbExport").value = progBarCount

If excel is indeed the issue, see if you can issue one command to excel that exports the data you need in csv format (or even ado-style xml). Exporting that will be a quick task, as will importing into a cursor in Lianja. From there, things should fly.
“winner” code which execute almost instant:

proc page1_section1_field2_click()
        cDirSelected = getdir("C:\","","Please Select A Directory For File Saving")
        IF inuse("exceldata") = .T.
            SELECT exceldata
            select 0
            use exceldata
        cDateTime = ttoc(datetime(),1)
        if right(cDirSelected,1)  "\"
            cDirSelected = cDirSelected + "\"
        cSaveAsPath = cDirSelected + "ExcelExport_" + cDateTime + ".txt"
        set textmerge to (cSaveAsPath)
        set textmerge delimiters to "{{","}}"
        set textmerge on



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s