SRL Archive - MSI Suggestions

MSIOpenBank


Sir R. M8gic1an

2009-10-27 08:37:00

half me, half nauman


const
BankMethod_Fast = 1;
BankMethod_Quiet = 2:
BankMethod_Glass = 3;
BankMethod_NPC = 4;

Function MSI_OpenBank(Bank, tPin : String) : Boolean;
Var
Order: array of TIntegerArray;
BankArray : TStringArray;
ProcedureArray: TIntegerArray;
{ 1 = OpenBankFast; 2 = OpenBankQuiet; 3 = OpenBankGlass;
4 = OpenBankNPC and 5 = OpenBank.}
Mark, I : Integer;
Begin
BankArray := [Bank_VE, Bank_VW];
Order := [
[4, 1, 2, 3, 5],
[1, 2, 3, 4, 5]
];


For I := 0 To High(BankArray) Do
begin
ProcedureArray := BankArray[I];
for h:= 0 to High(ProcedureArray)
Begin
Mark := GetSystemTime + 10000 + Random(3000);
Case ProcedureArray[I] Of
BankMethod_Fast : While (Not OpenBankFast(Bank)) And (GetSystemTime < Mark) Do
Wait(1);
BankMethod_Quiet : While (Not OpenBankQuiet(Bank)) And (GetSystemTime < Mark) Do
Wait(1);
BankMethod_Glass : While (Not OpenBankGlass(Bank, False, True)) And (GetSystemTime < Mark) Do
Wait(1);
BankMethod_NPC : While (Not OpenBankNPC) And (GetSystemTime < Mark) Do
Wait(1);
Else
While (Not OpenBank(Bank, False, True)) And (GetSystemTime < Mark) Do
Wait(1);
End;
End;

If Not BankScreen And Not PinScreen Then Exit;
If PinScreen And (Length(tPin) > 1) Then
InPin(tPin);

Result := WaitFunc(@BankScreen, 200, 15000);
If Result Then
MSIDebug('MSI_OpenBank', 'Successfuly Opened The Bank - '+Bank,
Debug_SmallDetails)
Else
MSIDebug('MSI_OpenBank', 'Could NOT Open The Bank - '+Bank,
Debug_SmallDetails);
End;

~RM

Coh3n

2009-11-01 20:16:54

I could be wrong, but isn't it more efficient to do this:

H := High(BankArray);
For I := 0 To H Do
You also said you wanted to see constants being used everywhere. So why not use them in the "Order" array also. Even though the integers are explained like 5 lines up, I think it would still be more convenient. And, in my opinion, looks better. :p

Yeah, and you'll probably roll your eyes at me for saying this, but I absolutely hate it when people capitalize bold words. But, I know Naum likes to, so if you're going to do it, be consistent and capitalize (or not) all the words. :p I know you did half and Naum did half, but I'm just pointing it out.

You know I'm really picky when it comes to standards.:wowzers:

Other than that, it looks awesome. I was thinking about something like this when we started. I figured it would be a lot better to loop through all the opening bank options in case one fails. Much better this way.

Well done guys. :biggrin: