Page 2 of 2

Re: Clock App

Posted: Fri Jun 10, 2016 2:57 pm
by jameshale
I can have a look from Monday so if you can zip the stack and post it here I will,take a look.


Re: Clock App

Posted: Fri Jun 10, 2016 3:05 pm
by dave.kilroy
Hi Saleh

What happens if you download the completed lesson stack and step through it? Does it behave in the same way as your own one? What are the differences (if any)? Does the completed lesson stack give you any clues as to what the problem is?
If so then it may be worth your while also downloading the completed stack "clock-6.livecode" and comparing it with your own - for example on the card they name "cardAlarm" they have not one but two datagrids ("gridAlarm" and "gridAlarmEdit"). I haven't stepped through the code properly and can't say for sure whether both datagrids are actually needed - but the difference in the number of datagrids is pretty major difference between your version and the 'official' version.

Re: Clock App

Posted: Mon Jun 13, 2016 8:38 am
by jameshale
Hi Saleh,

Well I spent some time over the weekend doing the clock app lessons.
I only used the slides (except once) as I didn't want to watch the videos.
There are a few problems with the material (using / as a line continuation character instead of \).
One handler beginning with "put" instead of "local" and one completely omitted function.
And a big one if your OS is set to use a 12 hour clock and not 24 hour one.
However, the stack built does indeed work, at least in terms of showing the set alarms in a data grid.

So what is wrong with your stack?

I am assuming you were able to get past the errors in the instructions as when trying to either compile a script or run it would indicate the errors mentioned.
So, that is not the issue.
But, it could simply turn out to be a simple typo.
When I first completed the app I too had nothing showing in my list of alarms regardless of how many alarms I added.
What was going wrong??
OK, starting at the "saveAlarm" handler I traced through saving the alarm, returning to the "Alarm" card and populating the data grid.
In doing so I discovered a couple of typos in my variable names.

Of course these will not be picked up by the compiler because, even though it really does a pretty good job at finding errors it can't know that when I type

add 1 to tLocal
and then
put tLocak into Fred

that I mistyped tLocal.

Yet this is what I did and because of this Fred does not have the value i expect.

In my case I had doubled up a couple of letters trying to type camel case for all the variables.

My point is that after I had found and cleared up these typos the stack worked as expected.

So I am really thinking you need to trace through your scripts and find the error.


Re: Clock App

Posted: Fri Nov 25, 2016 1:02 pm
by salah99
Dear James,

so sorry for my very late reply as I was busy with other mobile technologies.

Back to the clock app, I tried it again with version 8.1.1 and the datagrid is still empty. I really don't know what is wrong with it as there are no errors or typos with the code.

I have attached my file for you to look at.

So far, when I go to the alarm card and click on add and then clock on save, the app should save the new alarm to a file as well to the memory.

When I return to the alarm card again I should see the list of ala
(14.12 KiB) Downloaded 205 times
rms that were saved to the memory at least.

Right now even through I could see that the code check for the in memory array is not empty (I couldn't though display the array contents in the debugger I don't know why),
the datagrid is still empty. Please help me as I saw another post complaining about the same issue!!!


Re: Clock App

Posted: Sat Nov 26, 2016 5:22 am
by jameshale
I downloaded your app and sure enough there was an issue with showing the alarms.
The first clue is the list of errors that come up in the message box when you go to the "alarm" card.
errors on going to alarm card
These tell you something is amiss in the template.

When I looked at the "alarm" card in the project browser it all looked ok.

I then had a look at your datagrid template and here it was not ok.
Open the Project Browser, reveal the "Clock" components and then reveal the "Data Grid Templates ....." substack
Reveal the second card in the template substack
There you should see a group "Row Template" which when opened will show all your controls.
What you will see however is all your controls OUTSIDE the group "Row Template"
controls not in group
I suspect that when you edited the row template you didn't click on the existing controls and then select "edit group".

I simply deleted your data grid and redid it.

Works fine (for this stage of the app).

Re: Clock App

Posted: Sat Nov 26, 2016 5:24 am
by jameshale
Here is how the template should appear in the Project Browser...
controls in group

Re: Clock App

Posted: Sun Nov 27, 2016 7:54 pm
by salah99
Dear James,

Thank you very much for your help.

Alhamdulillah all is ok now.

As you stated rightly, my data grid was not set up correctly as I wasn't fully aware that while my data grid group is in edit mode and if I save my work before stopping editing the group I should click on edit group again as the edit mode will go off when saving!!

Also, there was some error in the way of coding the app in some cases as of deleting the entry in the array should have been based on the attribute "id" and not based on the index.

I had to perform a linear search on the array to find out the right index based on the passed "id" attribute.

I wonder if livecode has any other data structure that the developer can perform a faster search based on any attribute!!

The line separator of the graphic bottom line was also not appearing in my case even though I used the same coordinated as instructed but I had to lift it up higher in the template in order for it to appear.

Also, there was a need to explicitly clear the dgData of the data grid in case the array is empty.

Now all is ok and app is working fine.

Thanks again for all of your help dear.


Re: Clock App

Posted: Fri Dec 16, 2016 4:03 pm
by salah99
Guys I am posting here my working clock app for reference

Re: Clock App

Posted: Tue Jul 04, 2017 2:41 pm
Thanks for details, guys. I was looking for smart but at the same time not difficult app building course. Want to try this one.