on textChanged by computer change
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
on textChanged by computer change
Hello every body
I have a question about "on textChanged" handler
let say i have
-field1= field timer coundown
-button1= button for start and stop timer
-button2= button for play sound effect1
-button3= button for play sound effect2
I create code on field1 like this
on textChanged
if the field1 is "05:00" then
send "mouseUp" to button "button2"
end if
end textChanged
When countdonwn is running then the value change 05:00 nothing change anything.
What i expect is when timer value 05:00 the sound effect1 is playing
but if I type it manually 05:00 on field1 then the sound effect is playing
anyone cant give me guidance to a right direction
Commend and help will be appreciate
Thank You
I have a question about "on textChanged" handler
let say i have
-field1= field timer coundown
-button1= button for start and stop timer
-button2= button for play sound effect1
-button3= button for play sound effect2
I create code on field1 like this
on textChanged
if the field1 is "05:00" then
send "mouseUp" to button "button2"
end if
end textChanged
When countdonwn is running then the value change 05:00 nothing change anything.
What i expect is when timer value 05:00 the sound effect1 is playing
but if I type it manually 05:00 on field1 then the sound effect is playing
anyone cant give me guidance to a right direction
Commend and help will be appreciate
Thank You
Gilar | from INDONESIA
Re: on textChanged by computer change
Hi gilar,
1. very bad syntax and I wonder why (if) this has compiled:
...
if the field1 is "05:00" then
...
a. Do not use THE when accessing objects in Livecode - if field "field1"...
b. Use the object descriptor -> field "field1"
c. get used to put quotes around strings, and object names are strings -> field "field1"
d. VERY good advice: use meaningful names for your objects, "field1" or "button2" are NOT!
2. Obviously the "textchanged" message is NOT triggered when the text is changed via script, which is the case here,
only when the user types something.
So you should modify the "countdown" script, which writes the time into your field "field1", to do what you want.
Please post the script if you need some help here.
Best
Klaus
1. very bad syntax and I wonder why (if) this has compiled:
...
if the field1 is "05:00" then
...
a. Do not use THE when accessing objects in Livecode - if field "field1"...
b. Use the object descriptor -> field "field1"
c. get used to put quotes around strings, and object names are strings -> field "field1"
d. VERY good advice: use meaningful names for your objects, "field1" or "button2" are NOT!

