Oops!
I forgot this bit:
// Threadsafe?
METHOD GET ATTRIBUTES($MethodNames_at{$CurrentMethod_i};$Attributes_o)
$ThreadSafe_t:=OB Get($Attributes_o;"preemptive")
Case of
: ($ThreadSafe_t="capable")
$ThreadSafeSection_t:="\rPREEMPTIVE\r"
: ($ThreadSafe_t="incapable")
$ThreadSafeSection_t:="\rCOOPERATIVE\r"
Else
$ThreadSafeSection_t:="\INDIFFERENT\r"
End case
Then just include $ThreadSafeSection_t in your comments somewhere.
Regards,
Wayne
[image: --]
Wayne Stewart
[image: http://]about.me/waynestewart
<http://about.me/waynestewart>
On 19 April 2017 at 16:32, Wayne Stewart <[email protected]> wrote:
> Hi,
>
> With all this talk about comments, I thought I would throw another 2¢ into
> the conversation.
>
> This is also useful for non components.
>
> I love the fact that 4D now displays tooltips over your methods. However,
> sometimes the first few lines of the method are not too helpful.
>
> If you have anything written in the comments section of the explorer these
> are displayed instead (everyone should TURN OFF the automatic comment
> feature immediately).
>
> And if your code is in a component that is compiled, then only the
> Explorer Comments are displayed.
>
> Recently in Foundation I wrote a method to create comments based on the
> method header comments found there. This was only possible because of the
> stick discipline Dave Batton used when creating these headers.
>
> Does anyone else miss Dave B?
>
> Anyway, to wind things up, why not write a 4D Method that reads those
> headers and creates the Explorer comments for you?
>
> Use a macro to create the header so it conforms to the pattern as you
> start each header and then Bob's your uncle.
>
> Here is what I use, you can modify it for your header pattern perhaps.
>
> NB. Make sure your code starts below the header. I use 4D Pop macro to
> declare my locals but the macro puts them at the first empty line, I just
> need to reposition them to below the header manually.
>
>
>
> Example Macro:
>
> <macro name="FHead">
> <text>// ----------------------------------------------------
> // Project Method: <method_name/> --> ReturnType
>
> // Description
>
> // Access: Shared
>
> // Parameters:
> // $1 : Type : Description
> // $x : Type : Description (optional)
>
> // Returns:
> // $0 : Type : Description
>
> // Created by Wayne Stewart (<date format="9"/>)
> // [email protected]
> // ----------------------------------------------------
> </text>
> </macro>
>
>
>
>
> Code:
>
> // ----------------------------------------------------
> // Project Method: FW_WriteComments {(Method Name; Do not use)}
>
> // This method will create documentation comments
> // it is based on the assumption that you format your
> // method header comments in the same manner as Foundation
> // The first paramater is just used to trigger the method
> // starting in a new process, you should not pass this parameter
>
> // Access: Shared
>
> // Parameters:
> // $1 : Text : Either pass "" to do all methods or a specific method
> name
> // $2 : Longint : Do not use this
>
> // Created by Wayne Stewart
> // ----------------------------------------------------
>
> If (False) // Copy this to your Compiler Method!
> C_TEXT(FW_WriteComments ;$1)
> C_LONGINT(FW_WriteComments ;$2)
> End if
>
> C_TEXT($1)
> C_LONGINT($2;$ProcessID_i;$StackSize_i;$NumberOfMethods_
> i;$CurrentMethod_i;$Position_i)
> C_TEXT($MethodCode_t;$FirstChars_t;$MethodName_t)
>
> ARRAY TEXT($MethodNames_at;0)
> ARRAY TEXT($MethodCode_at;0)
> ARRAY TEXT($MethodComments_at;0)
>
> $StackSize_i:=0
>
> If (Count parameters=2)
>
> METHOD GET PATHS(Path project method;$MethodNames_at)
>
> $MethodName_t:=$1
>
> If (Length($MethodName_t)>0) // A method name or prefix has been
> specified
>
> $NumberOfMethods_i:=Count in array($MethodNames_at;$MethodName_t)
>
> If ($NumberOfMethods_i=1) // exactly one match (use this specific
> method)
> ARRAY TEXT($MethodNames_at;0)
> APPEND TO ARRAY($MethodNames_at;$MethodName_t)
> Else
>
> $NumberOfMethods_i:=Size of array($MethodNames_at)
> For ($CurrentMethod_i;$NumberOfMethods_i;1;-1) // Go Backwards
> If ($MethodNames_at{$CurrentMethod_i}=($MethodName_t+"@"))
> Else
> DELETE FROM ARRAY($MethodNames_at;$CurrentMethod_i)
> End if
>
> End for
>
> End if
>
>
>
> End if
>
> $NumberOfMethods_i:=Size of array($MethodNames_at)
>
> METHOD GET CODE($MethodNames_at;$MethodCode_at)
>
> ARRAY TEXT($MethodComments_at;$NumberOfMethods_i)
>
> For ($CurrentMethod_i;1;$NumberOfMethods_i)
> $MethodCode_t:=$MethodCode_at{$CurrentMethod_i}
>
> $Position_i:=Position("comment added and reserved by
> 4D.\r";$MethodCode_t)
>
> $MethodCode_t:=Substring($MethodCode_t;$Position_i+Length("comment
> added and reserved by 4D.\r"))
>
> $MethodCode_t:=Replace string($MethodCode_t;"\r // Access:
> Shared\r";"")
> $MethodCode_t:=Replace string($MethodCode_t;" //
> ----------------------------------------------------\r";"")
> $MethodCode_t:=Replace string($MethodCode_t;"//
> ----------------------------------------------------\r";"")
>
> $MethodCode_t:=Replace string($MethodCode_t;" // Project Method: ";"")
> $MethodCode_t:=Replace string($MethodCode_t;"// Project Method: ";"")
>
> $MethodCode_t:=Replace string($MethodCode_t;" // ";"")
> $MethodCode_t:=Replace string($MethodCode_t;"// ";"")
>
> $Position_i:=Position("Created by";$MethodCode_t)
>
> $MethodCode_t:=Substring($MethodCode_t;1;($Position_i-3))
>
> $FirstChars_t:=Substring($MethodCode_t;1;2)
> While ($FirstChars_t="\r\r")
> $MethodCode_t:=Substring($MethodCode_t;2)
> $FirstChars_t:=Substring($MethodCode_t;1;2)
> End while
>
> $MethodComments_at{$CurrentMethod_i}:=$MethodCode_t
>
>
> End for
>
> METHOD SET COMMENTS($MethodNames_at;$MethodComments_at)
>
> Else
>
> If (Count parameters=1)
> $MethodName_t:=$1
> Else
> $MethodName_t:=""
> End if
>
> // This version allows for any number of processes
> // $ProcessID_i:=New Process(Current method name;$StackSize_i;Current
> method name;0)
>
> // On the other hand, this version allows for one unique process
> $ProcessID_i:=New process(Current method name;$StackSize_i;Current
> method name;$MethodName_t;0;*)
>
> RESUME PROCESS($ProcessID_i)
> SHOW PROCESS($ProcessID_i)
> BRING TO FRONT($ProcessID_i)
> End if
>
>
> Finally,
>
> Here is an example comment from Cannon's excellent Object module, I
> rewrote the headers so I it would work:
>
> OBJ_Get_Real (Object; Key) --> Real
>
> Returns a Real value.
>
> Access: Shared
>
> Parameters:
> $1 : Object : The Object we are accessing
> $2 : Text : The key we are accessing
>
> Returns:
> $0 : Real
>
> And:
>
> OBJ_Set_Real (Object; Key; Real)
>
> Creates or updates a key with the passed in value
>
> Access: Shared
>
> Parameters:
> $1 : Object : The Object we are accessing
> $2 : Text : The key we are accessing
> $3 : Real : The Real to set
>
> Regards,
>
> Wayne
>
>
> --
> Wayne Stewart
>
>
>
**********************************************************************
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:[email protected]
**********************************************************************