Page 1 of 5 1234 ... LastLast
Results 1 to 10 of 45

Thread: Can't use !i in strings

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2017
    Location
    Belgium
    Posts
    102

    Default Can't use !i in strings

    Code:
    Send Info_Box "p {color: red !important}" "p {color: red !important}"
    Click image for larger version. 

Name:	exclaproblem.PNG 
Views:	43 
Size:	6.3 KB 
ID:	13387

    The compiler changes the !i to a 0. Why? It's in a string, it's not part of the code.
    Windows & web.

    Code:
    Send Info_Box "p {color:red !1 !3 !Important; }" "p {color:red !1 !3 !Important; }"
    This one doesn't even compile.

    Point is, these global variables/macro things shouldn't be evaluated when they're in a string.
    Real world usecase was setting a CssText property in chilkat.

  2. #2

    Default Re: Can't use !i in strings

    Nick,

    Welcome, you just reached the advanced level for DataFlex

    Joking aside, this is a long long time issue and is never going to be fixed AFAICT.
    It is inherently part on how things work.

    See:
    http://www.dataaccess.com/kbasepubli...ArticleID=1236

    --
    Wil

  3. #3
    Join Date
    Oct 2017
    Location
    Belgium
    Posts
    102

    Default Re: Can't use !i in strings

    Wil,

    Thanks for that KB article, Date Created 2000 .. Okay guess we'll just have to keep using concatenation then.
    I just still can't wrap my head around why this behavior is also used in strings but eh, whatever..

    Just another day in the life of a DF programmer

  4. #4
    Join Date
    Oct 2017
    Location
    Belgium
    Posts
    102

    Default Re: Can't use !i in strings

    https://www.dataaccess.com/KBasePubl...ArticleID=1237
    According to this KB article there was a problem with "//" in strings that got fixed in VDF 7...

    So uh, yeah..

  5. #5
    Join Date
    Feb 2009
    Location
    Hengelo, Netherlands
    Posts
    9,138

    Default Re: Can't use !i in strings

    Yeah, but that is a complete other thing.

    The <compilervar> (!<letter>[<letter>]) is part of the design and should work this way. It is not a bug or a design flaw.

    It is like complaining that the name of an XML element may not start with "xml" (https://www.w3schools.com/xml/xml_elements.asp)...
    Regards,
    Data Access Worldwide
    Vincent Oorsprong

  6. #6
    Join Date
    Oct 2017
    Location
    Belgium
    Posts
    102

    Default Re: Can't use !i in strings

    Okay I understand that it's not a bug, but it's still a rather weird quirk.

    For your comparison, I don't agree. The fact that dataflex complains about something in a string is not the same thing as starting an XML element name with "xml".

    For example: the C preprocessor does not touch strings. So dataflex saying "oh hey you can't use that combo of characters in a string" is something abnormal in my eyes.
    Last edited by WWGT; 10-Jan-2020 at 03:55 AM.

  7. #7
    Join Date
    Feb 2009
    Location
    Hengelo, Netherlands
    Posts
    9,138

    Default Re: Can't use !i in strings

    DataFlex isn't saying you cannot use the compiler variables in a string. It does not complain about something in a string, it is supporting it and needed in the language/compiler.

    For example if you use Direct_Input one of the situations lead to:
    Code:
    DIRECT_INPUT ('!1:' + string(!2)) !3 !4 !5 !6 !7 !8 !9
    as you can see the !1 is used in a literal and needs to be replaced/subsituted by the first parameter of the command.

    Another example:
    Code:
    !A [] $100 |CS"!1:!q"
    Could it be done differently? Probably, but this is part of DataFlex since the beginning and changing will break existing code which is not what most people want.
    Regards,
    Data Access Worldwide
    Vincent Oorsprong

  8. #8
    Join Date
    Oct 2017
    Location
    Belgium
    Posts
    102

    Default Re: Can't use !i in strings

    Thanks for that example, I understand now this not something you'd want to tackle when it doesn't provide any real benefits.

  9. #9
    Join Date
    Apr 2016
    Posts
    3

    Default Re: Can't use !i in strings

    Even though nothing will be changed I still think it's bad design.
    A developer might use be using a secret key in the source code:
    Get ComUnlockComponent "ZaPlXoKm0!1Fq1" to iRetval
    This is not a real key but I hope you get my point.

  10. #10
    Join Date
    Feb 2009
    Posts
    4,839

    Default Re: Can't use !i in strings

    QWERTY is a bad design ..... if you want to type quickly .... would you like that to change
    Success consists of going from failure to failure without loss of enthusiasm - Winston Churchill

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •