Bixby Sayz Posted January 15, 2013 Share Posted January 15, 2013 Anyone want to explain to me why... This generates a runtime error: [sCAR]program New; {$DEFINE RS2} {$I OSI\OSI.scar} begin SetUpOSI(); try Exit; finally CloseBank(True); end; FreeOSI(); end. [/sCAR] But this works fine: [sCAR]program New; {$DEFINE RS2} {$I OSI\OSI.scar} begin SetUpOSI(); try ; finally CloseBank(True); end; FreeOSI(); end. [/sCAR] Note: Must be logged into RuneScape and bank (any bank) must be open for this to exhibit. Doesn't happen if bank is closed. I give up trying to figure it out. At least I have the satisfaction of knowing what is causing bizarre runtime errors every time I sit down to rewrite my scripts so I can work around it. The error only exhibits if Exit is called inside the try...finally. Everytime I start rewriting my scripts to make them work I get bizarre errors like this and spend weeks running in circles trying to figure out what the heck is going on. Eventually I give up in frustration and the scripts never get written. Quote Link to comment Share on other sites More sharing options...
LordJashin Posted January 15, 2013 Share Posted January 15, 2013 nvm yeah something on ur side i think Quote Link to comment Share on other sites More sharing options...
FHannes Posted January 15, 2013 Share Posted January 15, 2013 As far as I can tell, it should work, maybe it's a bug in the script engine... Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted January 15, 2013 Author Share Posted January 15, 2013 It's an obscure bug/issue that has driven me round the bend for ages. In this scaled down example I listed above: If the Exit statement is executed inside a try/finally and if (and only if) the bank screen is open I get a runtime error at line 1 (invalid opcode). If the bank is closed it runs fine. In my script I have a CloseBank(True) in the finally portion. If the Exit statement is called inside the try/finally and if (and only if) the bank screen is open it generates a runtime error (invalid range) in LoadTextTPA at the very first statement. (CloseBank calls BankScreen which calls FindTextTPAInTPA which calls LoadTextTPA). In trying to track this down I wrapped the entire contents of LoadTextTPA in a try/except. The error then occurs at the end of the proc outside the try/except. At this point I give up and decide to go do something more fun like slam my fingers repeatedly in a drawer. Quote Link to comment Share on other sites More sharing options...
LordJashin Posted January 15, 2013 Share Posted January 15, 2013 Lol, some of the text tpa functions, I've had problems with them before too, with errors sometimes. Someone else too I think has posted about this in the past. It probably has to do with an access error? Invalid range, so invalid pixel, or something... Try putting the text tpa functions in your script, and ripping them from OSI. Then Dissect the text tpa functions, with and without OSI maybe. GL Quote Link to comment Share on other sites More sharing options...
Janilabo Posted January 15, 2013 Share Posted January 15, 2013 I have started using try..except..finally..end;, because it seems like adding that except part there does fix some of the problems. Not sure if it will work with your problem, but at least give it a try? program New; {$DEFINE RS2} {$I OSI\OSI.scar} begin SetUpOSI(); try Exit; except WriteLn('There was an error..?'); finally CloseBank(True); end; FreeOSI(); end. -Jani Quote Link to comment Share on other sites More sharing options...
FHannes Posted January 15, 2013 Share Posted January 15, 2013 I get a runtime error at line 1 (invalid opcode). Definitely a bug in the engine. If you toss it on Mantis, I will give fixing it a stab. Quote Link to comment Share on other sites More sharing options...