how to set the number of objects in stack

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
irfan qasim
Posts: 3
Joined: Sat Jul 24, 2010 1:23 pm

how to set the number of objects in stack

Post by irfan qasim » Sat Jul 24, 2010 2:38 pm

hi guys,,

i m working on one appliction in which i am using different trucks for hearvesting purpose,
i am trying to set the number of trucks so that when the specified number are created then it must stop and display one window box to inform .
my code is given below please help me how to set the number trucks rather then repeat to the number of controls of this card.

global gSimulating

on mouseUp
put "java JRSocket 54322 10000" into tProcess
open process tProcess for neither
put ("localhost:54322") into tSocket
open socket tSocket
--If there is not a control "txttruck" then
if there is not a control "txttruck" then
answer "Please create a txtfield first!"
exit mouseUp
end if
write "Plant need trucks to collect items from field" & return to socket tSocket
write "plant : I need trucks to harvest 100 tons" & return to socket tSocket
write "Target is harvest" & return to socket tSocket
write field "txttruck" & return to socket tSocket
read from socket tSocket until return
put it into pResult
if pResult="movetruck"
then

if gSimulating is not "true"
then
put "true" into gSimulating
set the icon of me to 1038
--set the controls of this card to n
put field "txttruck" into f
if f>2*n
then
answer "stop process"
else
put n+1 into n and repeat until f>=1*2^n

repeat with x = 1 to the number of controls of this card
if the Kind of control x is "Truck" then
put true into sThereIsAtruck
if the Status of control x is not empty then send moveStopped to control x
if the Status of control x is empty then
wait 0.5 second
set the Status of control x to "Unloading"
set the DestinationID of control x to the ID of control "Plant 1"
move control x to the location of control "Plant 1" without waiting
end if
end if
end repeat
if sThereIsAtruck is not true
then
answer "You must have at least one Mobile Object to run a Simulation!"
put "false" into gSimulating
set the icon of me to 1040
exit mouseUp
end if
else
put "false" into gSimulating
set the icon of me to 1040
repeat with x = 1 to the number of controls of this card
if the Kind of control x is "Truck" then
stop moving control x
end if
end repeat
end if
send "upDateFieldNodeInfo" to group "Tree1"
if tSocket is among the lines of the openSockets then close socket tSocket
end if

end mouseUp

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

Re: how to set the number of objects in stack

Post by Mark » Sun Jul 25, 2010 10:32 am

irfan qasim ,

It is not clear what you want. Do you want to write a script that creates controls and stops creating as soon as the number of required controls has been reached or do you want to prevent the user from creating a new control when the number of allowd controls as been reached?

You probably want to execute the following line some time, but without additional information I can't say more about it.

Code: Select all

if the number of controls is 234 then
  beep
  answer "Number of controls reached"
else
  -- make additional controls here
end if
Best 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

irfan qasim
Posts: 3
Joined: Sat Jul 24, 2010 1:23 pm

Re: how to set the number of objects in stack

Post by irfan qasim » Wed Jul 28, 2010 3:27 pm

irfan qasim wrote:hi guys,,

i m working on one appliction in which i am using different trucks for hearvesting purpose,
i am trying to set the number of trucks so that when the specified number are created then it must stop and display one window box to inform .
my code is given below please help me how to set the number trucks rather then repeat to the number of controls of this card.

global gSimulating

on mouseUp
put "java JRSocket 54322 10000" into tProcess
open process tProcess for neither
put ("localhost:54322") into tSocket
open socket tSocket
--If there is not a control "txttruck" then
if there is not a control "txttruck" then
answer "Please create a txtfield first!"
exit mouseUp
end if
write "Plant need trucks to collect items from field" & return to socket tSocket
write "plant : I need trucks to harvest 100 tons" & return to socket tSocket
write "Target is harvest" & return to socket tSocket
write field "txttruck" & return to socket tSocket
read from socket tSocket until return
put it into pResult
if pResult="movetruck"
then

if gSimulating is not "true"
then
put "true" into gSimulating
set the icon of me to 1038
--set the controls of this card to n
put field "txttruck" into f
if f>2*n
then
answer "stop process"
else
put n+1 into n and repeat until f>=1*2^n

