SRL Archive - Help and Support

trouble with case and strings


weaselforce

2006-05-20 01:09:37

ok heres the procedure im trying to get working. Im basically trying to get the "case" to click on text from the included string to correspond to whatever the const is. The problem is i dont know if it should be written like this:

case BowType of
Shaft: ClickText2(Shaft;SmallChars, 18, 455,489,360;false);
Long: ClickText2(Long;SmallChars, 20, 452, 483, 359;false);
Short: ClickText2(Short;SmallChars, 20, 452, 483, 359;false);
end;
—————————————————
case BowType of
' Shaft': ClickText2('Shaft';SmallChars, 18, 455,489,360;false);
'Long': ClickText2('Long';SmallChars, 20, 452, 483, 359;false);
'Short': ClickText2('Short';SmallChars, 20, 452, 483, 359;false);
end;
—————————————————
or defined as a variable like i have it below. can anyone shed some light?

begin
Shaft :='Arrow Shaft';
Long := 'Long Bow';
Short:= 'Short Bow';
if(ToFletch >= 27) then
begin
lollerskates := 34
end else
begin
lollerskates := ToFletch
end
begin
UseItem(1);
UseItem(2);
wait(400+random(200));
case BowType of
Shaft: ClickText2(Shaft;SmallChars, 18, 455,489,360;false);
Long: ClickText2(Long;SmallChars, 20, 452, 483, 359;false);
Short: ClickText2(Short;SmallChars, 20, 452, 483, 359;false);
end;
PopUp(4);
SendText(IntToStr(lollerskates)''+chr(13));
RandomEvents;
Wait(12000+random(2000));
RandomEvents;
Wait(25000+random(4000));
RandomEvents;
if(lollerskates = 34) then
ToFletch := ToFletch - 27;
Fletched := Fletched + 27;
end else
ToFletch := ToFletch - lollerskates
Fletched := Fletched + lollerskates
end;
end;
end;


WhiteShadow

2006-05-20 01:11:36

Yea you should make it a String.

I'm not sure how to help since I need to know how you setup the other things. Like is Shaft like a constant or something?

weaselforce

2006-05-20 01:42:48

