Jump to content

Enforce Prototypes @ptnum


LaidlawFX

Recommended Posts

Hello,

So doing some clean up on my vex code in a wrangle and I turned on Enforce Prototypes to remove a bunch of the hacks to get the code setup. The one thing I can not find out a cleanup for is to replace @ptnum with a non @ function. 

Is the only way to declare it prior to the wrangle as another attribute? That just seems messy.  Even declaring before hands means you need @ptnum to source that attribute.

Thanks,

-Ben

Edited by LaidlawFX
@ptnum haunts
Link to comment
Share on other sites

Here is an example file of using @ptnum to source a point attribute that errors out when enforce Prototype is on.

int id = point(0,"id",@ptnum);

setpointattrib(0,"Cd", @ptnum,id);

Upstream of that I have an attribute create that does a basic.

i@id=@ptnum;

 

ptnum.hip

Link to comment
Share on other sites

11 hours ago, LaidlawFX said:

Here is an example file of using @ptnum to source a point attribute that errors out when enforce Prototype is on.


int id = point(0,"id",@ptnum);

setpointattrib(0,"Cd", @ptnum,id);

Upstream of that I have an attribute create that does a basic.


i@id=@ptnum;

 

ptnum.hip

Yeah in that case you need to declare @ptnum at the top. So:

int @ptnum;
int id = point(0,"id",@ptnum);

setpointattrib(0,"Cd", @ptnum,id);

Think of it as a key. If you write @ptnum further down, it will take a look to see if it's allowed to accept that. If it isn't declared, or if you make a typo (@ptnmu) it will error because it isn't allowed.

I don't think you can get rid of @ altogether, but you can add it to a variable to get rid of it further down:

int @ptnum;
int pointnum = @ptnum;

 

  • Thanks 1
Link to comment
Share on other sites

Thanks for that. I just re-read what you said and that link you sent. Had to do a double check and it follows the pattern in cvex, too. It's been a long time since I looked at vex like this.

cvex
obj_geo1_pointvop1(int ptnum = 0;
        export int Cd = 0)
{
    // Code produced by: bind1
    Cd = ptnum;
}

Thanks again.

Found the declaring part in the docs again, too.

https://www.sidefx.com/docs/houdini/vex/snippets.html#declare

Edited by LaidlawFX
Found another link for declaring for future people.
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...