Clock App

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 198
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: Clock App

Post by jameshale » Fri Jun 10, 2016 2:57 pm

I can have a look from Monday so if you can zip the stack and post it here I will,take a look.

James

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 835
Joined: Wed Jun 24, 2009 1:17 pm
Location: Plymouth, UK
Contact:

Re: Clock App

Post by dave.kilroy » Fri Jun 10, 2016 3:05 pm

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.
"...this is not the code you are looking for..."

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 198
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: Clock App

Post by jameshale » Mon Jun 13, 2016 8:38 am

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.

James

salah99
Posts: 19
Joined: Sat Jun 04, 2016 10:24 am

Re: Clock App

Post by salah99 » Fri Nov 25, 2016 1:02 pm

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
Clock.zip
(14.12 KiB) Downloaded 66 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!!!

Regards,
Salah.

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 198
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: Clock App

Post by jameshale » Sat Nov 26, 2016 5:22 am

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.
Message_Box__Single_Line_.png
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"
Project_Browser_1.png
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).
Attachments
Clock.livecode.zip
redone clock
(14.89 KiB) Downloaded 67 times

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 198
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: Clock App

Post by jameshale » Sat Nov 26, 2016 5:24 am

Here is how the template should appear in the Project Browser...
Project_Browser_and_Clock__1___.png
controls in group

salah99
Posts: 19
Joined: Sat Jun 04, 2016 10:24 am

Re: Clock App

Post by salah99 » Sun Nov 27, 2016 7:54 pm

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.

Regards,
Salah.

salah99
Posts: 19
Joined: Sat Jun 04, 2016 10:24 am

Re: Clock App

Post by salah99 » Fri Dec 16, 2016 4:03 pm

Guys I am posting here my working clock app for reference
Attachments
Clock (2).zip
clock
(16.07 KiB) Downloaded 70 times

ty.bailey@o2.pl
Posts: 1
Joined: Tue Jul 04, 2017 2:19 pm
Location: USA, Los Angeles
Contact:

Re: Clock App

Post by ty.bailey@o2.pl » 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.

Post Reply

Return to “App Building Course”