Page 1 of 1

Trouble building the Clock App

Posted: Sat Oct 24, 2015 5:54 pm
by Bellballer1
Hi!
I am following the video on how to build the Clock app in LiveCode. In the Day 2 video, I am trying to include the "citylist.txt" list into my Clock stack, but it is not happening. In the video it says to "make sure the file that contains the clock stack is in the same folder that contains citylist.txt. Has anyone else encountered this problem or can provide a solution? Thanks!

Re: Trouble building the Clock App

Posted: Sat Oct 24, 2015 6:31 pm
by Klaus
HI Bellballer1,

1. welcome to the forum! :D

2. Could you please give some more info about what video/lesson exactly you are referring to?
There are LOTS of them on the internet...


Best

Klaus

Re: Trouble building the Clock App

Posted: Sat Oct 24, 2015 6:50 pm
by Bellballer1
I am referring to the "Create it with LiveCode" tutorial. It is one of the videos/lessons that comes with the LiveCode subscription. Specifically I am having a problem trying to complete lesson 2 of the "Clock-App 4." The citylist.txt is one of the resources that comes with the lesson and on "preOpenCard" I need that list to open and be read.

on preOpenCard
set the visible of group "groupSearch" to "true"
--no specialFolderPath to where the .livecode file is --so use the effective filename
put the effective filename of this stack into tFile set the itemDelimiter to slash --split by slashes
put "citylist.txt" into last item of tFile
--Read the file and put the data into lCityText variable
put URL ("file:" & tFile) into lCityText
--Load City List
LoadCityList

The above is the example from the slide show associated with that lesson.

Re: Trouble building the Clock App

Posted: Sun Oct 25, 2015 2:07 pm
by Klaus
Hi Bellballer1,

OK, I see, thanks!
Now what exactly goes wrong, or does not work?

Hint:
Make sure this are 2 (TWO) lines:
...
## put the effective filename of this stack into tFile set the itemDelimiter to slash --split by slashes
...
## !!!
put the effective filename of this stack into tFile
set the itemDelimiter to slash --split by slashes
## !!!
...

Is "lCityText" defined as a GLOBAL or LOCAL variable?
Maybe you can also post the script of handler "LoadCityList"?


Best

Klaus

Re: Trouble building the Clock App

Posted: Sun Oct 25, 2015 4:23 pm
by Bellballer1
Hi Klaus!

Thanks for the reply. I think the problem is is that the "citylist.txt" file is not being read, since it is an add-on to this lesson (it came as a separate attachment with the lesson plan). I'm not sure how LiveCode is able to read it or find it and add it to the stack I am working on. When I run the preOpenCard command, nothing happens (the citylist.txt file does not load).

I have "lCityText" defined as a local variable.

I also have the 2 lines written as you suggested. This is what I have:

local lCityText

on loadCityList pSearch
put lCityText into tCityList
if pSearch is not empty then
filter tCityList with ("*" & pSearch & "*")
end if
put "city" & tab & "UTC" & cr before tCityList
set the dgText[true] of group "gridCityList" to tCityList
end loadCityList

on preOpenCard
put the effective fileName of this stack into tFile
set the itemDelimiter to slash
put "citylist.txt" into last item of tFile
put URL ("file:" & tFile) into lCityText
loadCityList
end preOpenCard

Thanks for your help!

Bellballer1

Re: Trouble building the Clock App

Posted: Sun Oct 25, 2015 4:57 pm
by Klaus
Hi Bellballer1,

hmmm, not sure what's going wrong if you have your stack and that text file in the same folder.

Add this line to see if Livecode actually does not find the file:

Code: Select all

on preOpenCard
   put the effective fileName of this stack into tFile
   set the itemDelimiter to slash
   put "citylist.txt" into last item of tFile

  ## !!
  answer (there is a file tFile)
  ## Will display false if file not found.
...
Best

Klaus

Re: Trouble building the Clock App

Posted: Sun Oct 25, 2015 5:58 pm
by Bellballer1
Hi Klaus!

I am a true beginner...how can I make sure that my stack and the text file are in the same folder? I created a new folder that contains my stack and the text file, but that's actually the part that is confusing me. I apologize for being a pain. Thanks!

Bellballer1

Re: Trouble building the Clock App

Posted: Sun Oct 25, 2015 9:53 pm
by Klaus
Hi Bellballer1,
Bellballer1 wrote:how can I make sure that my stack and the text file are in the same folder?
this is more a logical resp. semantic and not a LC problem! :D
If you are in the same room as you mother, well, then you are in the same room as your mother! :D
Bellballer1 wrote:I created a new folder that contains my stack and the text file...
That's all you need to do!
Bellballer1 wrote:...but that's actually the part that is confusing me.
...
put the effective fileName of this stack into tFile
...
This will put an absolute pathname like tis into the variable tFile:
Mac:
Hard disk name/Folder 1/subfolder/Your project folder here/filename of your stack.livecode
Windows:
C:/Hard disk name/Folder 1/subfolder/Your project folder here/filename of your stack.livecode
...
set the itemDelimiter to slash
put "citylist.txt" into last item of tFile
...
Will replace the last item "filename of your stack.livecode" with "citylist.txt", so the variable tFile will now look like:
Hard disk name/Folder 1/subfolder/Your project folder here/citylist.txt

That means whereever you put your stack, this script will know the exact pathanme and this the path to the text file
IF it is in the same folder!

Please add the addtional line I mentioned above and tell me what the dialog tells you!

In the meantime I recommend to check these stacks to get more of the basics of Livecode:
http://www.hyperactivesw.com/revscriptc ... ences.html


Best

Klaus

Re: Trouble building the Clock App

Posted: Mon Oct 26, 2015 3:17 pm
by Bellballer1
Hi Klaus!

Success! I went back and started from scratch, and everything is working now (smile). I think when I was debugging I did something wrong. Everything is working and loading as the video instructs. Thanks for your help!

Bellballer1