Jump to content
Developer Wiki and Function Reference Links ×

Vectorscript dies with assigning a user defined type from a Var array...


Recommended Posts

{$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);

Link to comment
  • 1 month later...

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;

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...