Clock App

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

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

Clock App

Post by salah99 » Sat Jun 04, 2016 10:41 am

Dear All,

I recently purchased this course and its a lot of fun!!

I have two major issues with the clock app as follows:

1. When I click anywhere on any free space on any card, the app navigates away from the current card. I am not sure why!!

2. The list of alarms are saved successfully to the file but they are not loaded to the list of alarms on the alarm card. Very wierd!!! :roll:

If anyone could please help me out as this is my first post in the forum and I hope to get some good initial impression.

Here is my code for the show list command.

I have debugged it and tFormattedArray contains the desired contents as follows:

tFormattedArray
1
edit = false
id = 1
label = morning alarm
on = false
sound = Beep
time = 11:31

But when the curser reaches the the following statement, the debugger exits with no error but no list is displayed:

set the dgData of group "alarmList" to tFormattedArray

I have set up my data grid behavior as follows:

##############################################################

on FillInData pDataArray

set the text of field "time" of me to pDataArray["time"]
set the text of field "alarmLabel" of me to pDataArray["label"]
set the text of field "id" of me to pDataArray["id"]

if pDataArray["on"] is true then
set the hilite of button "alarmOn" of me to true
else
set the hilite of button "alarmOn" of me to false
end if

if pDataArray["edit"] is true then
hide button "alarmOn" of me
show button "edit" of me
else
show button "alarmOn" of me
hide button "edit" of me
end if

end FillInData


################################################################

on LayoutControl pControlRect

local theFieldRect

if the hilite of button "alarmOn" of me is true then
set the backGroundColor of graphic "alarmBackground" of me to 255,255,255
else
set the backGroundColor of graphic "alarmBackground" of me to 239,239,244
end if

set the rect of graphic "alarmBackground" of me to pControlRect

end LayoutControl

######################################################################


Please I need your help guys!!!


Regards,
Salah.

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

Re: Clock App

Post by dave.kilroy » Sat Jun 04, 2016 3:18 pm

Hi Salah and welcome to the forum! I'm afraid I haven't done that lesson and can't comment on it sensibly - however I note that in your array 'on' is set to "false", what happens if it is set to "true"?
salah99 wrote:tFormattedArray
1
edit = false
id = 1
label = morning alarm
on = false
sound = Beep
time = 11:31
Kind regards

Dave
"...this is not the code you are looking for..."

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

Re: Clock App

Post by salah99 » Sat Jun 04, 2016 3:47 pm

Hi Dave and thank you very much for your prompt response really appreciate it.

The on being equal to true only sets the hilite property of a button on the grid template to true as shown on the below code of the FillInData event of the data grid.

This does not affect the population of the list on the data grid!!

Regards,
Salah.

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

Re: Clock App

Post by dave.kilroy » Sat Jun 04, 2016 4:00 pm

Sorry Saleh I don't know what you mean - can you post a link to the lesson?

EDIT: actually don't try as I think the system won't let you post links until you have done about 10 postings...
"...this is not the code you are looking for..."

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

Re: Clock App

Post by dave.kilroy » Sat Jun 04, 2016 4:08 pm

OK I've found the lesson - does your issue take place in the 'cardAlarm' card? If so which of the datagrids are you referring to? Can you give more detail?
"...this is not the code you are looking for..."

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

Re: Clock App

Post by salah99 » Sat Jun 04, 2016 7:18 pm

Dear Dave,

thanks again for trying to help me out with this dilemma.

There is only one data grid with Clock application which resides on the card called "alarm".

This card contains a data grid called "alarmList" which is treated of course as a group.

Now this "alarmList" group contains a behavior script to fill in the data grid sub stack with the data from the data array called sAlarmArray.

In the fill in data event that I have shown earlier, we do the needed mapping of each row from the array to the template.

In the add button of the alarm card, we navigate to the "editAlarm" card and we save the alarm details to an array which gets saved to a file and then we return to the "alarm" card.

In the preOpenCard event of the "alarm" card, we load the list of alarms from the previously saved file.

Now the file is saved correctly and it is also loaded correctly to the memory when we open the "alarm" card.

The problem is when we call the following statement to populate the data grid with the array data in the command showList which is called from the preOpenCard of the "alarm" card to load alarms list from the file:

set the dgData of group "alarmList" to tFormattedArray

When I debugged this line I could see the array is populated correctly but the when I try to go to the next statement after the above statement, the debugger exits with no error and the data grid becomes empty!!

I downloaded the final code from the course material and I did a line by line comparison to find out where I went wrong with the code or with setting up the data grid property but I couldn't see any difference as the setting was very simple.

I could email you my live code file if you want a deeper look if you dont mind to see what's stopping the data grid from getting populated.

This is really my very first steps and I dont want this to be a real pain!!

Your help is most appreciated dear.

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 Jun 04, 2016 11:55 pm

