Jump to content
FHannes

Debugging Common Issues

Recommended Posts

So you've been scripting and you run into an error... Don't panic. Most errors are very common and easy to solve.

 

Access Violation

This is the error you will probably encounter most. However, there can be any number of different causes for it. you should under normal circumstances always be able to find and resolve this error. If you think you did nothing wrong, check again, because you probably did, but the bugs can be tricky and hide well. A known cause for this error in SCAR is using unsafe calls to forms. Whenever you create a form and try to run it, you have to use the ThreadSafeCall method to do so.

 

Nullpointer Exception

A nullpointer exception is usually easy to track down. The error occurs when you try to use an uninitialized object.

[scar]var

obj: TObject;

begin

obj := nil;

WriteLn(obj.ToString);

end.[/scar]

 

Divide By Zero

Do I really have to explain this?

 

Cannot Allocate DIB Handle

Say what now? This is a bit of a tricky one. This error is generated when SCAR can no longer create a new bitmap in the memory. How does this happen? There's too many in there already. Make sure you use FreeBitmap to a destroy a bitmap in a script when you no longer need it. Also, create a bitmap only once, don't create bitmaps in a loop when it's always going to be the same bitmap. And again, FREE IT when you're done with it. SCAR automatically frees all bitmaps after it hsa ran, but it does not control what happens while the script is running, so it's up to you.

 

Floating Point Overflow

This exception is thrown when a floating point value exceeds the memory limit of the type.

[scar]var

e: Extended;

begin

e := 50000000;

e := Pow(e, e);

end.[/scar]

 

Invalid Float

This is thrown when you tryt o convert a string to a floating point number which has an incorrect format or doesn't contain a number.

[scar]var

e: Extended;

begin

e := StrToFloat('hey');

end.[/scar]

 

Invalid Floating Point Operation

This is probably an internal error in SCAR which might indicate a bug, report it with the bug tracker.

 

Other stuff

I'll add more to this.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...