SRL Archive - OSR Help

Setting a variable equal to a function


HT BaaFly

2011-12-31 20:56:33

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

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

Brandon

2011-12-31 21:05:38

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.

Main

2011-12-31 21:11:03

I didn't try to compile your code, but this doesn't work?

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

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

menu: string;
//change that to
menu: boolean;

should be oke:P

HT BaaFly

2011-12-31 21:11:09

tried this
  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 :)

Main

2011-12-31 21:13:49

so is the problem fixed? :P

HT BaaFly

2011-12-31 21:16:51

yeah just tested it. thanks a lot :D

Main

2011-12-31 21:21:11

sexy