Jump to content

Convert PIO Dimensions field value to actual numbers


Recommended Posts

looking to figure out how to convert the value of a Dimensions field. if i put in 10'0" in the print out is "1e01". how do i turn that into inches? 

 

 

ANWSER:

length_sci_note = vs.GetRField(PIO_handle, recname, "Length from Shackle")
length = vs.ValidNumStr(length_sci_note)[1]
vs.AlrtDialog(length)

 

Edited by Jayme McColgan
Solved my issue
Link to comment

That is an actual number, but it is being displayed as scientific notation. 1e01 is one way of writing 1 x 10^1 = 1 x 10 = 10 feet. 

 

But I know that is not your real question, which is how do you format it as Feet and Inches.  For that we probably need some sample code to work from. It should take the display format from the Document Unit Settings. If that is not set to scientific notation I don't have any other good ideas.

 

Other than I have never seen this problem with Vectorscript. 😉

Link to comment

Unfortunately, I see this all the time in Vectorscript; it will be the result of GetRField() on parameters defined as a dimension type.  The first thing to try is to take the number returned by GetRField() and turn it into a string with the Num2StrF() command.  What you have to store or preserve will depend on the arithmetic you need to do with the value.  I usually have to do the following:

 

VAR

     paramVal : STRING;

     paramNumVal : REAL;

     numDisplay : STRING;

     ok : BOOLEAN;

 

BEGIN

     paramVal := GetRField();

     ok  :=  ValidNumStr(paramVal, paramNumVal);

     numDisplay := Num2StrF(paramNumVal);

END;

 

I haven't found a simpler way but perhaps Josh or Pat can come up with something.

Link to comment
4 hours ago, Pat Stanford said:

That is an actual number, but it is being displayed as scientific notation. 1e01 is one way of writing 1 x 10^1 = 1 x 10 = 10 feet. 

 

But I know that is not your real question, which is how do you format it as Feet and Inches.  For that we probably need some sample code to work from. It should take the display format from the Document Unit Settings. If that is not set to scientific notation I don't have any other good ideas.

 

Other than I have never seen this problem with Vectorscript. 😉

one day you will come to the dark side! don't be scared just because our code based shares the name with a snake! lol *hiss**hiss**hiss* thanks for all the help @Pat Stanford as i try and wrap my head around the VW Scripting workflow!

Link to comment

Oh, I have been to the dark side. VBA for relatively complicated Excel macros and dBase for some complicated database applications. Those are far more dark side.

 

But I draw the limit at white space delimiters.

 

I would rather learn C and go to the SDK than break my eyes and brain trying to decide if I have things lined up properly.  The language itself I don't mind, but white space delimiters, even in the 1990s was one of the stupidest design decisions I have EVER seen.

Link to comment

i have been meaning to take a look into the SDK and see what i can use it for. i've been thinking of moving my license key checker to the SDK so it can run every so often instead of it being at the beginning of every PIO i make... maybe one day. also want to move my auto plugin update to some sort of background task instead of it being a menu command. got some people at work who really slack at keeping up to date with plugins and such. 

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