honeyhoney
2015-02-15 15:29:19
Apparently there is no difference between
However, when using the first snippet of code I end up with access violations in the second iteration of the loop (below).
The second snippet works no problem.
Hopefully someone can explain the subtle(?) difference(s)?
exampleVar: exampleRecord = ['Bank chest we want to use', ['Bank', 'chest']];andexampleVar: exampleRecord;
exampleVar := ['Bank chest we want to use', ['Bank', 'chest']];However, when using the first snippet of code I end up with access violations in the second iteration of the loop (below).
The second snippet works no problem.
Hopefully someone can explain the subtle(?) difference(s)?
// Comment out line 26
// Uncomment line 27 and 79
program Test;
{$i AeroLib/AeroLib.simba}
const
STATE_A = 1;
STATE_B = 2;
type
tPointer = record
isProc: Boolean;
proc: procedure;
func: function: Boolean;
name: String;
end;
exampleRecord = record
name: String;
uptext: TStringArray;
end;
var
ptr: tPointer;
exampleVar: exampleRecord = ['Bank chest we want to use', ['Bank', 'chest']];
//exampleVar: exampleRecord;
function testFunc(input: exampleRecord): Boolean;
begin
if waitUpTextMulti(input.uptext, 500) then
exit(True);
end;
function getState(): Integer;
begin
if testFunc(exampleVar) then
exit(STATE_A)
else
exit(STATE_B);
end;
procedure aLoop();
begin
writeln('a loop');
end;
procedure bLoop();
begin
writeln('b loop');
end;
procedure loop();
begin
with ptr do
begin
case getState() of
STATE_A:
begin
name := 'state a';
isProc := true;
proc := @aLoop;
func := nil;
end;
STATE_B:
begin
name := 'state b';
isProc := true;
proc := [MENTION=61374]bloop[/MENTION];
func := nil;
end;
end;
end;
end;
begin
initAL();
//exampleVar := ['Bank chest we want to use', ['Bank', 'chest']];
while True do
begin
loop();
with ptr do
begin
if isProc then
proc()
else
func();
end;
end else
begin
Wait(5000);
end;
end.