Method Header Strategies

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Method Header Strategies

4D Tech mailing list
From the conversation about converting images we saw this method header:


If (True)
  If (False)
  Begin SQL
  /*
  Name: UTIL_ConvertPICTs
  Path: UTIL_ConvertPICTs

  Purpose: Convert all PICT formatted images in the
  Picture Libraray to .PNG images

  The v13.2 or later 4D Pack Plugin must be installed to use this method

  */
  End SQL
  End if
  C_TEXT($MethodName_T)
  $MethodName_T:=Current method name
  //===================== Declare Variables ==================================
  //method_parameters_declarations
  //--------------------------------------------------------------------------------
  //method_wide_constants_declarations
  //--------------------------------------------------------------------------------
  //local_variable_declarations
  C_LONGINT($Ndx;$SOA;$RIS;$PictRef_L)
  C_TEXT($PictName_T)
  C_PICTURE($Pict_G)
  C_POINTER($Pict_P)
End if

I can suss two things out of this. One is the  "If (false)" bit at the top so you can do all kinds of things that break cross-referencing in the name of not running code.

In this case it’s ‘protecting’ a Begin/End SQL which is being used because the construct allows you just type things with out having to comment your comments out.

But, why wrap the whole thing in if (True)?


**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Method Header Strategies

4D Tech mailing list
My guess… So you can click the triangle and hide everything in the header?

> On Aug 9, 2017, at 4:11 PM, Lee Hinde via 4D_Tech <[hidden email]> wrote:
>
> But, why wrap the whole thing in if (True)?


Later,
Guy

--
Guy Algot, Solutions Specialist
Edmonton, Alberta
(780) 974-8538

hardware, installation, training, support, programming, internet
specializing in 4th Dimension
=-= =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"Microsoft is a cross between the Borg and the Ferengi. Unfortunately,
they use Borg to do their marketing and Ferengi to do their programming."
    -- Simon Slavin



**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Method Header Strategies

4D Tech mailing list
that's what I thought at first but then the "False" block already does that job.

> 2017/08/10 7:58、Guy Algot via 4D_Tech <[hidden email]> のメール:
> My guess… So you can click the triangle and hide everything in the header?




**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Method Header Strategies

4D Tech mailing list
In reply to this post by 4D Tech mailing list
I tried using that SQL trick for a while and ultimately abandoned it. I
really rely on the headers I create to remind me of what the method does
and what the params are at the top. All the long discussion, if any, comes
after that. I've always heard it is all stripped out when compiled so I
just don't worry about it.

Sometimes I use If(True) statements just to make the code easier to manage.
And I like break up long Case of statements with :(false) // ** some
comment or header here **

It's purely cosmetic but I like it.

On Wed, Aug 9, 2017 at 3:11 PM, Lee Hinde via 4D_Tech <[hidden email]>
wrote:

> From the conversation about converting images we saw this method header:
>
>
> If (True)
>         If (False)
>         Begin SQL
>         /*
>         Name: UTIL_ConvertPICTs
>         Path: UTIL_ConvertPICTs
>
>         Purpose: Convert all PICT formatted images in the
>         Picture Libraray to .PNG images
>
>         The v13.2 or later 4D Pack Plugin must be installed to use this
> method
>
>         */
>         End SQL
>         End if
>         C_TEXT($MethodName_T)
>         $MethodName_T:=Current method name
>          //===================== Declare Variables
> ==================================
>          //method_parameters_declarations
>          //----------------------------------------------------------
> ----------------------
>          //method_wide_constants_declarations
>          //----------------------------------------------------------
> ----------------------
>          //local_variable_declarations
>         C_LONGINT($Ndx;$SOA;$RIS;$PictRef_L)
>         C_TEXT($PictName_T)
>         C_PICTURE($Pict_G)
>         C_POINTER($Pict_P)
> End if
>
> I can suss two things out of this. One is the  "If (false)" bit at the top
> so you can do all kinds of things that break cross-referencing in the name
> of not running code.
>
> In this case it’s ‘protecting’ a Begin/End SQL which is being used because
> the construct allows you just type things with out having to comment your
> comments out.
>
> But, why wrap the whole thing in if (True)?
>
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************




--
Kirk Brooks
San Francisco, CA
=======================

*The only thing necessary for the triumph of evil is for good men to do
nothing.*

*- Edmund Burke*
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Method Header Strategies

4D Tech mailing list
In reply to this post by 4D Tech mailing list
The ‘false’ doesn’t cover the whole header.

> On Aug 9, 2017, at 5:35 PM, Keisuke Miyako via 4D_Tech <[hidden email]> wrote:
>
> that's what I thought at first but then the "False" block already does that job.
>
>> 2017/08/10 7:58、Guy Algot via 4D_Tech <[hidden email]> のメール:
>> My guess… So you can click the triangle and hide everything in the header?
>
>
>
>

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Method Header Strategies

4D Tech mailing list
In reply to this post by 4D Tech mailing list
the old "standard" of:
If (false)
  // block of comments
end if

is outdated for a variety of reasons
- it started because it made interpreted code faster - as the
interpreter would try to 'execute' each line of comment. This was on
Motorola 680xx/Intel x86 processors running at a few 10s to a few
hundred mhz.
- the if (false) construct breaks the current implementation of 4D's
method editor where the comments (until the first line of actual code)
are displayed as tool tips

(in case you did not know this last bit, as an example)

// My_method (text:username) -> longint : UserID
//code


in another method
/some code
my_method
    Tool tip: // My_method (text:username) -> longint : UserID

On Thu, 10 Aug 2017 00:35:57 +0000, Keisuke Miyako via 4D_Tech wrote:

> that's what I thought at first but then the "False" block already
> does that job.
>
>> 2017/08/10 7:58、Guy Algot via 4D_Tech <[hidden email]> のメール:
>> My guess… So you can click the triangle and hide everything in the header?
>
>
>
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************
---------------
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Loading...