I want to have a variable function return the length of a PV, it would be Module/AI1/PV. I want to use the size of the value as a way to modify some size and spacing for instance if the value is 1.01.. compared to 43,000 I will have different spacing needs. I can't seem to get an expression to return the value i'm looking for. I'm wondering if there is a method available like .length.
I'm using a number funciton with a Script Conversion Type, I'm passing Tag and Path to the function as strings. My script is something like:return DLSYS.Read(Tag + '/' + Path + '.CV').length
I don't know if i'm even in the ballpark here
In reply to TreyB:
Live Text Boxes/Datalinks aren't like iFix where the width of the text is what is being displayed. You pick the width you want to display and regardless if the value is too short, just right or too long...the width doesn't change.
You will need to add configuration of the width(s) to your GEM (if that is what you are doing) to define the width to show unfortunately because the width can't be updated at RunTime either (I've tried that...)
In reply to Matt Stoner:
Yes, i would add configuration for the position of the relative items, for instance an icon that sits to the left of the datalink (which is right justified) will move further to the right based on the length of the datalink. Not the length of the datalink itself, but the length of the data being returned. Here is what I'm doing at the moment. I have a variable that calculates the length as follows: let result = DLSYS.Read(Tag+'/'+Path+'.CV'); return result.Value; tag and path are Input strings to the function
I haven't yet begun to calculate the length using an object property because I can't yet get the value returned from this function
I have tested this by creating a datalink to display the returned value of this function. It is set as Numeric. I believe i followed the syntax regarding the Read function and the RtValue object. But, i'm not returning a value for the datalink to display and it is just giving me
OK, In the Function I used a single Input called "Scale" and when using this function I used DLSYS["MODULE/SCALE_PATH"] for this input. SCALE_PATH is FB/PARAMETER or whatever the path to get to the scale parameter to be used. Then using your logic above my function logic using this "Scale" input becomes: if (Scale.Value.Eu0 < 0) { return (Scale.Value.Eu100.toFixed(0).length + Scale.Value.DecimalPoint + 1); } else { return (Scale.Value.Eu100.toFixed(0).length + Scale.Value.DecimalPoint); } Note: that if you need the EUs for any reason that would be Scale.Value.Units
This is sounding like what I commented on earlier that you want to dynamically set the width of objects based on the database configuration...I played around with some of it but ended up just having the PV, EU, etc widths be a configurable width on the GEM and then do all the positioning based on those configuration items because the animations/scripts don't run at edit time so for the person configuring the GEM to know what it "might" look like at runtime it just seemed to be easier.
We have considered using a custom selector where you could choose the "option" and then you can add measurements to that selection (see below) and then link the object widths to those measurements...but with not fixed width font you have to find the "worse" case and use that width. Unfortunately I don't think you will find an "easy" way to satisfy everything (or you will spend a lot of time trying to get there and may never get to it).