SRL Archive - Scripting Help

Random Access violation


TomTop

2015-03-06 12:45:47

Hey,

I don't know why, but my script keeps throwing my an access violation error, yet it doesn't tell me where -.-"

Error: Access violation
Compiling failed.

What should I do?

Turpinator

2015-03-06 12:50:52

You should post your code so we can look for the issue.

TomTop

2015-03-06 12:57:06

From: Turpinator
You should post your code so we can look for the issue.


The code is rather private, a project I've been working on for the past 3 months.
I'd prefer if you could list some common errors, or maybe explain why it isn't telling my a line.

slacky

2015-03-06 13:25:16

Edit: Didn't notice that it failed on compilation.

the bank

2015-03-06 13:26:45

Access Violation is due to Lape. Not that Lape is causing it, but Lape has terrible error output, and just about any error will just cause an "access violation".

Pascal Script is much more intuitive in that way. Unless you've written a lot of lape style shit, try just switching interpreters to get a better idea of your error.

That is, or just share your code. Private code is fine, just mean you'll have to find the error yourself and we won't be able to help in anyway.

Olly

2015-03-06 14:10:41

From: slacky
Normally it means you are reading from/writing to some location (in memory) which you do not have permission to access.. Usually an array where you are trying to access something out of bounds.
Lape doesn't catch such out-of-range errors, but it can crash because of it (but doesn't have to).
For exmaple:

var
myArr:TIntegerArray;
i:Int32;
begin
SetLength(myArr,1);
for i:=10 to 4000 do
begin
myArr[i] := 5; //may or may not crash (it doesn't have to crash but it can)

if i mod 50 = 0 then WriteLn('Out of range, but still no crash: ', i); //print every 50
end;
end;
PS: Careful when you test it (save everything unsaved), Simba usually crash after running this (a few times).


It's failing at compiling isn't it? It must be that infinite loop it gets stuck in..

TomTop

2015-03-06 15:14:38

I have found the error, it was a stupid mistake, I put a double dot (:) for a case statement.


case random(2) of:
1: doActions();
2: reLog();
end;

I removed the : and it worked.

The Mayor

2015-03-06 15:16:26

From: TomTop
I have found the error, it was a stupid mistake, I put a double dot (:) for a case statement.


case random(2) of:
1: doActions();
2: reLog();
end;

I removed the : and it worked.


But it will never reLog() ;)

TomTop

2015-03-06 15:41:01

From: The Mayor
But it will never reLog() ;)


What do you mean?

Turpinator

2015-03-06 15:55:52

From: TomTop
What do you mean?


random(2) = 0 or 1

The Mayor

2015-03-06 15:56:33


program new;
begin
while true do writeLn(random(2));
end.