How to implement synchronous in Live code
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
How to implement synchronous in Live code
Dear all,
I do all researching on the internet about how to implement synchronous communication among cards. Let me explain it more specific for you guys understand what I am doing.
I have the application which is written by java console.There is one module in my application invoke this Java console.Everything is work really well if I only use it individual.However, I am not able to work with other modules at the same time. I meant that if you want to execute Java console while you are doing other modules such as retrieve data from mySQL, you have to wait until Java console is finished.
Is there any way to work simultaneously among these modules. Could you please give me some advise for this issue ?
Thanks a lot for your help
Regards,
Quang
I do all researching on the internet about how to implement synchronous communication among cards. Let me explain it more specific for you guys understand what I am doing.
I have the application which is written by java console.There is one module in my application invoke this Java console.Everything is work really well if I only use it individual.However, I am not able to work with other modules at the same time. I meant that if you want to execute Java console while you are doing other modules such as retrieve data from mySQL, you have to wait until Java console is finished.
Is there any way to work simultaneously among these modules. Could you please give me some advise for this issue ?
Thanks a lot for your help
Regards,
Quang
Re: How to implement synchronous in Live code
Quang,
How exactly do you start the Java process? You might want to try "open process".
Mark
How exactly do you start the Java process? You might want to try "open process".
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: How to implement synchronous in Live code
Thanks Mark,
Here the way I start Java console
Regards,
Quang
Here the way I start Java console
Code: Select all
put "java -jar Demo.jar" into tCommand
get shell(tCommand)
Regards,
Quang
Re: How to implement synchronous in Live code
Hi Quang,
Yes, you need to try open process if you want to read from/write to the process or you could even use the launch command if you don't need to communicated with the process.
Kind regards,
Mark
Yes, you need to try open process if you want to read from/write to the process or you could even use the launch command if you don't need to communicated with the process.
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: How to implement synchronous in Live code
Hi Mark,
I try to use "open process" but it seem to be not working. I am not able to use other functions at the same time. Must wait until the console is finished.
Regards,
Quang
I try to use "open process" but it seem to be not working. I am not able to use other functions at the same time. Must wait until the console is finished.
Regards,
Quang
Re: How to implement synchronous in Live code
Quang,
Can you post (the relevant part) of your script?
Mark
Can you post (the relevant part) of your script?
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: How to implement synchronous in Live code
Hi Mark,
just let you know clearly what i am doing:
1.Java console: will loop 10 times and within 10 times if user give their card ,the result will be the number.
2.Live code: Open main menu with many user tasks and "ReadCard"card is the one of these. For example, I will open "User"cards retrieving user information and also open "ReadCard" card.As we discuss before, I can't use "User" card until Java console is finished.
Here is my code, That work well except one thing is to work simultaneously.
Regards,
Quang
just let you know clearly what i am doing:
1.Java console: will loop 10 times and within 10 times if user give their card ,the result will be the number.
2.Live code: Open main menu with many user tasks and "ReadCard"card is the one of these. For example, I will open "User"cards retrieving user information and also open "ReadCard" card.As we discuss before, I can't use "User" card until Java console is finished.
Here is my code, That work well except one thing is to work simultaneously.
Code: Select all
open process "java -jar Demo.jar" for read
repeat forever
put empty into it
set the defaultfolder to "C:\"
read from process "java -jar Demo.jar" for -1 line
if it is a number then ---return ID card
put it into cd fld "FIDCard"
close process "java -jar Demo.jar"
exit repeat
end if
if it contains "Time out" then --After 10 seconds
answer info "Time out"
exit repeat
end if
end repeat
Quang
Re: How to implement synchronous in Live code
Hi Quang,
The problem is that your repeat loop blocks the interface. It has nothing to do with the jar or with using cards or anything else. Any repeat loop, e.g.
will lock up LiveCode completely for 3 seconds.
You need to read from process with message:
You'll also need a line to kill the process, e.g.
Actually, the close process command didn't work in previous versions of LC. If this doesn't work, you might be able to use the kill command (which didn't work in previous version of LC either) or use a shell command to kill the process.
This video tells a little more about using processes.
Kind regards,
Mark
The problem is that your repeat loop blocks the interface. It has nothing to do with the jar or with using cards or anything else. Any repeat loop, e.g.
Code: Select all
put 0 into x
repeat
add 1 to x
wait 1 tick
if x > 180 then exit repeat
end repeat
You need to read from process with message:
Code: Select all
...
-- somewhere in a handler
read from process "java -jar Demo.jar" for -1 line with message "rcvData"
...
-- different handler
on rcvData theData
if it is a number then
...
end if
end rcvData
Code: Select all
...
send "killProcess" to me in 10 seconds
...
on killProcess
close process "java -jar Demo.jar"
end killProcess
This video tells a little more about using processes.
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: How to implement synchronous in Live code
Hi Mark,
I resolved the problem. I still use get shell(tCommand).However, turn off loop in Java console. Now it work fine.
Thank you very much for your help
Regards,
Quang
I resolved the problem. I still use get shell(tCommand).However, turn off loop in Java console. Now it work fine.
Thank you very much for your help
Regards,
Quang
-
- Posts: 3
- Joined: Fri Feb 22, 2013 11:44 am
Re: How to implement synchronous in Live code
whats it like on windows?