2. Obviously the "textchanged" message is NOT triggered when the text is changed via script, which is the case here,
only when the user types something.
So you should modify the "countdown" script, which writes the time into your field "field1", to do what you want.
Please post the script if you need some help here.
Best
Klaus
Re: on textChanged by computer change
Yes ... you are right Klaus, Thank YouKlaus wrote:Hi gilar,
1. very bad syntax and I wonder why (if) this has compiled:
...
if the field1 is "05:00" then
...
a. Do not use THE when accessing objects in Livecode - if field "field1"...
b. Use the object descriptor -> field "field1"
c. get used to put quotes around strings, and object names are strings -> field "field1"
d. VERY good advice: use meaningful names for your objects, "field1" or "button2" are NOT!![]()
Now I change the name of text field and button
- timer_fld = field for timer
- timer_btn = button for Start and Stop Timer
- Sound_btn = button for sound Effect
Now I use count up Timer, but the principe is same.Klaus wrote: 2. Obviously the "textchanged" message is NOT triggered when the text is changed via script, which is the case here,
only when the user types something.
So you should modify the "countdown" script, which writes the time into your field "field1", to do what you want.
Please post the script if you need some help here.
Best
Klaus
I want to trigger sound effect when timer value 05:00
This is my Count Up Script
Code: Select all
global holdTime
on mouseUp
if the backgroundcolor of me is 46, 56, 63 and the ticks - holdTime >30 then --NEW
set the backgroundcolor of me to 115, 153, 100
put the ticks into holdTime -- NEW
DoCountUp
else
set the backgroundcolor of me to 46, 56, 63
cancel item 1 of last line of the pendingMessages
end if
end mouseUp
on DoCountUp
if the backgroundcolor of me is 115, 153, 100 then
set the numberformat to 00
put format("%02d:%02d",pTime[4],pTime[5],pTime[6]) into tNewTime
add 1 to char 4 to 5 of word 1 of field timer_fld of card 001
if char 4 to 5 of word 1 of field timer_fld of card 001 = 60 then
add 1 to char 1 to 2 of word 1 of field timer_fld of card 001
put 00 into char 4 to 5 of word 1 of field timer_fld of card 001
//Script for CasparCG
put "CG 1-9 UPDATE 1 " into tm1xml
put quote after tm1xml
put "<templateData><componentData id=\" after tm1xml
put quote after tm1xml
put "timer1\" after tm1xml
put quote after tm1xml
put "><data id=\" after tm1xml
put quote after tm1xml
put "text\" after tm1xml
put quote after tm1xml
put " value=\" after tm1xml
put quote after tm1xml
put field timer_fld of card 001 after tm1xml
put "\" after tm1xml
put quote after tm1xml
put " /></componentData></templateData>" after tm1xml
put quote after tm1xml
put field ipport of card 001 after server
write tm1xml & format("\r\n") to socket server
else
//Script for CasparCG
put "CG 1-9 UPDATE 1 " into tm1xml
put quote after tm1xml
put "<templateData><componentData id=\" after tm1xml
put quote after tm1xml
put "timer1\" after tm1xml
put quote after tm1xml
put "><data id=\" after tm1xml
put quote after tm1xml
put "text\" after tm1xml
put quote after tm1xml
put " value=\" after tm1xml
put quote after tm1xml
put field timer_fld of card 001 after tm1xml
put "\" after tm1xml
put quote after tm1xml
put " /></componentData></templateData>" after tm1xml
put quote after tm1xml
put field ipport of card 001 after server
write tm1xml & format("\r\n") to socket server
end if
send "DoCountUp tNewTime" to me in 1 second
end if
end DoCountUp
Any Comment and Help wouldbe appreciate
Best
Gilar Kadarsah | from INDONESIA
Gilar | from INDONESIA
Re: on textChanged by computer change
Selamat siang Gilar,
where is pTime[4] etc. coming from resp. what is in the array?
Looks to me that you can simply:
put tNewTime into fld "timer_fld"
?
But maybe not
...
put format("%02d:%02d",pTime[4],pTime[5],pTime[6]) into tNewTime
## add 1 to char 4 to 5 of word 1 of field timer_fld of card 001
## QUOTES!
add 1 to char 4 to 5 of word 1 of field "timer_fld" of card 001
...
And no need to format the card number:
... of cd 1
Is enough.
But maybe you can check right here:
Best
Klaus | from germany
where is pTime[4] etc. coming from resp. what is in the array?
Looks to me that you can simply:
put tNewTime into fld "timer_fld"
?
But maybe not

...
put format("%02d:%02d",pTime[4],pTime[5],pTime[6]) into tNewTime
## add 1 to char 4 to 5 of word 1 of field timer_fld of card 001
## QUOTES!

add 1 to char 4 to 5 of word 1 of field "timer_fld" of card 001
...
And no need to format the card number:
... of cd 1
Is enough.
But maybe you can check right here:
Code: Select all
...
put format("%02d:%02d",pTime[4],pTime[5],pTime[6]) into tNewTime
if tNewTime = "05:00" then
## do your sound thing here...
end if
...
Klaus | from germany
Re: on textChanged by computer change
Selamat Malam Kaluse, Terimakasih BanyakKlaus wrote:Selamat siang Gilar,
where is pTime[4] etc. coming from resp. what is in the array?
Looks to me that you can simply:
put tNewTime into fld "timer_fld"
?
But maybe not![]()
...
put format("%02d:%02d",pTime[4],pTime[5],pTime[6]) into tNewTime
## add 1 to char 4 to 5 of word 1 of field timer_fld of card 001
## QUOTES!![]()
add 1 to char 4 to 5 of word 1 of field "timer_fld" of card 001
...
Sekarang di Indonesia sudah malam Hari ....

