Results 1 to 7 of 7

Thread: Setting a variable equal to a function

  1. #1
    Join Date
    Oct 2008
    Posts
    196
    Mentioned
    1 Post(s)
    Quoted
    20 Post(s)

    Default Setting a variable equal to a function

    I'm trying to set a variable equal to a function in this function:

    Simba Code:
    procedure WaitBetweenLoading(State: integer); // 0 is buying, 1 is selling and 2 is GE menu
    var
      c: integer;
      menu: string;
    begin
      Case State of
      0: menu := isBuyOpen;
      1: menu := isSellOpen;
      2: menu := InGE;
      end;
      MarkTime(c)
      While not menu do
        begin
          Wait(500);
          If TimeFromMark(c) > 30000 then
            Writeln('Could not get to the screen');
            TerminateScript;
        end;
    end;

    For example, if the input 'State' is equal to 0, I want menu to change to InGE if state is 1 then its isSellOpen i want it changed to and so on
    is this possible?

    Edit: Missing around with Types. might get something figured
    Last edited by HT BaaFly; 01-01-2012 at 02:05 AM.

  2. #2
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Wut? Do you mean you want a Global variable? If you want to use Menu outside of the function then just do var
    Menu: String;

    Procedure...

    Because your "case state of" already assigns menu a value.. I believe if you wanted the entire function in a variable you can do X:= @Function... Correct me if I'm wrong.
    I am Ggzz..
    Hackintosher

  3. #3
    Join Date
    Sep 2007
    Location
    British Columbia, Canada
    Posts
    4,047
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    I didn't try to compile your code, but this doesn't work?
    Simba Code:
    Case State of
      0: menu := isBuyOpen;
      1: menu := isSellOpen;
      2: menu := InGE;
      end;

    seems like it should but your menu is set as string not a boolean.

    also
    Simba Code:
    MarkTime(c)
      While not menu do
        begin
          Wait(500);
          If TimeFromMark(c) > 30000 then
            Writeln('Could not get to the screen');
            TerminateScript;
        end;

    again, you set menu as string not as boolean.


    My suggestion
    Simba Code:
    menu: string;
    //change that to
    menu: boolean;

    should be oke:P
    Oh Hai Dar

  4. #4
    Join Date
    Oct 2008
    Posts
    196
    Mentioned
    1 Post(s)
    Quoted
    20 Post(s)

    Default

    tried this
    Simba Code:
    Case State of
        0: menu := @isBuyOpen
        1: menu := @isSellOpen
        2: menu := @InGE
      end;
    same error

    I am not trying to declare a global variable

    I want menu to be a function and I want to change to other functions depending on the value of the integer state

    That did it Main thanks a lot

  5. #5
    Join Date
    Sep 2007
    Location
    British Columbia, Canada
    Posts
    4,047
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    so is the problem fixed? :P
    Oh Hai Dar

  6. #6
    Join Date
    Oct 2008
    Posts
    196
    Mentioned
    1 Post(s)
    Quoted
    20 Post(s)

    Default

    yeah just tested it. thanks a lot

  7. #7
    Join Date
    Sep 2007
    Location
    British Columbia, Canada
    Posts
    4,047
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    sexy
    Oh Hai Dar

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •