Jump to content

Print an array element for debugging


Alexandre

Recommended Posts

Hi everyone !

I'm learning VEX (from CGwiki and Entagma) and I don't understand why the result of the following code is 0 whereas it should be 3... what did I misunderstand ?

int myarray[] = {2, 3, 4, 5};
int foo = myarray[1];
printf("%i \n",i@foo);

Thanks !

Alexandre

 

 

odforce_forum.JPG

Link to comment
Share on other sites

Another question which is a step further... but still low level

I want to access to a specific float attribute called d (related to a distance), I have tried attrib, point, pointattrib... I don't understand how to access to the nth value of d. Moreover I don't understand what mean the integer "&success" in the help function

In the example in attachment I would expect to get 1.49176 instead of 30 times "0.0000"

thanks !

Alexandre

odforce_forum2.JPG

Link to comment
Share on other sites

You should give up using prints with vex, just use the spreadsheet as your print out. There is no need to fetch the point value of @d from the point that you are running over. Just use @d. Vex is a sand box. when you enter the wrangle, the information about points is made available to the wrangle, kind of like a copy. You can operate upon those entries, then when you exit the wrangle internal housekeeping remaps everything to make the output work correctly. This prevents you from performing certain operations typical in a top-down programming language. It also prevents you from messing up indicies.

Try using two wrangle, one to add new points and the other to review or revise those points.

You are trying to print @d for point #1.

Try...

if(@ptnum==1) print("%02d\n",@d);

You should not ignore the success flag either. Pass a valid variable, not 0.

Also I don't think primuv returns a point that you can just pass to addpoint. It returns the value at the UV coordinate. This would cause all the other operations on that point to be suspect. Your getting 30 zeros because the pointattrib is failing, you are not examining success and a zero is returned just as the documentation states.

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.
Note: Your post will require moderator approval before it will be visible.

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