Actually I'm new in programming, and new in Livecode so I'm completly beginer.
I Really don't understand how the timer code work All.
I Just copas and edit that code frome GithHub.
But I'm learning. I use Livecode to create Application wich connect to CasparCG
I put the code as you said in timer script. just like this:
Code: Select all
global holdTime
on mouseUp
if the backgroundcolor of me is 46, 56, 63 and the ticks - holdTime >30 then --NEW
set the backgroundcolor of me to 115, 153, 100
put the ticks into holdTime -- NEW
DoCountUp
else
set the backgroundcolor of me to 46, 56, 63
cancel item 1 of last line of the pendingMessages
end if
end mouseUp
on DoCountUp
if the backgroundcolor of me is 115, 153, 100 then
set the numberformat to 00
put format("%02d:%02d",pTime[4],pTime[5],pTime[6]) into tNewTime
add 1 to char 4 to 5 of word 1 of field timer_fld of card 001
if char 4 to 5 of word 1 of field timer_fld of card 001 = 60 then
add 1 to char 1 to 2 of word 1 of field timer_fld of card 001
put 00 into char 4 to 5 of word 1 of field timer_fld of card 001
//Script for CasparCG
put "CG 1-9 UPDATE 1 " into tm1xml
put quote after tm1xml
put "<templateData><componentData id=\" after tm1xml
put quote after tm1xml
put "timer1\" after tm1xml
put quote after tm1xml
put "><data id=\" after tm1xml
put quote after tm1xml
put "text\" after tm1xml
put quote after tm1xml
put " value=\" after tm1xml
put quote after tm1xml
put field timer_fld of card 001 after tm1xml
put "\" after tm1xml
put quote after tm1xml
put " /></componentData></templateData>" after tm1xml
put quote after tm1xml
put field ipport of card 001 after server
write tm1xml & format("\r\n") to socket server
else
//Script for CasparCG
put "CG 1-9 UPDATE 1 " into tm1xml
put quote after tm1xml
put "<templateData><componentData id=\" after tm1xml
put quote after tm1xml
put "timer1\" after tm1xml
put quote after tm1xml
put "><data id=\" after tm1xml
put quote after tm1xml
put "text\" after tm1xml
put quote after tm1xml
put " value=\" after tm1xml
put quote after tm1xml
put field timer_fld of card 001 after tm1xml
put "\" after tm1xml
put quote after tm1xml
put " /></componentData></templateData>" after tm1xml
put quote after tm1xml
put field ipport of card 001 after server
write tm1xml & format("\r\n") to socket server
end if
send "DoCountUp tNewTime" to me in 1 second
end if
================================================ NEW CODE
if the field timer_fld is "05:00" then
send "mouseUp" to button "Sound_btn"
end if
================================================ NEW CODE
end DoCountUp
AND WORK LIKE CHARM .... thank you Klause ....
TERIMAKASIH BANYAK
Now i'm find out "pTime[4] etc." what is it mean?
Gilar | from INDONESIA
Re: on textChanged by computer change
Hi gilar,
so no idea what you are writing here
I can recommend some great learning resources to get the basics of Livecode, check this page:
http://www.hyperactivesw.com/revscriptc ... ences.html
The ARRAY pTime is not declared in your script, neither LOCAL nor GLOBAL!
So I still wonder why the script works!
Best
Klaus
I actually cheated and looked up "Good day" in malayan via Google,gilar wrote:Selamat Malam Kaluse, Terimakasih Banyak
Sekarang di Indonesia sudah malam Hari ....
so no idea what you are writing here

The code is quite complicated to be honest and I have also problems to understand it.gilar wrote:Actually I'm new in programming, and new in Livecode so I'm completly beginer.
I Really don't understand how the timer code work All.
I Just copas and edit that code frome GithHub.
But I'm learning. I use Livecode to create Application wich connect to CasparCG
I can recommend some great learning resources to get the basics of Livecode, check this page:
http://www.hyperactivesw.com/revscriptc ... ences.html
Well, we already talked about this, right?gilar wrote:...
if the field timer_fld ...
...

It is Klaus without an E!gilar wrote:... thank you Klause ....
I have asked you first!gilar wrote:Now i'm find out "pTime[4] etc." what is it mean?

The ARRAY pTime is not declared in your script, neither LOCAL nor GLOBAL!
So I still wonder why the script works!

Best
Klaus
Re: on textChanged by computer change
If the array is undeclared then the values will be empty. The format function will still return the short time values so the rest of the handler still works. I suspect the array may have held the values for the internet date or maybe the long time,where there would be more keys.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com