SRL Archive - OSR Help

Need quick help on withdrawing an item from the bank


Lisafishes

2013-03-05 14:54:45

I have read the comments on the banking page, and every time I think I understand how to write the line, I geta syntax error.
I just need someone who successfully uses: WithdrawItem to show me how the line is correctly written

This is what I have and it gives me a type mismatch.

 Procedure Banking;
Var
dpick: Integer;

Begin
dpick := DTMFromString('mbQAAAHicY2VgYMhmYmBIB+IaIE4E4iIgFmdkYOAAYkkgVgNiHiBmYGDCgjEBIxYMBgD4aAKv');

OpenBankQuiet('eb');
DepositAll;
WithdrawItem('dpick', 922984, [1], ['rag', 'ick'], 6);



End;

Ashaman88

2013-03-05 14:59:33

Show me what the parameters are and I will tell you

Le Jingle

2013-03-05 15:33:12


procedure Banking;
begin
OpenBankQuiet('eb');
DepositAll;
WithdrawItem(922984, 'color', 1, 'rag', [6]);
end;

Make sure you have the correct types for each argument.

function WithdrawItem(Ident: integer; IdentType: string; Amount: integer; UpText: String; Tol: TIntegerArray): boolean;

There's no TStringArray for this specific method.

Also, I don't see why you declare a dtm when you don't use it (DPick).

Lisafishes

2013-03-05 15:38:54

From: Ashaman88
Show me what the parameters are and I will tell you


This is what it shows in the notes for this function
(*
WithdrawItem
~~~~~~~~~~~~

.. code-block:: pascal

function WithdrawItem(Ident: integer; IdentType: string; Amount: integer;
UpText: TStringArray; Tol: TIntegerArray): boolean;

Withdraws an item using WithdrawItemEx, but removes the Index check.

.. note::

Author: Nava2
Last Modified: Unknown

Example:

.. code-block:: pascal

if WithdrawItem(theColor, 'color', 27, ['ew log', 'ew l'], [3]) then
CloseBank;
*)

Lisafishes

2013-03-05 15:42:58

But I am using it, the dtm is called dpick, I'm nt trying to withdraw by column and row but by dtm and color
From: Le Jingle

procedure Banking;
begin
OpenBankQuiet('eb');
DepositAll;
WithdrawItem(922984, 'color', 1, 'rag', [6]);
end;

Make sure you have the correct types for each argument.

function WithdrawItem(Ident: integer; IdentType: string; Amount: integer; UpText: String; Tol: TIntegerArray): boolean;

There's no TStringArray for this specific method.

Also, I don't see why you declare a dtm when you don't use it (DPick).

Ashaman88

2013-03-05 15:46:55

withdrawitem(dpick,'dtm',28,['rag', 'ick'],[]);

replace the 28 with however many you want to withdraw. Just doing this on comp not sure if it compiles

Lisafishes

2013-03-05 15:54:31

yet another type mismatch. Guess you use a different w/d method than this?

Awesome and thanks I'll give it a whirl :)
From: Ashaman88
withdrawitem(dpick,'dtm',28,['rag', 'ick'],[]);

replace the 28 with however many you want to withdraw. Just doing this on comp not sure if it compiles

Ashaman88

2013-03-05 16:22:55

From: Lisafishes
yet another type mismatch. Guess you use a different w/d method than this?

Awesome and thanks I'll give it a whirl :)


Yeah sorry I can do it once I get home, don't have simba to play with at work. If nobody tells you how before then I'll let you know. But no I normally just use withdraw

Le Jingle

2013-03-05 19:04:32

Asha had it right with the exception that, as I mentioned previousley, you can only have a string uptext.

For example, a string, is:

var
s : string;
begin
s := 'dragon flying purple eater';
writeln(s);
end.

whereas a TStringArray (the parameter that is not accepted as UpText for this function call) is:

var
sArr : TStringArray;
begin
sArr := ['hi', 'how', 'are', 'you'];
writeln(sArr);
end.

In the above examples, a sArr is a TStringArray, or an array of string type.
This is different from having a single string, s.

THUS!
When making the Banking procedure (for your original query), we can go about many ways, but two interesting ideas in particular:
1. Use a single string to match upText

procedure Banking;
var
DPick : Integer;
begin
DPick := DTMFromString('mbQAAAHicY2VgYMhmYmBIB+IaIE4E4iIgFmdkYOAAYkkgVgNiHiBmYGDCgjEBIxYMBgD4aAKv');
OpenBankQuiet('eb');
DepositAll;
WithdrawItem(DPick, 'dtm', 1, 'Dragon pickaxe', []);
FreeDTM(DPick);
end;

