Bri Posted August 11, 2021 Share Posted August 11, 2021 The short version of what I'm trying to accomplish is to show the absolute value of a coordinate in a data tag (for instance, if the coordinate is -20'0" on the X axis, I just want it to say 20'0"). I'm essentially dimensioning from a 0,0 point and the direction (which would be expressed as positive/negative) is irrelevant. I do this in worksheets with a simple if/else formula: =IF((XCOORDINATE>0), XCOORDINATE, -(XCOORDINATE)) because I haven't run across an easier way. Some spreadsheets have an ABS(value) function, but I don't see this in VW. My questions are: - is it possible to put a a formula such as this in a data tag? I haven't had any luck, it just displays as text, but maybe I don't have the right syntax. - either way, is there an easier way to get the figure I'm looking for? Thanks, Brian Quote Link to comment
Pat Stanford Posted August 11, 2021 Share Posted August 11, 2021 XCOORDINATE does not exist in Data Tags, but the object insertion point of the Data Tag does using a tag of #IPX#. IF/Then is weird in Data Tags. It uses a formula of <Value_If_True>@<The_Condition>:<Value_If_False>. Don't use any spaces between things. So I think the following will give you what you want: -#IPX#@#IPX#<0:#IPX# Thank you to @michaelk for helping me refine this syntax. Ask again if you need more help. 3 Quote Link to comment
Sam Jones Posted August 11, 2021 Share Posted August 11, 2021 1 hour ago, Pat Stanford said: IF/Then is weird in Data Tags. It uses a formula of <Value_If_True>@<The_Condition>:<Value_If_False>. Don't use any spaces between things. You're kidding me. Quote Link to comment
Pat Stanford Posted August 11, 2021 Share Posted August 11, 2021 That is the only format I have been able to make work in VW2021. Quote Link to comment
Sam Jones Posted August 11, 2021 Share Posted August 11, 2021 I'm sure your right, but that sort of syntax is supposed to entice users who are avoiding using vectorscript, python, or marionette? It seems like they have given users access to a tool that they will use to fashion user requested labeling functionality. I am consistently impressed by users who dig in to create their own custom solutions, so perhaps there will be a plethora of user data tag solutions. It's easier for me to deal with vs. I wonder why they didn't try to stay consistent with worksheet syntax. 2 Quote Link to comment
Pat Stanford Posted August 12, 2021 Share Posted August 12, 2021 My guess is that this is the syntax used by whatever parser they are using under the hood and they didn't have time to wrap it in something better. This is actually very close to a standard Python if then construct which could be like: <Value if True>?<The Condition>:<Value if False> They probably changed to @ because the question mark was being used for something else. I believe/hope that it will be better in future versions, but at least it works in VW2021. And I completely agree with you that it is almost unusable for anyone not familiar with programming. Or having a friend on the forum who likes digging into obscure questions. 😉 3 Quote Link to comment
David Poiron Posted August 12, 2021 Share Posted August 12, 2021 Thanks for this Pat. I've been trying to do an IF/THEN in a data tag for a while and this works for me too! Now if I can only round off a calculated value to one decimal place in a data tag...any thoughts there? Quote Link to comment
Sam Jones Posted August 12, 2021 Share Posted August 12, 2021 40 minutes ago, Pat Stanford said: This is actually very close to a standard Python For me, another reason to stay with VS. Quote Link to comment
LarryO Posted August 12, 2021 Share Posted August 12, 2021 Out of curiosity only. If the condition cannot be evaluated does the parser capture for processing either the true or false value?; or throw an error dialog or a null value? The way it is written reminds me of a process without error checking. If read left to right it would capture the false value into the register then process the condition where by a true result would overwrite the register value with the next value to the left. (APL processed code lines left to right) Where as Pascal or Basic+ type of formatting will have the condition for evaluation first resulting in selectively choosing to ignore either the first value or the second value and do a single write to the register. Hmmm. Overly simplified of course. hehe Quote Link to comment
Pat Stanford Posted August 12, 2021 Share Posted August 12, 2021 I have no idea what is going on under the hood or if there is any error checking. Since the middle has to be a boolean value, I would assume that there will always be a result from the operator. But will it default to True or False? Quote Link to comment
michaelk Posted August 12, 2021 Share Posted August 12, 2021 It changed in 2019 or 2020. @ used to be not a reserved character. I'm looking through the help documents and I can't find it anymore, but there used to be 2 syntaxes for IF/THEN/ELSE statements in data tags. The only one that I ever got to work (and even that only recently) is result@logic_statement:else Like Pat said: No spaces to make it more readable 🙂. I'm not positive about double quotation marks or single quotation marks. I know I successfully use #record#.#field#@#record#.#field#<>'':#record#.#differentfield# The single quotes next to each other recognize a blank field, but all the examples of returning specific text uses double quotes. 1 Quote Link to comment
Eliot Hartzler Posted August 12, 2021 Share Posted August 12, 2021 @michaelk If it's bugging you 😋, there's a link to the help documents regarding this topic in the following post, but, as we've all mentioned, the @ syntax is the one that works. 1 Quote Link to comment
michaelk Posted August 12, 2021 Share Posted August 12, 2021 Thanks @Eliot Hartzler. It was bugging me! Quote Link to comment
Bri Posted August 12, 2021 Author Share Posted August 12, 2021 Thank you all - and I swear I searched the help before asking. I see it now and it works (using the @ version). Quote Link to comment
Josh_M_Gill Posted 21 hours ago Share Posted 21 hours ago On 8/11/2021 at 5:45 PM, Pat Stanford said: -#IPX#@#IPX#<0:#IPX# If I wanted to adjust precision to "1", the expression would be #IPX##doc dist_0_1#. how do I incorporate this into the if/then variable? Quote Link to comment
Pat Stanford Posted 19 hours ago Share Posted 19 hours ago Guessing, but I would bet that you have to put the formatting part (#doc Dist_0_1#) AFTER BOTH of the #IPX# sections. 1 Quote Link to comment
Josh_M_Gill Posted 8 hours ago Share Posted 8 hours ago That worked! Thanks Pat 🙂 X= -#IPX##doc dist_0_1#@#IPX#<0:#IPX##doc dist_0_1# Y= -#IPY##doc dist_0_1#@#IPY#<0:#IPY##doc dist_0_1# 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.