Loading ...
Sorry, an error occurred while loading the content.
 

APPEND not obtaining current values

Expand Messages
  • joy8388608
    It seems at least some variables used in APPEND statements are not having their current values correctly obtained. Run the following clip in any document. It
    Message 1 of 3 , Jan 21 8:58 AM

      It seems at least some variables used in APPEND statements are not having their current values correctly obtained.


      Run the following clip in any document. It surrounds all vowels with '@' one replace at a time. The results are gathered using an Assign (Set) statement and with an APPEND statement. My results (NTP 7.1) are as follows. I had similar results with GetLineCount instead of GetTextSize.


      Can anyone verify\explain?


      Thank you,

      Joy



      SetMsg is Starting with 7128 characters in document

      After replacing a with @a@ we are left with 7976 characters in document

      After replacing e with @e@ we are left with 9228 characters in document

      After replacing i with @i@ we are left with 10010 characters in document

      After replacing o with @o@ we are left with 10924 characters in document

      After replacing u with @u@ we are left with 11348 characters in document


      AppendMsg is Starting with 7128 characters in document

      After replacing a with @a@ we are left with 11348 characters in document

      After replacing e with @e@ we are left with 11348 characters in document

      After replacing i with @i@ we are left with 11348 characters in document

      After replacing o with @o@ we are left with 11348 characters in document

      After replacing u with @u@ we are left with 11348 characters in document


      ^!Set %SetMsg%=Starting with ^$GetTextSize$ characters in document^%NL%

      ^!Set %AppendMsg%=Starting with ^$GetTextSize$ characters in document^%NL%


      ^!Replace "a" >> "@a@" WASIT

      ^!Set %SetMsg%=^%SetMsg%After replacing a with @a@ we are left with ^$GetTextSize$ characters in document^%NL%

      ^!Append %AppendMsg% After replacing a with @a@ we are left with ^$GetTextSize$ characters in document^%NL%


      ^!Replace "e" >> "@e@" WASIT

      ^!Set %SetMsg%=^%SetMsg%After replacing e with @e@ we are left with ^$GetTextSize$ characters in document^%NL%

      ^!Append %AppendMsg% After replacing e with @e@ we are left with ^$GetTextSize$ characters in document^%NL%


      ^!Replace "i" >> "@i@" WASIT

      ^!Set %SetMsg%=^%SetMsg%After replacing i with @i@ we are left with ^$GetTextSize$ characters in document^%NL%

      ^!Append %AppendMsg% After replacing i with @i@ we are left with ^$GetTextSize$ characters in document^%NL%


      ^!Replace "o" >> "@o@" WASIT

      ^!Set %SetMsg%=^%SetMsg%After replacing o with @o@ we are left with ^$GetTextSize$ characters in document^%NL%

      ^!Append %AppendMsg% After replacing o with @o@ we are left with ^$GetTextSize$ characters in document^%NL%


      ^!Replace "u" >> "@u@" WASIT

      ^!Set %SetMsg%=^%SetMsg%After replacing u with @u@ we are left with ^$GetTextSize$ characters in document^%NL%

      ^!Append %AppendMsg% After replacing u with @u@ we are left with ^$GetTextSize$ characters in document^%NL%


      ^!Jump Text_Start

      ^!Info [L]SetMsg is ^%SetMsg%^%NL%^%NL%AppendMsg is ^%AppendMsg%

    • flo.gehrke
      ... Joy, Please test... ^!SetDebug On ^!Set %Str%=AAA has ^$StrSize(AAA)$ characters^P ^!Append %Str%=BB has ^$StrSize(BB)$ characters ^!Info [L]^%Str%
      Message 2 of 3 , Jan 22 4:54 AM
        --- In ntb-clips@yahoogroups.com, <mycroftj@...> wrote:
        >
        > It seems at least some variables used in APPEND statements are
        > not having their current values correctly obtained.

        Joy,

        Please test...

        ^!SetDebug On
        ^!Set %Str%=AAA has ^$StrSize(AAA)$ characters^P
        ^!Append %Str%=BB has ^$StrSize(BB)$ characters
        ^!Info [L]^%Str%
        ^!ClearVariables

        and you'll see that '^!Append' doesn't evaluate the '^$StrSize$' function but assings it as TEXT. Cf the Clip Help on '^!Append':

        "Appends value to the content of %Variable%. This command also has the advantage of allowing assignments of function names and ^?{} prompts without causing these to be evaluated."

        So what appears as a bug to you is actually meant as an "advantage".

        In the clip above, the infobox finally ouputs...

        AAA has 3 characters
        BB has 2 characters

        because '^!Info', in contrast to '^!Append', is able to evaluate the function that was appended to '%Str%'.

        A work-around is to use another variable and to append its contents because a variable will be evaluated in this case:

        ^!SetDebug On
        ^!Set %Str%=AAA has ^$StrSize(AAA)$ characters^P
        ^!Set %AnotherStr%=BB has ^$StrSize(BB)$ characters
        ^!Append %Str%=^%AnotherStr%
        ^!Info [L]^%Str%
        ^!ClearVariables

        In the past, it has often been criticized that the Help on '^!Append' doesn't fully explain how that command works. Also it's still on the wish list to get an '^!Append' that evaluates any function too.

        Regards,
        Flo
      • joy8388608
        I completely missed that in the help file. Yes, that explains what I am seeing. An example in the help file would have stuck in my mind better. Thanks for
        Message 3 of 3 , Jan 23 3:01 PM

          I completely missed that in the help file. Yes, that explains what I am seeing. An example in the help file would have stuck in my mind better. Thanks for explaining and now I will remember. Time to scan my clips where I use APPEND for possible problems!


          Sorry about that and thanks.


          Joy

        Your message has been successfully submitted and would be delivered to recipients shortly.