macoovacany Posted June 25, 2010 Share Posted June 25, 2010 {$DEBUG} {Vectorscript dies with assigning a user defined type from a Var array from within a procedure. Although I can expand the specific script I'm writing to avoid this situation, I though I mention this is as it appears to be a bug. } PROCEDURE TEST1; TYPE MyType = STRUCTURE f1 :REAL; f2 :REAL; END; VAR arrMyType : DYNARRAY[] of MyType; instMyType : MyType; PROCEDURE proc1(var procarrMyType :DYNARRAY[] of MyType; num:INTEGER); VAR instMyType: MyType; ind : INTEGER; BEGIN FOR ind := 1 to num DO BEGIN {********* VW crashed here *********} instMyType := procarrMyType[ind]; END; END; {Nothing to see here.} FUNCTION ARandomNumber :REAL; VAR ARndmNum :REAL; BEGIN ARndmNum := 10*random; ARndmNum := 10*ARndmNum + 10*random; ARndmNum := 10*ARndmNum + 10*random; ARandomNumber := ARndmNum; END; BEGIN allocate arrMyType[1..10]; arrMyType[1].f1 := ARandomNumber; arrMyType[1].f2 := ARandomNumber; proc1(arrMyType, 1) END; run(test1); Quote Link to comment
maarten. Posted August 8, 2010 Share Posted August 8, 2010 Indeed, thanks for the info. Although the above should also work, you can fix it by assigning every part of your defined type of Var to that Var, I had to do this in one of my scripts to solve it: instMyType.f1 := procarrMyType[ind].f1; instMyType.f2 := procarrMyType[ind].f2; Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.