2. (loop through an array of string (aka a TStringArray)

procedure Banking;
var
DPick, i : Integer;
UpTexts : TStringArray;
begin
DPick := DTMFromString('mbQAAAHicY2VgYMhmYmBIB+IaIE4E4iIgFmdkYOAAYkkgVgNiHiBmYGDCgjEBIxYMBgD4aAKv');
OpenBankQuiet('eb');
DepositAll;

UpTexts := ['rag', 'ick', 'ragon', 'ickaxe', 'Dragon pickaxe'];

for i := 0 to high(UpTexts) do
if WithDrawItem(DPick, 'dtm', 1, UpTexts[i], []) then
break;

FreeDTM(DPick);
end;

Explanation:
In the first snippet, you look for the exact match, of a single string, s.
In the second snippet, you iterate through your array of string (multiple), or TStringArray, calling WithdrawItem with a new string value (indicated by the current index being iterated through within the for loop), testing it for that uptext.

In my opinion, I'd recommend either creating your own custom function based off of the second example, working in a TStringArray argument parameter. This could be implemented very similar to how the current withdrawItemEx function works, given the exception you change the internal line inside WithdrawItemEx (because WithDrawItem calls this), from if WaitUpText(UpText, 300) then to use the function, WaitUpTextMulti(S: TStringArray; Time: Integer).

Nonetheless, the original snippet I shared will still obtain the outcome you desired.

Cheers,
Lj

Ashaman88

2013-03-05 19:36:41

Lame why does include say array then ? Is it lies!?

Le Jingle

2013-03-05 19:39:59

From: Ashaman88
Lame why does include say array then ? Is it lies!?


Yes I guess it does (just realized that now that you point it out), so you were setup!! (just joking ofc :p ) You had it correct, given the information from the function description and the lack of access to the internal functionality of the function. ;)

Lisafishes

2013-03-05 20:15:41

Thankyou for that very informative answer, I do greatly appreciate the help, haven't played with scripting in many years, definately rusty.
From: Le Jingle
Asha had it right with the exception that, as I mentioned previousley, you can only have a string uptext.

For example, a string, is:

var
s : string;
begin
s := 'dragon flying purple eater';
writeln(s);
end.

whereas a TStringArray (the parameter that is not accepted as UpText for this function call) is:

var
sArr : TStringArray;
begin
sArr := ['hi', 'how', 'are', 'you'];
writeln(sArr);
end.

In the above examples, a sArr is a TStringArray, or an array of string type.
This is different from having a single string, s.

THUS!
When making the Banking procedure (for your original query), we can go about many ways, but two interesting ideas in particular:
1. Use a single string to match upText

procedure Banking;
var
DPick : Integer;
begin
DPick := DTMFromString('mbQAAAHicY2VgYMhmYmBIB+IaIE4E4iIgFmdkYOAAYkkgVgNiHiBmYGDCgjEBIxYMBgD4aAKv');
OpenBankQuiet('eb');
DepositAll;
WithdrawItem(DPick, 'dtm', 1, 'Dragon pickaxe', []);
FreeDTM(DPick);
end;

2. (loop through an array of string (aka a TStringArray)

procedure Banking;
var
DPick, i : Integer;
UpTexts : TStringArray;
begin
DPick := DTMFromString('mbQAAAHicY2VgYMhmYmBIB+IaIE4E4iIgFmdkYOAAYkkgVgNiHiBmYGDCgjEBIxYMBgD4aAKv');
OpenBankQuiet('eb');
DepositAll;

UpTexts := ['rag', 'ick', 'ragon', 'ickaxe', 'Dragon pickaxe'];

for i := 0 to high(UpTexts) do
if WithDrawItem(DPick, 'dtm', 1, UpTexts[i], []) then
break;

FreeDTM(DPick);
end;

Explanation:
In the first snippet, you look for the exact match, of a single string, s.
In the second snippet, you iterate through your array of string (multiple), or TStringArray, calling WithdrawItem with a new string value (indicated by the current index being iterated through within the for loop), testing it for that uptext.

In my opinion, I'd recommend either creating your own custom function based off of the second example, working in a TStringArray argument parameter. This could be implemented very similar to how the current withdrawItemEx function works, given the exception you change the internal line inside WithdrawItemEx (because WithDrawItem calls this), from if WaitUpText(UpText, 300) then to use the function, WaitUpTextMulti(S: TStringArray; Time: Integer).

Nonetheless, the original snippet I shared will still obtain the outcome you desired.

Cheers,
Lj