Author Topic: Begin Condition ("Text" If Statement) Allows Colons  (Read 1968 times)

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 291
  • Upstanding Lunatic
    • My AVCS Homepage
Begin Condition ("Text" If Statement) Allows Colons
« on: May 11, 2018, 04:04:29 PM »
Is this an issue?
If I try to use a token in the Variable Name of an If Statement, integer/bool/etc., it will give a popup telling me I cannot do that because it uses a Colon symbol.  So I just assume the proper method is to set a temp variable from the token, then compare that, and it works just fine, as designed (see test 3 below).
EDIT:  Also, Test 2 -WILL- work if it is compared to anything but NOT SET... such as "contains" or "equals"



I assume that is a 'dummy check'  :P  But, I don't get that popup when I use a token/colon symbol in a Text based If Statement, and of course it doesn't work, but it lacks the warning popup of it's fellow variable types.  2-years-ago me would have had to hurdle that during a learning curve, and I wonder if it's an issue?

New people learning how to use advanced stuff like Conditions could run into this snag, and I assume that's why the other types have that popup warning.  Could not find anything specific in the manual about the use of (or not to use) Tokens in If Statements with regards to the first variable to be compared.

Example (of course, only the third test works but the first two throw no errors during creation):
Code: [Select]
//When I say:  Run Test Victor [1..3]
Set Text [~tb] to [Not Set]
Set Text [Builder_{TXT:~tb}_Module] to [Not Set]
//
// Test 1 - compare variable with token inside variable name
Begin Text Compare : [{CMDSEGMENT:1}] Equals '1'
    Begin Text Compare : [Builder_{TXT:~tb}_Module] Has Not Been Set
        Write '[Green] TEST 1 - Will not Work' to log
    End Condition - Exit when condition met
End Condition
//
// Test 2 - compare variable as complete token
Begin Text Compare : [{CMDSEGMENT:1}] Equals '2'
    Begin Text Compare : [{TXT:Builder_{TXT:~tb}_Module}] Has Not Been Set
        Write '[Green] TEST 2 - Will not Work' to log
    End Condition
End Condition
//
// Test 3 - convert variable with token in name to temp variable for comparison
Begin Text Compare : [{CMDSEGMENT:1}] Equals '3'
    Set Text [~tbm] to [Builder_{TXT:~tb}_Module]
    Begin Text Compare : [~tbm] Has Not Been Set
        Write '[Green] TEST 3 - Worked' to log
    End Condition
End Condition

**edit:  I should not that I am happy it DOES allow Tokens in Text based If Statements as this only fails in Not Set checks
« Last Edit: May 11, 2018, 04:12:05 PM by SemlerPDX »

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Begin Condition ("Text" If Statement) Allows Colons
« Reply #1 on: May 11, 2018, 04:09:53 PM »
Hi, there.

This is by design.  Text used to not allow colons, but due to demand, it was altered to be allowed.  The rest of the types do not have that functionality (yet).  I can't recall the exact reason, but it had something to do with parsing and performance when anything other than text was being accessed.  Thanks for the heads up!

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 291
  • Upstanding Lunatic
    • My AVCS Homepage
Re: Begin Condition ("Text" If Statement) Allows Colons
« Reply #2 on: May 11, 2018, 04:16:50 PM »
Thank you for the response!  That explains a lot!  Thanks