How timer is used in Revolution studio

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

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

Re: How timer is used in Revolution studio

Post by Klaus » Sat Sep 25, 2010 9:17 pm

Oh come on, Irfan, you must be kidding!
Read my script a BIT more carefully again and the rethink your script!

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

Re: How timer is used in Revolution studio

Post by irfan » Sun Sep 26, 2010 5:17 pm

hi klaus

i am not kidding .. really i told you that i am also suprise why this timer is not working ...

with this code format timer is not working .

Reagard
Irfan

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

Re: How timer is used in Revolution studio

Post by Klaus » Sun Sep 26, 2010 7:12 pm

Hi irfan,

before I will come to your problem I must say that I am presonally upset for a couple of reasons!
1. You unnecessarily opened a new thread for this same problem.
2. You did not take any advice I gave you. I did this not for the fun of it!
So your script is still full of unnecessary code and very hard to read.
3. You obviously did not read my script at all, at least the script you posted here last implied that!
4. If you did, you may not have understood it, which is definitvely NO problem, but then you did not ask questions, which is a problem!
5. In the other thread you explained today your real problem the first time since you started this thread!

You want to interrupt the MOVING of you objects, but until then you always only told us to interrupt the script for which we already gave you a some answers.

You wrote this, which is not what I wrote in my script:

Code: Select all

...
put the seconds into tStarttime
if the seconds - tStarttime > 10 then
  ## At this time only a fraction of a millisecond may have passed after you inititalised tStartime
  ## so this will of course NEVER have any effect!
  answer "Time has passed"
  exit mouseup
end if
...
After looking at your script a bit more exactly I confess I did not get at frirst what "move xy... in 0 seconds..." really meant!
Although I still see no real sense in it...? But see below.

You can add an amount of time to the "move" command like "move xyz... in 2 seconds" so the object will really move in 2 seconds.
But when you do not supply this or only a value of 0, the move command will use the global property "movespeed" which is 200 pixels per second.
That's why I thought that the object would not really move but just change its location.

OK, here are some more thoughts about what may solve your problem.
But PLEASE read also my comments!

Code: Select all

...
put the seconds into tStarttime
move grc "Obj8531" to the loc of grc (item 1 of line 1 of field "ObjectsLoc") in 2 sec without waiting
## Enter a desired amount of time instead of my example "in 2 secs..."
## Checking here does not make sense yet, since only 2 seconds will have passed so far
## but this is how it should be done anayway:
if the seconds - tStarttime > 10 then
  STOP MOVING grc "Obj8531" 
  ##!!!! This is what you were looking for!
  exit mouseup
end if
wait 5 sec
move grc "Obj8533" to the loc of grc (item 1 of line 1 of field "ObjectsLoc") in 2 sec without waiting
## Here you can check agian, but this still does not make sense, since until now 2 + 5 = 7 seconds will have passed
if the seconds - tStarttime > 10 then
  STOP MOVING grc Obj8533" 
  ##!!!! This is what you were looking for!
  exit mouseup
end if
wait 10 sec
## Here any more checking will not make sense since more than the desired 10 seconds have already passed!

move grc "Obj8535" to the loc of grc (item 1 of line 1 of field "ObjectsLoc") in 2 sec without waiting
wait 15 sec
## See above, no sense in checking here and in the rest of the script.
...
end if
Best

Klaus

P.S.
I still strongly advice you to work through some or all stack here:
http://www.runrev.com/developers/lesson ... onferences

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

Re: How timer is used in Revolution studio

Post by irfan » Sun Sep 26, 2010 11:09 pm

hi klaus

first i am sorry if you suffer with my posts.... Actually the problem i am going to address is not understood able by you.
i was asking you that the code of timer given by you is not working at any stage . i place it out side the if statment also and try to execute. As it should be work when mouse up event is trigger and after 10 second it should display specified message.
if this work then its easy for me to place it at my desire locations.
may be second require some initilization...
put the seconds into tStarttime
if the seconds - tStarttime > 10 then
## At this time only a fraction of a millisecond may have passed after you inititalised tStartime
## so this will of course NEVER have any effect!
answer "Time has passed"
exit mouseup
end if