In the message box type: put TRUE into grevdevelopment
Then try stepping through your script.
Now instead of the script simply stopping at the offending line with no message, you should indeed see a message.
I am assuming from what you have reported that the message will indicate an error in the revdatagridlibrary behaviour.
There isn't, by the way, but I think that is what will be reported.

What version of LC are you using?

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

Re: Clock App

Post by dave.kilroy » Mon Jun 06, 2016 10:05 am

Hi Salah - I guess you're building your app from scratch as you follow the course instructions? And this is why the control names you mention are different from the completed lesson stack which I downloaded? 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.

So my advice would be to listen to what @jameshale suggests and 'walk through' your app's processes - if necessary spend quite a bit of time doing this until you know EXACTLY what is going on. If that doesn't help then download the completed stack and spend time examining it, 'walking through' it and comparing it to your own.

One last thing, coding is hard - if you're finding it tough that's perfectly normal. I'm sure you'll lick the problem and when you do you'll feel great:)

Kind regards

Dave

PS: also, if you try and try and are still stuck come back to us here with more questions and more details...

PPS: another thing to try is to start a new stack trying to get just the bit of the lesson that isn't working for you in a little 'test harness' stack - if you get it working there then there MUST be something in your original stack that is the problem
"...this is not the code you are looking for..."

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

Re: Clock App

Post by salah99 » Tue Jun 07, 2016 5:36 pm

Dear Dave, Jameshale,

Thanks again guys. Your input as highly appreciated.

I am so sorry for the late reply.

I am really stuck with this data grid issue and I am not able to display any data or get any error.

When I try to execute the statement "put TRUE into grevdevelopment" in the message box or in the code I dont get any error messages.

I even created a separate stack with one card that has a similar data grid and read the binary file into my array successfully but I dont get anything on my data grid and it is empty but no errors.

It is a really simple code and I could share with you the new stack that I created and the binary file that you should place on the documents folder.

Kindly let me know if I could send you the stack along with the file you will easily see what I am talking about.

Please help me guys with this issue I need to move on with my course!!

Thanks a lot in advance.

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 » Tue Jun 07, 2016 6:23 pm

Hi Salah,

What version of Livecode are you using?

James

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

Re: Clock App

Post by salah99 » Wed Jun 08, 2016 8:00 am

Dear Jameshale,

I am using version 8.

Will that have any effect?

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 » Wed Jun 08, 2016 8:57 am

Indeed it could.
Which version 8?

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

Re: Clock App

Post by salah99 » Thu Jun 09, 2016 6:31 pm

Dear Jameshale,

it says livecode 8 build 13018.
Does that help?

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 » Fri Jun 10, 2016 1:46 am

Not really.
I was expecting something like 8.0dp15 or 8.01rc1 or 8.10dp1 or the like.
A while back I too had issues with some of my DG's.
They had been working perfectly and then all of a sudden they stopped.
The one in question had text and images in each row and was a 'form' type DG.
It would work when I made it and while I used it during the session but on a restart I would simply get a blanke area.
Sometimes showing a paler rectangle where the row should be.
It didn't matter how many times I recreated the thing I would get the same result.
When I tried to debug my code it would get to the despatch the data to the DG line and the script debug session would simply end, as if we reached the end of the handler.
When I put TRUE in the global environment variable I mentioned in my previous post instead of ending the debugging session I was thrown into the revdatagridlibrary script where it turned out it could not find an object.
Now the revdatagridlibrary has not been modified for years so the problem wasn't actually in it as such but something weird was happening to my template that was choking it.
My initial fix was to comment out the offending line in the revdatagridlibrary script - drastic but it worked, until LC could fix whatever was happening.
There was another symptom for me. The name of all my DG templates became nonsensical.
During this time there was an issue with the toolbar icons in LC for the group editing buttons not reflecting the correct state. It took until 8.01 for this to be finally sorted out (I think).
I think this was the source of the issue.
When I was redoing the DG manual for inclusion into the dictionary I noticed a warning about ensuring you stopped editing the template group before saving the template etc. I don't think this was happening while the toolbar issue was still present.
In any case post version 8.01 of LC I have been able to create and reuse the problem DG without issue.
I did need to recreate once using version 8.01 of.LC.
I no longer have to use a modified revdatagridlibrary.

So, can you please ensure you are using at least version 8.01,delete the existing data grid and recreate it and see if you still have the problem.

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

Re: Clock App

Post by salah99 » Fri Jun 10, 2016 11:45 am

Dear Jameshale,

Thanks a lot for your help.

I uninstalled version 8.0.0 and installed version 8.0.1.

I created a new stack and set up my template and my behavior script.

I loaded the array with the contents from the file that was saved previously using version 8.0.0 (Do I need to recreate the file as well with this new version??!!).

Again, I could see the contents are nicely laid out in the array and also in the form grid inspector (under the contents tab).

Unfortunately, I am still getting an empty grid and no data is displayed.

Could you please direct me or I could share my livecode file with you.

Regards,
Salah.

Post Reply

Return to “App Building Course”