SamIWas Posted June 20, 2014 Share Posted June 20, 2014 (edited) 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 June 20, 2014 by SamIWas Quote Link to comment
Hippocode Posted June 20, 2014 Share Posted June 20, 2014 (edited) 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 June 20, 2014 by hippothamus Quote Link to comment
Pat Stanford Posted June 20, 2014 Share Posted June 20, 2014 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? Quote Link to comment
SamIWas Posted June 20, 2014 Author Share Posted June 20, 2014 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! Quote Link to comment
JBenghiat Posted June 27, 2014 Share Posted June 27, 2014 Sam, Take a look at ValidAngStr http://developer.vectorworks.net/index.php/VS:ValidAngStr It's much more robust in dealing with units indicators, etc. The same is true with ValidNumStr for dimension text. -Josh Quote Link to comment
SamIWas Posted June 27, 2014 Author Share Posted June 27, 2014 Str2Angle ended up working for me, but 'll take a look at the one you posted above as well. 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.