Regard
irfan

deebee
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 89
Joined: Mon Jul 19, 2010 6:59 am

Re: How timer is used in Revolution studio

Post by deebee » Mon Sep 27, 2010 3:31 am

It almost seems that the biggest barrier here may be the translator service. Most are somewhat unreliable when translating to English.

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

Re: How timer is used in Revolution studio

Post by Klaus » Mon Sep 27, 2010 11:26 am

Hi irfan,

I do not suffer from your posts but the behavior that they express.
It also looks like that you do not understand what we are trying to explain you
and if that is the case why do you not ask more specific questions?

I still have absolutely no idea what you want to achieve.
I am guessing and guessing but this is too time consuming.
As you might have noticed we really WANT to help you but obviously can't!

Could you please try to write your problem down in "pseudo-code"?
Know what that means? It is a mix of LiveCode and plain english.
Maybe then we finally get it :)


Best

Klaus

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

Re: How timer is used in Revolution studio

Post by irfan » Mon Sep 27, 2010 10:48 pm

hi Klaus,,

i am trying to explain my problem in detail below.

what is problem.
i have develop an Harvesting logistic application in Revolution studio.The application has following main objectives.

1. Truck move from plant to field ,load raw material from field and unload it on the plant.
2.The number of trucks and time requite to finish the harvesting depend on amount of raw material to harvest.
3. i am using road to move from field to plant and then back field.
4. i have number of if statement containg different number of trucks depending on the amount of harvesting material to harvest. like if the harvesting material is 40 tons then the control will enter into that if statement having truck require for 40 tons etc....
Different number of Trucks are moving from plant to field depending upon the amount of Harvesting material.

My Question is following.
Now i want to use a timer that work in each if statement and after the specific time is expired it stop the trucks when they reach back to plant not on the road area.Means when time is finished it instruct that truck (grc Obj1234) to stop at the loc of plant.
The code to move the truck from plant to filed is given below please
script..
move grc Obj8531 to the loc of grc item 1 of line 1 of field "ObjectsLoc" in 0 sec without waiting
Now your propose script #STOP MOVING grc obj3455# is working and stop the object (Truck) where it is.
i want to stop it at plant when time is expire.
This is my problem hopefully you will understand.
Regard
Irfan




1.first thing is that my Revolution studio application start when it is trigger from java platform.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: How timer is used in Revolution studio

Post by mwieder » Tue Sep 28, 2010 12:31 am

OK - that's starting to make more sense. You should have explained this in the first place.

I wouldn't use a timer for this at all. Here's what I'd do:

Set a custom property of each truck as it leaves for the field.
When the truck returns to the plant, check to see if enough time has elapsed.
If not, send the truck back out again.

For instance...

When you start a truck:

Code: Select all

set the uStartingTime of grc Obj1234 to the seconds
When the truck returns to the plant:

Code: Select all

if (the seconds - the uStartingTime of grc Obj1234) < 30 then
  --send the truck out again
end if
Since I don't know anything about your code, I can't tell you where to put this code. If it were me, I'd put the code in the truck objects themselves, creating a sort of truck class. The code would then become

Code: Select all

-- when the truck gets sent to the field
set the uStartingTime of me to the seconds

-- when the truck returns
if (the seconds - the uStartingTime of me) < 30 then
...
...and as has recommended before, you need to learn something about this development environment before embarking on an ambitious project like this:
http://www.runrev.com/developers/lesson ... onferences

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

Re: How timer is used in Revolution studio

Post by irfan » Wed Sep 29, 2010 8:54 pm

hi kluas,,

Thank you very much for suggesting me to read example ..it helps me a lot and solve all my minor problems ,,, now i am stuck in the final stage .. it is stated below