problem is that its nowhere near done, i was trying to debug it and ran into this problem :( heres how its set up so far


program WeaselFletcher;

{.include SRL/SRL.scar}

var ToFletch,Fletched:Integer;

//-----------------------------------------------------//

Const
AmountOfLogs = 2000; // Amount of bows (u) to make.
BowType = 'Shaft'; // Uppercase, vaild = Long, Short, Shaft

//-----------------------------------------------------//

Procedure BankingWithdraw;
begin
if(not (inventorycount=0))then
begin
OpenBank3;
DepositAll;
BankingWithdraw;
end else
begin
if (not (Bankscreen))
then
begin
OpenBank3;
Fixbank;
end else
Fixbank;
if (ToFletch >= 27) then
begin
Withdraw(1,1,0);
end else
begin
withdraw(1,1,ToFletch);
end
Closewindow;
end;
end;

Procedure BankingDeposit;
begin
OpenBank3;
fixbank;
Deposit2(2,0);
if(not (InventoryCount = 0)) then
DepositAll;
wait(375 + random(30));
end;

procedure Fletch;
var lollerskates:Integer;
var Shaft,Long,Short:String;

begin
Shaft :='Arrow Shaft';
Long := 'Long Bow';
Short:= 'Short Bow';
if(ToFletch >= 27) then
begin
lollerskates := 34
end else
begin
lollerskates := ToFletch
end
begin
UseItem(1);
UseItem(2);
wait(400+random(200));
case BowType of
Shaft: ClickText2(Shaft;SmallChars, 18, 455,489,360;false);
Long: ClickText2(Long;SmallChars, 20, 452, 483, 359;false);
Short: ClickText2(Short;SmallChars, 20, 452, 483, 359;false);
end;
PopUp(4);
SendText(IntToStr(lollerskates)''+chr(13));
RandomEvents;
Wait(12000+random(2000));
RandomEvents;
Wait(25000+random(4000));
RandomEvents;
if(lollerskates = 34) then
ToFletch := ToFletch - 27;
Fletched := Fletched + 27;
end else
ToFletch := ToFletch - lollerskates
Fletched := Fletched + lollerskates
end;
end;
end;

Procedure RandomEvents;
Begin
FindSandwich;
FindTalk;
FindLamp('fletching');
GambleNewBox;
FindNormalRandoms;
end;

begin
ToFletch := AmountofLogs
Fletched := 0
SetupSRL;
RandomDisguise;
MouseSpeed := 12
BenMouse := True
CloseWindow;
ChatsOff;
RandomEvents;
Repeat
BankngWithdraw;
Fletch;
BankingDeposit;
Until(Fletched >= AmountofLogs

WhiteShadow

2006-05-20 01:47:54

Compiles now.

program WeaselFletcher;

{.include SRL/SRL.scar}

var ToFletch,Fletched:Integer;

//-----------------------------------------------------//

Const
AmountOfLogs = 2000; // Amount of bows (u) to make.
BowType = 'Shaft'; // Uppercase, vaild = Long, Short, Shaft

//-----------------------------------------------------//
Procedure RandomEvents;
Begin
FindSandwich;
FindTalk;
FindLamp('fletching');
GambleNewBox;
FindNormalRandoms;
end;

Procedure BankingWithdraw;
begin
if(not (inventorycount=0))then
begin
OpenBank3;
DepositAll;
BankingWithdraw;
end else
begin
if (not (Bankscreen))
then
begin
OpenBank3;
Fixbank;
end else
Fixbank;
if (ToFletch >= 27) then
begin
Withdraw(1,1,0);
end else
begin
withdraw(1,1,ToFletch);
end
Closewindow;
end;
end;

Procedure BankingDeposit;
begin
OpenBank3;
fixbank;
Deposit2(2,0);
if(not (InventoryCount = 0)) then
DepositAll;
wait(375 + random(30));
end;

procedure Fletch;
var lollerskates:Integer;
Shaft, Long, Short:String;
begin
Shaft :='Arrow Shaft';
Long := 'Long Bow';
Short:= 'Short Bow';
if(ToFletch >= 27) then
begin
lollerskates := 34
end else
begin
lollerskates := ToFletch;
UseItem(1);
UseItem(2);
wait(400+random(200));
case BowType of
Shaft: ClickText2(Shaft, SmallChars, 18, 455, 489, 360, false);//
Long: ClickText2(Long, SmallChars, 20, 452, 483, 359, false);//
Short: ClickText2(Short, SmallChars, 20, 452, 483, 359, false);//
end;
PopUp('4'); //
SendText(IntToStr(lollerskates)+chr(13));
RandomEvents; //Random procedure yea?
Wait(12000+random(2000));
RandomEvents; //
Wait(25000+random(4000));
RandomEvents;
if(lollerskates = 34) then
begin
ToFletch := ToFletch - 27
Fletched := Fletched + 27
end else // end else requires a begin
begin
ToFletch := ToFletch - lollerskates
Fletched := Fletched + lollerskates
end;
end;
end;


begin
ToFletch := AmountofLogs
Fletched := 0
SetupSRL;
RandomDisguise;
MouseSpeed := 12
BenMouse := True
CloseWindow;
ChatsOff;
RandomEvents;
Repeat
BankingWithdraw;
Fletch;
BankingDeposit;
Until(Fletched >= AmountofLogs )
end.

weaselforce

2006-05-20 01:52:34

when i use a comma i get "comma expected" later on in the script. Semicolon i get one in the middle of 'text'. i'm very confused

function ClickText2(txt: String; font, xs, ys, xe, ye: Integer; left: Boolean): Boolean;

^ does that not imply semicolon?

inferno

2006-05-20 05:16:26


function ClickText2(txt: String; font, xs, ys, xe, ye: Integer; left: Boolean): Boolean;

No it doesn't imply a semi-colon. The txt parameter is a String, hence the word string after it, the semi-colon following the word String means it is the end of the string parameters. Then you have the xs, ys, xe, ye parameters followed by the word Integer to show they are integer values, again there is a semi-colon to show it is the end of the integer parameters. And the same for the Left parameter, which is identified as a boolean. Finally the whole function returns a boolean value, as shown by the Boolean; outside the brackets.

So no, you don't put semi-colons in there, just commas between each parameter

program WeaselFletcher;

{.include SRL/SRL.scar}

var ToFletch,Fletched:Integer;

//-----------------------------------------------------//

Const
AmountOfLogs = 2000; // Amount of bows (u) to make.
BowType = 'Shaft'; // Uppercase, vaild = Long, Short, Shaft

//-----------------------------------------------------//
Procedure RandomEvents;
Begin
FindSandwich;
FindTalk;
FindLamp('fletching');
GambleNewBox;
FindNormalRandoms;
end;

Procedure BankingWithdraw;
begin
if(not (inventorycount=0))then
begin
OpenBank3;
DepositAll;
BankingWithdraw;
end else
begin
if (not (Bankscreen))
then
begin
OpenBank3;
Fixbank;
end else
Fixbank;
if (ToFletch >= 27) then
begin
Withdraw(1,1,0);
end else
begin
withdraw(1,1,ToFletch);
end
Closewindow;
end;
end;

Procedure BankingDeposit;
begin
OpenBank3;
fixbank;
Deposit2(2,0);
if(not (InventoryCount = 0)) then
DepositAll;
wait(375 + random(30));
end;

procedure Fletch;
var lollerskates:Integer;
begin
if(ToFletch >= 27) then
begin
lollerskates := 34
end else
begin
lollerskates := ToFletch;
UseItem(1);
UseItem(2);
wait(400+random(200));
case BowType of
'Shaft': ClickText2('Arrow Shaft', SmallChars, 18, 455, 489, 360, false);//
' Long': ClickText2('Long Bow', SmallChars, 20, 452, 483, 359, false);//
'Short': ClickText2('Short Bow', SmallChars, 20, 452, 483, 359, false);//
end;
PopUp('4'); //
SendText(IntToStr(lollerskates)+chr(13));
RandomEvents; //Random procedure yea?
Wait(12000+random(2000));
RandomEvents; //
Wait(25000+random(4000));
RandomEvents;
if(lollerskates = 34) then
begin
ToFletch := ToFletch - 27
Fletched := Fletched + 27
end else // end else requires a begin
begin
ToFletch := ToFletch - lollerskates
Fletched := Fletched + lollerskates
end;
end;
end;


begin
ToFletch := AmountofLogs
Fletched := 0
SetupSRL;
RandomDisguise;
MouseSpeed := 12
BenMouse := True
CloseWindow;
ChatsOff;
RandomEvents;
Repeat
BankingWithdraw;
Fletch;
BankingDeposit;
Until(Fletched >= AmountofLogs )
end.

weaselforce

2006-05-20 15:29:57

gah ok, that makes perfect sense. I should have noticed that myself :(