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

Is text selected?

Expand Messages
  • Jean-François Colas
    Hello list, Searching for a method of determining if I have text selected or not when launching a script, I wrote the piece of code below. I found out that,
    Message 1 of 4 , Dec 14, 2011
    • 0 Attachment
      Hello list,

      Searching for a method of determining if I have text selected or not
      when launching a script, I wrote the piece of code below. I found out
      that, when I selected nothing, the "^&" element seems to contain two
      characters ASCII 4, everytime. Is it a feature or just coincidence?

      Is there a more conventional way to determine if text is selected?

      Thanks,
      J.-F.

      H="Study Selection"
      ^!set Sel=^&
      ^!set LenSel=^$StrSize(^%Sel%)$
      ^!Set Result=Len: ^%lenSel%^tSel: '^%Sel%'^p
      ^!Set i=0
      :boucle
      ^!Inc %i%
      ^!Set %Result%=^%Result%^%i%^t: ^$CharToDec(^$StrCopy(^%Sel%;^%i%;1)$)$^p
      ^!if ^%i% < ^%lenSel% boucle
      ^!info ^%result%
      ^!goto end
    • Jean-François Colas
      Hi again, ... Sorry, for that part, I simply forgot ^$GetSelection$
      Message 2 of 4 , Dec 14, 2011
      • 0 Attachment
        Hi again,

        Le 14/12/2011 15:53, Jean-François Colas a écrit :
        > Hello list,
        >
        > Searching for a method of determining if I have text selected or not
        > when launching a script, I wrote the piece of code below. I found out
        > that, when I selected nothing, the "^&" element seems to contain two
        > characters ASCII 4, everytime. Is it a feature or just coincidence?
        >
        > Is there a more conventional way to determine if text is selected?
        >
        Sorry, for that part, I simply forgot ^$GetSelection$

        > Thanks,
        > J.-F.
        >
        > H="Study Selection"
        > ^!set Sel=^&
        > ^!set LenSel=^$StrSize(^%Sel%)$
        > ^!Set Result=Len: ^%lenSel%^tSel: '^%Sel%'^p
        > ^!Set i=0
        > :boucle
        > ^!Inc %i%
        > ^!Set %Result%=^%Result%^%i%^t: ^$CharToDec(^$StrCopy(^%Sel%;^%i%;1)$)$^p
        > ^!if ^%i%< ^%lenSel% boucle
        > ^!info ^%result%
        > ^!goto end
        >
        >
        >
        > ------------------------------------
        >
        > Fookes Software: http://www.fookes.com/
        > NoteTab website: http://www.notetab.com/
        > NoteTab Discussion Lists: http://www.notetab.com/groups.php
        >
        > ***
        > Yahoo! Groups Links
        >
        >
        >
      • Sheri
        The current selection should be retrieved with ^$GetSelection$ and the selection size should be tested with ^$GetSelSize$ Caret-ampersand is the text that was
        Message 3 of 4 , Dec 14, 2011
        • 0 Attachment
          The current selection should be retrieved with ^$GetSelection$ and the selection size should be tested with ^$GetSelSize$

          Caret-ampersand is the text that was preselected at the time a clip was started.

          Regards,
          Sheri
        • flo.gehrke
          ... ^!IfFalse ^$GetSelSize$ Next Else Skip_2 ^!Prompt This clip requires a selection. ^!Goto End ^!Info The size of the selection is: ^$GetSelSize$ characters
          Message 4 of 4 , Dec 14, 2011
          • 0 Attachment
            --- In ntb-clips@yahoogroups.com, Jean-François Colas <jfcolas@...> wrote:
            >
            > Is there a more conventional way to determine if text is selected?

            ^!IfFalse ^$GetSelSize$ Next Else Skip_2
            ^!Prompt This clip requires a selection.
            ^!Goto End
            ^!Info The size of the selection is: ^$GetSelSize$ characters

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