Array

Want to move your code and projects to LiveCode but don't know where to start?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller

BlaBlaBliBli
Posts: 37
Joined: Sat Oct 06, 2012 12:22 pm

Re: Array

Post by BlaBlaBliBli » Thu Nov 15, 2012 9:54 pm

So you mean in the first button the code is :

put word 1 to -1 of fld "myCdName" & tab & word 1 to -1 of fld "Date" & cr before fld "List" card "Closet birthday card"
put the short name of this cd into fld "myCdName"

and on the card the code is :

on openCard
put the long date into field "The Long Date"
set the dateFlag of this stack to true
set the timerFlag of this stack to true
startDate
startTimer
pass openCard
end openCard

on startDate
put the long date into field "The Long Date" card "Category"
if the dateFlag of this stack then send startDate to me in 1second
end startDate

on startTimer
put the time into field "The Long Time" card "Category"
if the timerFlag of this stack then send startTimer to me in 1 second
end startTimer

on updateTime
put 60 - item 3 of (word 1 of the long time) into mySeconds
put the time into fld "Time"
send "updateTime" to me in mySeconds seconds
end updateTime

I didn't really understood the prob what bad in it :@ ?

And i dont understand why you want me to put the short date ? then what will be ?
and what is the idea with the secs ? what you mean im updating each sec.. I just tried this code and it works good without im touching everything =)

Thanks alot!

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5136
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Array

Post by Mark » Sun Nov 18, 2012 5:25 pm

Hi,

The code in the first button should probably be:

Code: Select all

on mouseUp
  put the short name of this cd into fld "myCdName"
  put word 1 to -1 of fld "myCdName" & tab & word 1 to -1 of fld "Date" & cr before fld "List" card "Closet birthday card"
end mouseUp
because this updates the field before it is used in the next command.

In the code that we are using to generate the list of reminders, we are using the short date. I think that you want to integrate the two sets of scripts which you now have. Therefore, both sets should use the same date format and the short date is the easiest and most reliable option for now. You can change this once it works, but for now I recommend using the short date.

You send the startDate and startTime messages every second. The scripts need only a few milliseconds to execute and then you send the command again in 1 second etc. Those handlers execute every second. Every time when these handlers run, they update the value in a field, even if the value if the same.

Updating the date and time every second is not good because you keep the computer busy. You're making a call to the internal clock, LiveCode has to convert the value it receives from the clock, then LiveCode needs to update the value in the field, even if the value is the same as the previous value, after which the window with the field needs to be redrawn. You save your computer a lot of work and you'll have more processing time for other tasks if you do this only once a minute, as does my updateTime script.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

BlaBlaBliBli
Posts: 37
Joined: Sat Oct 06, 2012 12:22 pm

Re: Array

Post by BlaBlaBliBli » Wed Nov 21, 2012 7:44 pm

Ok, I understood you'r explantions and I changed my code .

But what I have to change except for the short the and for the code you gave me ?

And another question, I want that the user will have the oppertunity to give the card the name he wants because I can't make cards with names im choosing for users, so how can I do it ?

Very thank you!!!

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5136
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Array

Post by Mark » Wed Nov 21, 2012 9:05 pm

Hi,

Sorry, I don't understand your first question. Can you explain what you're asking?

You can set and get the name property of a card. It is probably a good idea to search for "name" in the LiveCode dictionary and read everything you can find about it.

You can set the name property of any control, card or stack to a string or container, such as

set the name of this card to "Hello World"
set the name of this cd to field "Card Name"

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

BlaBlaBliBli
Posts: 37
Joined: Sat Oct 06, 2012 12:22 pm

Re: Array

Post by BlaBlaBliBli » Thu Nov 22, 2012 2:09 pm

Hello!

My first question is what do I have to change, in the thing i showed you, except from making "the long date" to "short date" and you gave me another code for the first button I changed as well. so you explained me about the secs also, do I have to change there anything ? to change any "Secounds" to "millisecounds or stuff like that?"

I searched for "Name" in the dictionary and there is nothing I found that I need... I dont want to give the card names, I want that the User will give it names and when he presses things buttons of that putting the name into the scrolling field it will right the name that he choosed for the card.. e.g. if he decided to give the card the name "Punch" and the date is 12/21 it will right in the scrolling field "Punch 12/21 29 Days left"

Thanks alot, Like always =)

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5136
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Array

Post by Mark » Thu Nov 22, 2012 11:35 pm

Hi,

If you're using my handler that sends a message exactly every minute and if those handlers work correctly, then you don't need to change them anymore. No need to replace seconds with milliseconds.

In the dictionary, you can read that you can set, put and get the name of any object, card and stack. For example "the name of this cd". You can use this instead of field "Description". Just give it a try.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Bernard
Posts: 184
Joined: Sat Apr 08, 2006 10:14 pm
Location: London, England

Re: Array

Post by Bernard » Fri Nov 23, 2012 12:03 am

Mark, you are performing sterling work here. However, it might help our new colleague to find things in the documentation if one provides links to specific items in the dictionary, using the online version. One can point him to the page on "the name" property of objects thus:

http://docs.runrev.com/Property/name

I don't know if that will help, but I can see there is some confusion going on.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5136
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Array

Post by Mark » Fri Nov 23, 2012 12:12 am

Hi,

What exactly is the confusion you observe?

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply

Return to “Converting to LiveCode”