Page 1 of 1

LiveCode 4.5.2 with Sqlite

Posted: Thu Dec 23, 2010 11:22 pm
by macroman
I'm having a really strange issue with database access on LiveCode 4.5.2 and I'm just wondering if anybody might have any idea as to what is going on.

I'm trying to get up to speed with LiveCode having written software in just about every other language going over the years so I started writing a small app using a simple sqlite database. As I progressed, I discovered that the database access wasn't doing much. The code is so simple, there couldn't be a lot wrong with it so far... there's only one table, two fields, two records and one sql select.

I then discovered much to my annoyance that if I build a standalone application, it works absolutely perfectly every time. If I switch back to the IDE, then it doesn't work any more.

At this stage, I can see absolutely no logic in what is happening. I've wasted hours and hours messing around with this and the outcome is still exactly the same. Standalone... works perfectly, IDE doesn't work and no errors. I'm working locally on Windows Vista SP2.

Does anybody have any thoughts on this???

Thanks a mil,

Mike

Re: LiveCode 4.5.2 with Sqlite

Posted: Fri Dec 24, 2010 1:12 pm
by Klaus
Hi Mike,

sounds like a pathname problem.
Could you please post some script snippets and info about the folder structure you use in the IDE?


Best

Klaus

Re: LiveCode 4.5.2 with Sqlite

Posted: Fri Dec 24, 2010 5:25 pm
by macroman
Hi Klaus,

There's not much left at this stage because I've cut it to bits so much. There used to be error handling and a lot more in the code but it's all gone now, in an effort to try to work out what is happening. What I'm left with at the moment is:

on mouseUp
put revOpenDatabase("sqlite","pimdata.db",,,,,,) into mydb
put revDataFromQuery(,,mydb,"SELECT * FROM investigator_groups") into field "textarea"
revCloseDatabase mydb
end mouseUp


I tend to switch between a PC and my notebook and because of that, I've been working from a folder on the desktop which I just move around. The app and the database are just in the one folder.

Mike

Re: LiveCode 4.5.2 with Sqlite

Posted: Fri Dec 24, 2010 5:39 pm
by Klaus
Hi Mike,

well, when you doubleclick a standalone "the defaultfolder" is the directory the app/exe is in.
This may not be the case in the IDE!

Try to use a function like this:

Code: Select all

on mouseUp
  put tAppPath() & "pimdata.db" into tDB
  put revOpenDatabase("sqlite",tDB,,,,,) into mydb
  put revDataFromQuery(,,mydb,"SELECT * FROM investigator_groups") into field "textarea"
  revCloseDatabase mydb
end mouseUp

function tAppPath
  put effective filename of this stack into tFilename
  set itemdel to "/"
  if the platform = "MacOS" AND the environment <> "development" then
  ##!!
     delete item -4 to -1 of tFileName
    ## MacApp.app/Contents/MacOS/Standalonestack
  else
    delete item 1 of tFileName
  end if
   return tFilename & "/"
end tAppPath
Merry christmas :)

Best

Klaus

Re: LiveCode 4.5.2 with Sqlite

Posted: Fri Dec 24, 2010 6:09 pm
by macroman
Klaus,

Thank you so much. You were absolutely spot on with your diagnosis.

I made a quick change to the code you posted to 'delete the last item of tFileName' instead of the first to get the full path and it is working perfectly, every time. I had wrongly assumed that the IDE was managing the folder which of course I should not have been doing.

Once again, thanks a million for your help and I hope you have a great Christmas.

Mike