on Finished
---if pResult2="odd" then
STOP MOVING grc "Obj8533"
STOP MOVING grc "Obj8535"
STOP MOVING grc "Obj8537"
end Finished
this script stop all the listed objects that are moving between plant and field where it is,( may be on the raod or plant). my target is to stop the objects after time is finished into the plant area or field area not on the way. i mean to say that when time is finised and moving obj (truck) is on the way to plant or field then it must stop while it reach on plant or field not on the way . The script to move the grc object
is given below.
move grc Obj8533 to the loc of grc item 1 of line 1 of field "ObjectsLoc" in 0 sec without waiting .

field id is "Obj8525" and plant id is "Obj8517".
my target is to stop the above listed grc obj at plant or field after is stooped.
hopefully you will understand and assist me.

Regard
Irfan

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

Re: How timer is used in Revolution studio

Post by Klaus » Thu Sep 30, 2010 11:07 am

Hi irfan,

I am very sorry, but I still do not understand what you are after except stopping the graphics, which already works obviously.

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

Re: How timer is used in Revolution studio

Post by irfan » Thu Sep 30, 2010 11:49 am

hi kluas,

i know graphic stooping is working but now i want to stop the moving graphic at specific location (on plant r on field) graphic object.
i try the following script to stop the graphic object at plant but it is not working.

-STOP MOVING grc "Obj8533" to the loc of grc "Obj8517"
--STOP MOVING grc "Obj8535" to the loc of grc "Obj8517"
here "Obj8517" is plant location. my target is to stop moving graphic when they reach on this graphic object (plant).

may be with little modification of this script it will work.


Regard
Irfan

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

Re: How timer is used in Revolution studio

Post by Klaus » Thu Sep 30, 2010 12:15 pm

Hi irfan,

hm, when you stop something it will of course just stop where it is and not at a specific point (loc)! :)
So maybe you could set its location after it has stopped?
...
stop moving grc "Obj8533"
set the loc of grc "Obj8533" to the loc of grc "Obj8517"
...
Not sure if I understand you.


Best

Klaus

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

Re: How timer is used in Revolution studio

Post by irfan » Thu Sep 30, 2010 1:47 pm

hi klaus,

i am trying that script... let me clear on thing that when i stop the grc object with script below

STOP MOVING grc "Obj8533" then it is working ,, but when i want to stop it with condition like..

if pResult2="complete" then send STOP MOVING grc "Obj8533" .......... This script is now not stop the specified object.

as logically it is looking true that if pResult="complete" then it should stop object.

i also try this script...
if pResult2="complete" then STOP MOVING grc "Obj8533" ... it is also not working.

regard

Irfan

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

Re: How timer is used in Revolution studio

Post by Klaus » Thu Sep 30, 2010 1:57 pm

Hi irfan,

we need more info than "is not working"! Do you get any errors?
And please post the complete script that is not working, because this part
...
if pResult2="complete" then stop moving grc "Obj8533"
...
IS correct syntax!


Best

Klaus

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

Re: How timer is used in Revolution studio

Post by irfan » Thu Sep 30, 2010 2:28 pm

hi klaus

this is the script. First read from socket and then store in three different variable. the Third variable pResult2 is used in the last condition..
on mouseup
read from socket tSocket until return
put it into tResult
put item 1 of tResult into pResult
put item 2 of tResult into pResult1
put item 3 of tResult into pResult2 ////// its value will be even

if "truckContractor1need nine truck"= pResult -- evaluates to true
then
send "complete" to me in pResult1 seconds
lock moves
move grc Obj8533 to the loc of grc item 1 of line 1 of field "ObjectsLoc" in 0 sec without waiting
move grc Obj8531 to the loc of grc item 1 of line 1 of field "ObjectsLoc" in 0 sec without waiting
unlock moves
end if
end mouseup

on complete

if pResult2="even" then stop moving grc "Obj8531"
if pResult2="even" then stop moving grc "Obj8533"

end complete

Post Reply