Re: Macro to check that local variables are declared in a method?

2018-04-28 Thread Nigel Greenlee via 4D_Tech
Bob

I have a component that declares all my variables(not just locals). Locals were 
simple-everything else was hard. It relies on you having a definable format(i.e 
type is at end or demarked by _ ) and having consistent(even if varying) way of 
identifying type (e.g _at is is array text and _atxt is array text  and _t is 
txt and _txt is text. if it finds something that it does not understand it 
decalres it(commented out) as //C_UNKNOWN($_somethingprobablyatypo_xxx).

The definitions are editable and you set them up when you put the component 
it(it installs a couple of methods in your code and does not alter your 
structure so taking it back out does not break your code). I have been using it 
on several systems for over a year with differing decalration systems and so 
far it has been very good(it does some other things besides decalring 
variables..will auto put a header on your methods and auto put code in if you 
want it..i have it put $_l_FormEvent:=Form Event ..Case of..:($_L_formevent=on 
clicked)..end case in all new object methods for example).

You would be welcome to have a copy to try out-i would welcome feedback on 
whether it can work for others. (if you do want to try it let me know your 
naming convention so I can confirm it will work with the code).-i have versions 
for V14,15,AND 16.

Nigel Greenlee




> On 27 Apr 2018, at 11:54, Bob Miller via 4D_Tech <4d_tech@lists.4d.com> wrote:
> 
> Hello,
> 
> Has anyone created a macro to check a method to make sure all its local 
> variables are declared?
> 
> I've thought about undertaking such a thing, but as it probably involves 
> getting into regular expressions, I've been looking forward to doing this 
> with some dread.
> 
> If anyone has done this already and is willing to share, I'd be much 
> obliged!
> 
> 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.
> 
> I'm probably making a mountain out of a molehill, but hey, that's what 
> this list is for - to let people show me exactly that.  I appreciate it.
> 
> 
> Bob Miller
> Chomerics, a division of Parker Hannifin Corporation
> 
> 
> ll
> "PLEASE NOTE: The preceding information may be confidential or privileged. It 
> only should be used or disseminated for the purpose of conducting business 
> with Parker. If you are not an intended recipient, please notify the sender 
> by replying to this message and then delete the information from your system. 
> Thank you for your cooperation."
> **
> 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
> **

**
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
**

Re: Macro to check that local variables are declared in a method? [Solved]

2018-04-28 Thread John Baughman via 4D_Tech

> On Apr 27, 2018, at 12:17 PM, Bob Miller via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> RE> I don?t have a macro for you, but I?m curious to know why asking the 
> compiler to check the syntax isn?t enough?

Another reason is that for some usages of a local variable starting with one of 
the 16 R releases, the compiler ignores the variable wrt typing and 4D will 
throw an unknown variable type error at run time. Prior versions of 4D had no 
problem with these undeclared variables. Case in point

   SET QUERRY DESTINATION (Into variable;$found)

These are not that hard to find and fix, but yet another good reason to have a 
means to easily find undeclared locals

John

Sent from my iPad
John Baughman
Kailua,Hawaii
john...@hawaii.rr.com
**
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
**

Re: Macro to check that local variables are declared in a method? [Solved]

2018-04-28 Thread Lee Hinde via 4D_Tech
I was looking at that string and testing it a bit more (after it’s been 
canonized, of course.)

Underscores aren't captured in the original, which a lot of us use -  e.g.e, 
$somestring_t

This captures those:  \$[_a-zA-Z0-9]*   All I did was add the underscore 
between the [].

What I’m not sure how to do (well, I’m unwilling to spend the time, because 
WTH) is capture spaces within a variable name.

**
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
**

Re: [Tip?] Test path name and Posix

2018-04-28 Thread Arnaud de Montard via 4D_Tech

> Le 27 avr. 2018 à 19:29, Chip Scheide via 4D_Tech <4d_tech@lists.4d.com> a 
> écrit :
> 
> Test Path Name FAILS (file/folder does not exist) if given a POSIX 
> formatted path.

Normal behaviour, doc says "You can pass either a relative or absolute 
pathname, expressed in the syntax of the current system."  :-(
I like posix… For example I store paths inside resource folder and "complete" 
with this:

//Fs_resourcePath (posix_t {;checkIfExist_b) -> txt
//$0 current system absolute path
//$1 posix path relative to ressource folder
//   ex: "pictures/4statesbuttons/myButton.png"
//   ex: "pictures/4statesbuttons/"
//$2 optional : if passed and true, $0 will be empty
//   if folder or document doesn't exist
C_TEXT($0)
C_TEXT($1)
C_BOOLEAN($2)
$path_t:=Convert path system to POSIX(Get 4D folder(Current Resources 
folder))+$1
$path_t:=Convert path POSIX to system($path_t)
If (Count parameters>1)
If ($2)  //must exist
If (Test path name($path_t)<0)  //not a folder or a document
$path_t:=""
End if
End if
End if
$0:=$path_t
//_

-- 
Arnaud de Montard 



**
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
**