repeat with x = 1 to the number of controls of this card
if the Kind of control x is "Truck" then
put true into sThereIsAtruck
if the Status of control x is not empty then send moveStopped to control x
if the Status of control x is empty then
wait 0.5 second
set the Status of control x to "Unloading"
set the DestinationID of control x to the ID of control "Plant 1"
move control x to the location of control "Plant 1" without waiting
end if
end if
end repeat
if sThereIsAtruck is not true
then
answer "You must have at least one Mobile Object to run a Simulation!"
put "false" into gSimulating
set the icon of me to 1040
exit mouseUp
end if
else
put "false" into gSimulating
set the icon of me to 1040
repeat with x = 1 to the number of controls of this card
if the Kind of control x is "Truck" then
stop moving control x
end if
end repeat
end if
send "upDateFieldNodeInfo" to group "Tree1"
if tSocket is among the lines of the openSockets then close socket tSocket
end if

end mouseUp
THANK U MARK FOR UPDATING

ACTUALLY I M GOING TO DEFINED A NUMBER AND WHEN CONTROLS REACH AT THAT POINT THEN IT STOP CREATING MORE.

AS MY PROJECT 'repeat with x = 1 to the number of controls of this card' HERE I AM TRYING TO FIX THE NO. OF CONTROLS SO THAT WHEN THE REQUIRD NUMBER IS REACHED TEHN IT STOP.

HOPE FULLY YOU WILL UPDATE ME .
REGARD
IRFAN QASIM

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

Re: how to set the number of objects in stack

Post by Mark » Wed Jul 28, 2010 3:30 pm

Dear irfan qasim ,

I'd be happy to help, but I don't know what you want.

Please, don't use all caps. It is considered rude.

Best,

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

irfan
Posts: 20
Joined: Thu Jul 29, 2010 12:49 am

Re: how to set the number of objects in stack

Post by irfan » Thu Jul 29, 2010 1:15 am

Mark wrote:Dear irfan qasim ,

I'd be happy to help, but I don't know what you want.

Please, don't use all caps. It is considered rude.

Best,

Mark
dear Mark,,
i am sending you all my project please run it and then tell me how to control the and sent the truck from plant to two fields.
actually i going to control and sent truck from plants to feild by own choice,. example ( if i have five total trucks and i sent two truck to field #01 and rest to other field) ,.....
Best Regard
irfan

irfan
Posts: 20
Joined: Thu Jul 29, 2010 12:49 am

Re: how to set the number of objects in stack

Post by irfan » Fri Jul 30, 2010 5:47 pm

Hi Mark,,

i am trying to sent you my project so that you could understand and assist me to solve my problem.
but my project size is more than the allowed file 256 kb.
i will be thakful to you if you sent me ur personal contact id so that i could sent project file to you.

Best Regard
Irfan Qasim

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

Re: how to set the number of objects in stack

Post by Mark » Sat Jul 31, 2010 10:26 am

Irfan,

I don't have your contact info either. You can send me a message through the economy-x-talk website here. Once you have contacted me, you'll get an e-mail from me and will be able to send me your files.

Best 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

irfan
Posts: 20
Joined: Thu Jul 29, 2010 12:49 am

how option menue is used to select object

Post by irfan » Sat Sep 18, 2010 11:24 am

hi guys

i am using option menue in my application and want to select different value from it . my code is given below but now working.

i want to select on object from it and write it to socket ,..

code

write Menu "option" & return to socket tSocket
read from socket tSocket until return
put it into p1
if p1="c1" // here we have c1,c2,c3 are option menue and i select on
then
answer "okay"
end if

Klaus
Posts: 14192
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: how option menue is used to select object

Post by Klaus » Sat Sep 18, 2010 1:46 pm

irfan wrote:... my code is given below but now working...
???
Do you mean it is working NOW? Then what is your question? Or do you mean "...but NOT working"? I guess the latter.

The syntax for getting the currently selected option menu is: the label of btn "optinon menu button"

So you would like to:
...
put the label of btn "the option menu button" into tSelectedOption
write tSelectedOption & return to socket tSocket
...

Best

Klaus

Klaus
Posts: 14192
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: how to set the number of objects in stack

Post by Klaus » Sat Sep 18, 2010 5:05 pm

Dear Irfan,

I am a moderator and deleted your post in the section "Announcement" since it was a duplicate of your last question here!
And you posted it AFTER I gave my answer here!

So please make sure you read all answers before posting your question again and make sure to post it in the correct section.
Thanks!


Best from germany

Klaus

P.S.
Looks like you lack some basic thing in Rev, so I highly recommend to work through these wonderful stacks here:
http://www.runrev.com/developers/lesson ... nferences/

Post Reply