Jump to content
Developer Wiki and Function Reference Links ×

Vectorscript/Record Format Math Problem


Recommended Posts

I have been beating my head for hours trying to figure out what is going on. Maybe I'm tired and missing something really stupid.

Okay, I have a record format,. Let's say it's named "samiwas". In that record format is a field named "X Rotation Offset". This field is set to number, with the format of angle with 2 decimal places (so that it appears as "45.00").

In my script, there is a variable xro, which is a REAL value. I have a line in the script that is written:

xro:=180+(GetRField(h,'samiwas','X Rotation Offset'));

This format gets an error saying "the operands are not of compatible types", even though both are numbers. I have to use a str2num procedure to get the script to compile, but when I do this, the result is always 180, no matter what value I put in the field.

Is this making any sense? Am I missing something very basic?

Edited by SamIWas
Link to comment

Is this making any sense? Am I missing something very basic?

In vectorscript you can't directly GET/SET int/real values from record/parameter fields.

The GET/SET procedure always works with STRINGS ( even for booleans).

This means you'll need to convert the result of GetRfield from string to int

xro:=180+Str2Num(GetRField(h,'samiwas','X Rotation Offset'));

If it keeps returning 180 make sure the name in the above function is correct.

Edited by hippothamus
Link to comment
One possibility on why the Str2Num function is not working properly could be that there is other text in the field as well as the number. Is there a degree sign or something similar?

Since this is an angle, maybe try Str2Angle instead of Str2Num?

The number field is set as angle, so maybe the degree symbol is coming in with it and messing it up. I thought I had tried it as a regular number too, but I'll try again. I didn't even see the Str2Angle command. I'll try that too and see what happens.

Thanks for the help, everyone!

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