$localRegex:="\\$[0-9_\\p{Letter}]+"  //Includes parameters. Assumes locals do 
not have spaces.

A simple way to ensure you are not matching within strings is to split the 
method into lines and then on each line collapse the strings so they are empty. 
You only need to do this on lines that have a "$". Here is a method to do this:


//Collapes all string constants in the code to "" prevent contents from 
matching simple regex scanning.

//$0 - Code with strings collapsed.
//$1 - Code.

C_TEXT($0;$1)

C_LONGINT($start;$end;$pos)
C_BOOLEAN($done)

$0:=$1

$end:=1

Repeat 
  $start:=Position("\"";$0;$end;*)
  If ($start>0)
    $pos:=$start+1
    Repeat 
      $end:=Position("\"";$0;$pos;*)
      Case of 
        : ($end<1)  //Unbalanced?
          $end:=Length($0)+1  //Kill all to the end.
          $done:=True
        : ($0[[$end-1]]="\\")  //Escaped quote.
          $done:=False
          $pos:=$end+1
        Else 
          $done:=True
      End case 
    Until ($done)
    $0:=Delete string($0;$start+1;$end-$start-1)
    $end:=$start+2
  End if 
Until ($start<1)


John DeSoi, Ph.D.


> On Apr 27, 2018, at 10:54 AM, Bob Miller via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> The "tough" issue for me is "how to identify a local variable":
> - it begins with a $
> - it may end with any of these characters: space, equals, semicolon, 
> colon, dash, left paren, left curly brace, end of line, or any arithmetic 
> or comparison operator
> - it is not fully enclosed in quotes; example: "$ ###,###.00" is a format, 
> not a local variable, but I'm ignoring EXECUTE ON SERVER, etc.

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to