Get Table Field Pointer

This is like 4D's GET POINTER except that it's specifically written to work with tables and fields instead of variables. You can pass a table name with or without brackets, but a field needs to be in the [Table]Field format.
  ` GetTableFieldPointer
  ` Returns a pointer to the table or field pointer string passed
  ` $1 - Table or Field name - Table: Orders or [Orders]; Field: [Orders]Address
  ` Written by Tom Dillon



If ($PointerStr#"")
  While (Substring($PointerStr;1;1)<"A")  ` Gets rid of leading junk
  End while 
  If ($PointerStr#"")
    If ($PointerStr[[1]]="[")  ` Beginning of a table in [Table] format
    End if 
    $RBPos:=Position("]";$PointerStr)  ` Ending of a table in [Table] format
    If ($RBPos>0)  ` Position of right bracket indicates that [Table] exists
      If (Length($PointerStr)>$RBPos)  ` There's more than just a table. A field exists.
      End if 
    Else   ` No ] so it's just a table
    End if   ` ($RBPos>0)
    For ($i;1;Count tables)
      $Name:=Table name($i)
      If ($Name=$TableStr)
        $i:=Count tables
      End if   ` ($i;1;Count tables)
    End for   ` ($i;1;Count tables)
    If (($IsField) & ($TableNum#0))
      For ($i;1;Count fields($TableNum))
        $Name:=Field name($TableNum;$i)
        If ($Name=$FieldStr)
          $i:=Count fields($TableNum)
        End if 
      End for   ` ($i;1;Count fields($TableNum))
    End if   ` (($IsField) & ($TableNum#0))
  End if   ` ($PointerStr # "")
End if   ` ($PointerStr # "")

If ($IsField)
End if