Global time variable

what syntax should I use to run a function within a script in variable time intervals? Would like to avoid having to use cron, iCal etc.

Is this in Script Editor, or AppleScript Studio? AppleScript Studio is, as I mentioned, different. AppleScript Studio does not automatically enable the idle handler; you have to go to the main nib file, choose "File's Owner", and turn on the idle handler in the inspector, similar to the way you would handle a click on a button. It seems to use the same mechanics, though.
As for getting it to work, let's see...
Well, first off, get rid of the brackets after "on idle". You don't need them, and they may be screwing things up.
Next, you probably don't want idle to get called every second, which is what this example is going to do. (It's returning nHours * nMins * nSecs, which is 1 * 1 * 1, which is 1.)
Make sure you're saving the thing as a "Stay-Open" program in Script Editor.
And, finally: keep in mind that the idle handler will only be called if you run the program stand-alone. If you're running it in Script Editor, the idle handler will never be called.

Similar Messages

  • Dealing with a turn based application with using a global static variable

    Hi there. I read some articles about JavaFX concurrency,so as a newbie i have to practice on it. Now i'm trying to implement a turn based application that can be played among 3-6 players. Moreover, i use a scene imported from a .fxml file and i have to update it correctly depends on some calculations of each thread (in other word players ). My main issue is, i don't wanna use a while loop which checks the state of game like;
    while( GameState != State.GAME_OVER ){
         currentPlayer = GameBoard.getNextPlayer();
         // do some actions,calculations etc.
    So, i want to use worker threads instead of this while loop. I guess using Service class for iterating and assigning the next player will be suitable instead of using the while loop and Tasks for doing each player's calculation,or waiting for some responses from Human players on UI based,however, i'm struggling with two problems.
    There should a global static variable ( like GameState which is an Enumarator ) determines the state of the game,so it should be updated and should be checked by each turn. Is there any way to do this ?
    How can i get rid off this while loop ?
    I will appreciate for every answer. Thanks anyway.

    It shouldn't make too much difference. The basic idea is that you have a model class representing your game state (the Game class in jsmith's example). When a player makes a move, you update the state of the game. Since this will result in changes to the UI, this update should be performed on the FX Application Thread.
    If the player making the move is a human player, the move will likely be made by a user action (button press or mouse click, etc); this will be handled on the FX Application thread anyway.
    When the state of the game changes so it is the turn of an "artificial" player to make a move, have the object representing the artificial player calculate its next move, and then update the game state. Since this is a response to the game state changing (it's now the turn of the artificial player), this will also be on the FX Application Thread.
    The only (slight) complexity comes if the calculation of the move for the artificial player takes a long time. You don't want to perform this long running calculation on the FX Application Thread. The cleanest way to manage this is to launch a Task which calculates the desired move, and then updates the game state when the move is ready. So, something like this:
    GameState game = ... ;
    // UI is bound to the game state.
    ExecutorService executorService = ... ;
    final Player currentPlayer = game.getCurrentPlayer() ;
    final Task<Move> calculateMoveTask = new Task<Move>() {
         @Override
         public Move call() {
              Move move = // compute next move...
              return move ;
    calculateMoveTask.setOnSucceeded(new EventHandler<WorkerStateEvent>() {
         @Override
         public void handle(WorkerStateEvent event) {
              gameState.makeMove(currentPlayer, calculateMoveTask.getValue());
    executorService.submit(calculateMoveTask);
    If you're doing more threading than that, you're probably doing it wrong... . There should also be no need for anything to be held as a "global" static variable (the idea above is the only structural modification you need to the example posted by jsmith).

  • Global Constants / Variable in OSB

    I want to define global Constants / Variable in OSB and I want to access them in XSLT when I am tranforming the requests...
    Any idea how can I do that?
    I want to use these variables and constants for server name and ports (in different environment) and some other stuff.

    We have done a similar implementation for the same scenario. We have created a Xquery where we put in the configuration information as an XML and then in the pipeline stages we use the Assign the Xquery to a a temporary variable and then use the values of the xml using relative xpath expressions.
    This way any time we need to make any changes to the confguration we know once place we can change and it gets reflected in the complete code base.
    Below is how we have done it:
    - create a Xquery with xml configurations (say commonconfig.xq)
    - then using the Assign action get the output of this xquery into a temp var (say commonConfig)
    - then use the configurable values using the relative xpath in the Assign action (say Assign $commonConfig/param1/text() to param1Value
    Let me know if you need further information.
    Thanks,
    Patrick

  • Global Application variable

    How do I set a global application variable in a Swing application?
    Namely
    MDI display opens a new window
    new window sets a variable
    close the new window and return to the MDI window
    MDI window needs to use the variable.
    Note: the new window is is its own class object.

    What are you talking about?
    Static variables are "global".
    In some class (it does not really matter which) define
    a static variable. O.K. now you have a "global"
    variable.
    Some people may say that this is "bad" programming
    practice, but it is what you asked for.public static variables of public classes are 'global' in the sense you can refer to them if anywhere in an application. Public classes are also 'global' in this sense.
    However, we don't call them global variables, they are class variables. A global variable is generally defined to be one that is associated with the running application. It has no context other than that. It can be used anywhere at any time without any qualifications. In other words, the are terrible.
    I had to maintain an application that had 50 or so global variables. Some of these variables represented the exact same piece of information so it was cruicial during modifications to make sure that they were kept in sync. Don't use this type of design.

  • Avoid Global Public variables...

    Hello Experts,
    I have declared few variables in package specification (l_test , l_test_2)and i'm using across the API procedures.
    But when i run the TOAD expert it says "Avoid defining global public variables in the package specification."
    So i thought of moving the code from package specification to package body...
    Is this a good approach and will my code work as it was working before if i declare in the body...
    Plz suggest ...
    Thanks...
    Earlier
    Package Specification Part
    CREATE OR REPLACE PACKAGE PKG_TEST
    AS
    l_test NUMBER(1);
    l_test_2 NUMBER(2);
    END;New
    CREATE OR REPLACE PACKAGE BODY PKG_TEST
    AS
      l_test NUMBER(1);
    l_test_2 NUMBER(2);
       PROCEDURE process
       IS
       END process ;
       PROCEDURE process_2
       IS
       END process_2 ;
    END PKG_TEST;

    Linus,
    Just so you are aware, the scope of those variables are different depending on if they are defined in the PACKAGE (SPEC) or PACKAGE BODY.
    Declared in the PACKAGE (Spec): Globally accessible to everything on the Schema.
    Declared in the PACKAGE (Body): Globally accessible to everything with that particular Package.
    So as you can see, this quite a big difference. TOAD is warning you because putting globals in the PACKAGE is a pretty sloppy coding practice that can easily lead to difficult to maintain code. While you can ignore it, I'd suggest not doing that. ;)
    In fact, I'd suggest avoiding globals altogether when possible. Passing parameters may be more time consuming, but it makes it very clear what each procedure/function should be doing, and future programmers will thank you. Time you'll save on initial programming will be made up when doing maintenance. But admittedly globals are useful, just be careful when using them. Getting your code to work isn't enough; you should aim to make it clear and understandable too.

  • Time Variable in Container Operation in BPM

    hi,
    how can we add a time variable in container operation in BPM?
    Say i want to increment the time upto 5 hours and see if it has reached in my loop.
    how can we achieve this?
    Tiru

    henrique -
    I have a block with a timeout defined.
    Within the block i have the deadline with control step which triggers the exception
    I have the exception handler which has a send step which sends the actual error message.
    I have a send step which polls the http receiver and is in a infinite loop.
    Now the first time i receive an error message i get an email which is good and should work that way.
    Next time if it errors out it should continue until a deadline of 8 hours and then should send out an error email.
    What happens is i get the second error message immediately without the deadline getting exceeded.
    When i look at the workflow log the exception handler gets executed but i don't see a sign of the deadline getting executed?
    Any reasons why its behaving this way?
    Thanks,
    Tiru

  • In need of a global time

    Hi
    I start by making a 1000 frame long comp called "WheelLoop" in which I add a 30 frame Animated file sequence of a 360 degree wheel turn.
    I then add a loopOut Cycle expression to the footage layer so that the wheel keeps turing over and over again for the entire 1000 frames.
    Next I precomp the WheelLoopComp into a new 1000 frame long comp called "Wheelspin"
    From now on I can controll the exact point of the wheel turn in time via a TimeRemap on the WheelSpin comp.
    E.g. If I set the time remap to 30 frames the wheel has turned once, and at 120 fr. it has turned four times.
    Next I go on with my comp work and end up having burring this WheelSpin comp way down in precomps with all sorts of starting point offsets to the.
    now when I am stading in the TopLevelComp at frame 120 I can no longer be sure that the wheel has turned four times, cause of all the layer starting points offsets.
    What I would like is to go down the line into the WheelSpin comp and have the TimeRemap refer to the "Global time" (or Top Comp Time) regardless of any offsets up the line in the different layes that holds the WheelSpin Comp.
    The result should be so that when I tell the WheelSpin Comps TimeRemap to be at frame 120 from the TopLevel Comp, the Wheel should have turned exactly four times regarless if some of the Comp thats holds it might have a different starting points.
    To do this I feel I need a Global time.
    E.g. go into the TimeRemap of the WheelSpin Comp and add an expression " comp("TopLevel").time "
    Is this in anyway possible?
    Thanks in advance

    Try replacing your loopOut() time remapping expression with this one:
    period = key(numKeys).time - key(1).time;
    time%period
    Dan

  • Global Container Variable

    Hi
    Give me idea on Global Container variable in Graphical mapping.
    Thanx in Advance

    Hi
    Ref this
    /people/sravya.talanki2/blog/2005/12/21/use-this-crazy-piece-for-any-rfc-mapping-lookups
    http://help.sap.com/saphelp_nw04/helpdata/en/95/bb623c6369f454e10000000a114084/content.htm
    Design and Configuration [original link is broken]
    Thanks
    Sridhar

  • Global Counter Variable - Graphical Mapping

    Hi there.
    Can anybody help with implementing a global counter variable in the graphical mapping please.
    I am trying to populate the "SEGMENT" field of an IDoc with the correct sequence, i.e. add 1 for each new segment. The IDoc has several segments, most of which are embedded. I have tried using the "<b>counter</b>" function but this seems to reset back to one for each instance of it being called.
    I would appreciate any pointers.
    Thank you.
    Mick.

    Hi see this for implementation
    <b>defining Global Variables</b>
    ArrayList arrVI;
    int counter =0;
    <b>Initialization Section</b>
    arrVI= new  ArrayList();
    <b>assignment</b>
    arrVI.add(sVI[iLoopCounter]);
    counter++;
    <b>
    fetch Values</b>
    for (int i =0;i<counter;i++)
    result.addValue(arrVI.get(i)+"");
    Mudit

  • CPM- Run Time variable

    Hi SEM Gurus,
    In CPM -BSC, there are two types of CPM variables, one is Design CPM variable which is used to define the char value at the time of designing the BSC and other is runtime (Presentation)CPM variable which can be used to pass the value of char at the runtime or executing the BSC. The problem is that The second variable ( Run time ) is not working i.e. in value field of measure designing we have to assign this created runtime cpm variable to char but we cant see this cpm variable while assigning this to char.
    Please help me to solve this problem.
    Could anybody will confirm that this is possible in BSC? basically this is possible in management cockpit and it must work in BSC but unfortunatly it is creating a problem for us.
    Thanks/ hari

    Hi Hari,
    I'm now starting a BSC implementation and I'm facing the same issue. I created a CPM run time variable and I can't assign it in the BSC.
    Did you find a way to do this?
    Thanks in advance.
    Best Regards,
    Sofia Silva

  • SEM-CPM - Time Variables

    Hi All,
    Im working with CPM in order to create a cockpit.
    Right now i need to use the time variables in order to filter the information by period.
    I will appreciate if someone can give me some comments/step by step  in how to works with Time Variable in CPM ?
    Regards
    I will assign points.

    hi Marcos,
    did you have the SEM220 training material ? i think cpm time variable is discussed
    or check in sap help ... didnt work with CPM for long time
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/3a/4ba1bd2bf203cbe0000800091c1b0e/frameset.htm
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/c2/5a4ab4770911d3b7210000e82debc6/frameset.htm
    hope this helps.

  • Comma problem with global string variable

    Hi,
    I'm fiighting with comma problem for global string variable. I've on page string for example "7nndqrr52vzyb,0" and by dynamic column link I'm assigning this string to global variable. Then I'm trying to display value of that global variable on another page but I see only string till comma, nothings more. I'm not sure what I'm doing wrong because when I'm trying to assign that value normally by computation process as a constant value is fine and see on another page correct string. I'll be really glad for help.
    Thanks
    Cheers,
    Mariusz

    When it tries to display the string, it sees the comma and wants to believe the string is terminated. You could escape the , in the string or replace it with a different character..
    See this link: http://download.oracle.com/docs/cd/E17556_01/doc/user.40/e15517/concept.htm#BEIGDEHF
    Thank you,
    Tony Miller
    Webster, TX
    If vegetable oil is made of vegetables, what is baby oil made of?
    If this question is answered, please mark the thread as closed and assign points where earned..

  • Corrupt Global User Variable?

    We're running ICM 7.5 and over the weekend, calls stopped routing to one skill.  AT&T, our first line, worked with Cisco and after research/testing, came back with an answer that the global user variable was corrupt.  Has anyone experienced this?  It seems odd that out of the blue this becomes corrupt, especially over a weekend when call volume is low.
    My team, along with Network and AT&T did a process of elimination, removing translation route & global user to validate call routing and adding each piece back.  When the variable was added, call routing failed to backup routing.
    Thanks,
    Jill M Gorrie

    Hi,
    User variables are meant to be used in web forms and web forms only. You can certainly pass their values to business rules when you used them in POV or page section of the form during save. All you need to do is to create another business rule (local or global) variable in business rule on the corresponding dimension and use it in your business rule. If you enable running the business rule on save and using the form values for variables options in form properties, business rules would replace the values of business rule variables with the values that are set in user variables.
    Cheers,
    Alp

  • Which Time variable should use compare this month with last month

    We want to calculate the increaed number of employees according to one action reason e.g. Entry to company compare with last month. In this case we have to use time variable in BEx query designer. Now can see 0calmonth has serval variable available.
    1) Should we use [0CMLMON] for last month and use offset for this month like [0CMLMON]-1 or [0CMLMON]+1 or use variable [0RSTTCM1], which variable should we use for this month and last month? Do we need to create variables by manually?
    2) Then using calculated KF to calculate the increaed number of employees, is this logic correct? If it is wrong, please info.
    Edited by: hi ni on Apr 22, 2008 7:58 AM

    Hi,
    For the comparison of last 2 months data, you can use two Restricted Key figures with reference to 0CALMONTH and it is better to use only customer exit variable for both RKF's.For the Last month use offset value as -1.
    Rgs,
    I.R.K

  • Use of YTD versus PTD time variable

    All,
    Are there any reasons to move to YTD or stick with PTD from a system perspective? One reason to stick with PTD may be to comply with a regulated (calender year - December) and non-regulated (financial year - March) closing/reporting in the same application. BPC 7.0 provides the use of two time variables within the same application so that there may be no reason to use PTD. Is the use of YTD easier from a customisation and data migration perspective?
    Thank you for your advise.
    Marc

    All,
    Are there any reasons to move to YTD or stick with PTD from a system perspective? One reason to stick with PTD may be to comply with a regulated (calender year - December) and non-regulated (financial year - March) closing/reporting in the same application. BPC 7.0 provides the use of two time variables within the same application so that there may be no reason to use PTD. Is the use of YTD easier from a customisation and data migration perspective?
    Thank you for your advise.
    Marc

Maybe you are looking for

  • Un able to install Scan to Email app on Color LaserJet Pro MFP M177fw

    Hello! I recently purchased  Color LaserJet Pro MFP M177fw as my home printer. Main thing i was looking for was Scan to Email feature. As I read in specifications provided in this product description I see: http://www.shopping.hp.com/shopping/pdf/cz1

  • My Iphnoe 4 was stolen, what can i do?, how to know when it's block by IMEI

    I'm travelling across argentina, and a couple of days ago some one stolen my Iphone in my room in KAIXO CENTRAL HOSTEL, (never go there!!!, there is an YHA hostel close to this, and there are security, I learn of my mistakes, later...). I want to kno

  • Wrong character conection in non-latin pdf

    Hello, We are working on a database with multi language data including Hebrew, Arabic, Persian and English, and our reports in HTML are correct but in PDF output there are few character mixing problems, we had a similar problem in Forms but fixed it

  • Expense's getting Auto Approved and Invoiced.

    HI Few of the Expense report/s are getting Auto Approved and Invoiced in the system. Due to which a valid GL accoutn combination is not generated. Regards, V.

  • Random Contacts sync errors

    We keep encountering Contacts sync errors. We are syncing two Macs/Lion and two iPads. There is no pattern as to where the correct contact entry was created - could by any of the four devices. We don't create on icloud.com, only use that for troubles