Macro anyone?

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

Macro anyone?

4D Tech mailing list
Anyone have a macro (or anything else)
which will sort method editor text?

I have a method which I am using to keep track of other methods I have
worked on.
I would like to sort this list. Currently I am copy/pasting in excel
and sorting and copy/pasting back

Would prefer not to do this.

Thanks
Chip
---------------
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]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Macro anyone?

4D Tech mailing list
Hi Chip,

Here's the pseudocode:

Create a 4d method mySortMethod
GET MACRO PARAMETER highlighted text
Parse returned text to text array with substring using CR as delimiter
Sort array
Rebuild method text from array: For(1;$element;size of array())+CR
SET MACRO PARAMETER highlighted text

Then in your macros.xml v2 file:

<macro
        name="Sort method lines"
        in_toolbar="true"
        in_menu="true"
        type_ahead="false"
        version="2"
        >
        <text><method>mySortMethod</method></text>
 </macro>

HTH



On Tue, May 30, 2017 at 8:04 AM, Chip Scheide via 4D_Tech <
[hidden email]> wrote:

> Anyone have a macro (or anything else)
> which will sort method editor text?
>
> I have a method which I am using to keep track of other methods I have
> worked on.
> I would like to sort this list. Currently I am copy/pasting in excel
> and sorting and copy/pasting back
>
> Would prefer not to do this.
>
> Thanks
> Chip
> ---------------
> 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]
> **********************************************************************




--
Bob Finnerty
Exodus Software
**********************************************************************
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: Macro anyone?

4D Tech mailing list
In reply to this post by 4D Tech mailing list
This gets the text from and to the clipboard


$text:=Get text from pasteboard

ARRAY TEXT($array;0)
$delim:=Char(Carriage return)
$len:=Length($text)
$lenDel:=Length($delim)-1
$pos1:=1
$pos2:=Position($delim;$text;*)

While ($pos2>0)
$SS:=Substring($text;$pos1;$pos2-1)
APPEND TO ARRAY($array;$SS)
$pos1:=$pos2+$pos1+$lenDel
$pos2:=Position($delim;Substring($text;$pos1;$len);*)
End while
APPEND TO ARRAY($array;$SS)

SORT ARRAY($array)
$text:=""
$size:=Size of array($array)
For ($i;1;$size)
$text:=$text+$array{$i}+$delim
End for
SET TEXT TO PASTEBOARD($text)

Keith - CDI

> On May 30, 2017, at 10:04 AM, Chip Scheide via 4D_Tech <[hidden email]> wrote:
>
> Anyone have a macro (or anything else)
> which will sort method editor text?
>
> I have a method which I am using to keep track of other methods I have
> worked on.
> I would like to sort this list. Currently I am copy/pasting in excel
> and sorting and copy/pasting back
>
> Would prefer not to do this.
>
> Thanks
> Chip
> ---------------
> 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]
> **********************************************************************

**********************************************************************
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: Macro anyone?

4D Tech mailing list
Keith & Bob
Thanks!

On Tue, 30 May 2017 11:01:11 -0500, Keith Culotta via 4D_Tech wrote:

> This gets the text from and to the clipboard
>
>
> $text:=Get text from pasteboard
>
> ARRAY TEXT($array;0)
> $delim:=Char(Carriage return)
> $len:=Length($text)
> $lenDel:=Length($delim)-1
> $pos1:=1
> $pos2:=Position($delim;$text;*)
>
> While ($pos2>0)
> $SS:=Substring($text;$pos1;$pos2-1)
> APPEND TO ARRAY($array;$SS)
> $pos1:=$pos2+$pos1+$lenDel
> $pos2:=Position($delim;Substring($text;$pos1;$len);*)
> End while
> APPEND TO ARRAY($array;$SS)
>
> SORT ARRAY($array)
> $text:=""
> $size:=Size of array($array)
> For ($i;1;$size)
> $text:=$text+$array{$i}+$delim
> End for
> SET TEXT TO PASTEBOARD($text)
>
> Keith - CDI
>
>> On May 30, 2017, at 10:04 AM, Chip Scheide via 4D_Tech
>> <[hidden email]> wrote:
>>
>> Anyone have a macro (or anything else)
>> which will sort method editor text?
>>
>> I have a method which I am using to keep track of other methods I have
>> worked on.
>> I would like to sort this list. Currently I am copy/pasting in excel
>> and sorting and copy/pasting back
>>
>> Would prefer not to do this.
>>
>> Thanks
>> Chip
>> ---------------
>> 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]
>> **********************************************************************
>
> **********************************************************************
> 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]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Macro anyone?

4D Tech mailing list
Chip:

Refer to my posting re. Workspace in the "favorite tricks" thread.

--
Douglas von Roeder
949-336-2902

On Tue, May 30, 2017 at 9:48 AM, Chip Scheide via 4D_Tech <
[hidden email]> wrote:

> Keith & Bob
> Thanks!
>
> On Tue, 30 May 2017 11:01:11 -0500, Keith Culotta via 4D_Tech wrote:
> > This gets the text from and to the clipboard
> >
> >
> > $text:=Get text from pasteboard
> >
> > ARRAY TEXT($array;0)
> > $delim:=Char(Carriage return)
> > $len:=Length($text)
> > $lenDel:=Length($delim)-1
> > $pos1:=1
> > $pos2:=Position($delim;$text;*)
> >
> > While ($pos2>0)
> > $SS:=Substring($text;$pos1;$pos2-1)
> > APPEND TO ARRAY($array;$SS)
> > $pos1:=$pos2+$pos1+$lenDel
> > $pos2:=Position($delim;Substring($text;$pos1;$len);*)
> > End while
> > APPEND TO ARRAY($array;$SS)
> >
> > SORT ARRAY($array)
> > $text:=""
> > $size:=Size of array($array)
> > For ($i;1;$size)
> > $text:=$text+$array{$i}+$delim
> > End for
> > SET TEXT TO PASTEBOARD($text)
> >
> > Keith - CDI
> >
> >> On May 30, 2017, at 10:04 AM, Chip Scheide via 4D_Tech
> >> <[hidden email]> wrote:
> >>
> >> Anyone have a macro (or anything else)
> >> which will sort method editor text?
> >>
> >> I have a method which I am using to keep track of other methods I have
> >> worked on.
> >> I would like to sort this list. Currently I am copy/pasting in excel
> >> and sorting and copy/pasting back
> >>
> >> Would prefer not to do this.
> >>
> >> Thanks
> >> Chip
> >> ---------------
> >> 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]
> >> **********************************************************************
> >
> > **********************************************************************
> > 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]
> **********************************************************************
>
**********************************************************************
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: Macro anyone?

4D Tech mailing list
In reply to this post by 4D Tech mailing list
The final 100 yards using Bob Finnerty's suggestion - (Hey! Finnerty. Glad to see still working with 4D!)



1. Here is the code (non-pseudo) that you place in your project as a Project Method: here called SortMethod. Paste this text in and save it.


  // PROJECT METHOD: SortMethod
  // ----------------------------------------------------
  // CREATED: 05/31/17, 17:40:22 Robert Livingston
  // DESCRIPTION: Alphabetically sorts the lines of a method when used in a Macro
  // Call SortMethod from the Macro dropdown in the Method Editor

C_TEXT ($inputText)
C_TEXT ($sortedText)

C_LONGINT ($FULL_METHOD_TEXT)
$FULL_METHOD_TEXT:=1
GET MACRO PARAMETER ($FULL_METHOD_TEXT;$inputText)

  // take the input text and turn it into a Text array
ARRAY TEXT ($axLineCode;0)
C_LONGINT ($positionDelimiter)
C_TEXT ($element)

Repeat

  $positionDelimiter:=Position (Char (Carriage return);$inputText)

  If ($positionDelimiter=0)

    If ($inputText#"")  // don't gratuitously add a blank line to the array at the end
      APPEND TO ARRAY ($axLineCode;$inputText)
    End if

  Else

    $element:=Substring ($inputText;1; ($positionDelimiter-1))
    $inputText:=Substring ($inputText;$positionDelimiter+1)

    If ($element#"")  // filter out blank lines
      APPEND TO ARRAY ($axLineCode;$element)
    End if

  End if

Until ($positionDelimiter=0)

SORT ARRAY ($axLineCode)

C_LONGINT ($nElement;$totElement)
$totElement:=Size of array ($axLineCode)

If ($totElement>0)

  $sortedText:=$axLineCode{1}

  For ($nElement;2;$totElement)
    $sortedText:=$sortedText+Char (Carriage return)+$axLineCode{$nElement}
  End for

Else

  $sortedText:="ALERT("+Char (Double quote)+"Method passed has no content"+Char (Double quote)+")"

End if

SET MACRO PARAMETER ($FULL_METHOD_TEXT;$sortedText)



2. Here is the Macro that you have in your Macro v2 folder (you can just add these lines to any existing Macros.xml that you may have.


<macro name="SortMethod" version="2">
    <text>
        <method>SortMethod</method>
    </text>
</macro>


*    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    

To use:

– Be in the method that you wish to sort.

– Call the Macro -- SortMethod -- from the macro dropdown list that is part of the method editor.

– Boom, the method is sorted.


*    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    

It can be a little disconcerting if you accidentally apply this Macro to some random method. It will instantly turn into an alphabetized mess. Fortunately, the Undo Command will restore its original state.



> On May 30, 2017, at 8:39 AM, Bob Finnerty via 4D_Tech <[hidden email]> wrote:
>
> Hi Chip,
>
> Here's the pseudocode:
>
> Create a 4d method mySortMethod
> GET MACRO PARAMETER highlighted text
> Parse returned text to text array with substring using CR as delimiter
> Sort array
> Rebuild method text from array: For(1;$element;size of array())+CR
> SET MACRO PARAMETER highlighted text
>
> Then in your macros.xml v2 file:
>
> <macro
>        name="Sort method lines"
>        in_toolbar="true"
>        in_menu="true"
>        type_ahead="false"
>        version="2"
>>
>        <text><method>mySortMethod</method></text>
> </macro>
>
> HTH
>
> --
> Bob Finnerty
> Exodus Software
> **********************************************************************
> 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]
> **********************************************************************
>
> On Tue, May 30, 2017 at 8:04 AM, Chip Scheide via 4D_Tech <
> [hidden email]> wrote:
>
>> Anyone have a macro (or anything else)
>> which will sort method editor text?
>>
>> I have a method which I am using to keep track of other methods I have
>> worked on.
>> I would like to sort this list. Currently I am copy/pasting in excel
>> and sorting and copy/pasting back
>
>

**********************************************************************
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: Macro anyone?

4D Tech mailing list
Yeah.. I can imagine !

:)

On Wed, 31 May 2017 20:28:40 -0700, Robert Livingston wrote:
> – Boom, the method is sorted.
>
>
> *    *    *    *    *    *    *    *    *    *    *    *    *    *    
> *    *    *    *    *    *    *    *    *    *    *    *    *    
>
> It can be a little disconcerting if you accidentally apply this Macro
> to some random method. It will instantly turn into an alphabetized
> mess. Fortunately, the Undo Command will restore its original state.
---------------
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]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Macro anyone?

4D Tech mailing list
In reply to this post by 4D Tech mailing list
Hi Bob,

Thanks to the (absurd) federal EHR requirements, my old Patient Manager EHR
has become  a dinosaur, but I've been slowly reworking it from 2004 to v16,
as I still need some of its functionality (I working for CHI as a specialty
inpatient hospitalist).

Good to see your still in the 4D world as well

Bob Finnerty

On Wed, May 31, 2017 at 8:28 PM, Robert Livingston <[hidden email]>
wrote:

> The final 100 yards using Bob Finnerty's suggestion - (Hey! Finnerty. Glad
> to see still working with 4D!)
>
>
>
> 1. Here is the code (non-pseudo) that you place in your project as a
> Project Method: here called SortMethod. Paste this text in and save it.
>
>
>   // PROJECT METHOD: SortMethod
>   // ----------------------------------------------------
>   // CREATED: 05/31/17, 17:40:22 Robert Livingston
>   // DESCRIPTION: Alphabetically sorts the lines of a method when used in
> a Macro
>   // Call SortMethod from the Macro dropdown in the Method Editor
>
> C_TEXT ($inputText)
> C_TEXT ($sortedText)
>
> C_LONGINT ($FULL_METHOD_TEXT)
> $FULL_METHOD_TEXT:=1
> GET MACRO PARAMETER ($FULL_METHOD_TEXT;$inputText)
>
>   // take the input text and turn it into a Text array
> ARRAY TEXT ($axLineCode;0)
> C_LONGINT ($positionDelimiter)
> C_TEXT ($element)
>
> Repeat
>
>   $positionDelimiter:=Position (Char (Carriage return);$inputText)
>
>   If ($positionDelimiter=0)
>
>     If ($inputText#"")  // don't gratuitously add a blank line to the
> array at the end
>       APPEND TO ARRAY ($axLineCode;$inputText)
>     End if
>
>   Else
>
>     $element:=Substring ($inputText;1; ($positionDelimiter-1))
>     $inputText:=Substring ($inputText;$positionDelimiter+1)
>
>     If ($element#"")  // filter out blank lines
>       APPEND TO ARRAY ($axLineCode;$element)
>     End if
>
>   End if
>
> Until ($positionDelimiter=0)
>
> SORT ARRAY ($axLineCode)
>
> C_LONGINT ($nElement;$totElement)
> $totElement:=Size of array ($axLineCode)
>
> If ($totElement>0)
>
>   $sortedText:=$axLineCode{1}
>
>   For ($nElement;2;$totElement)
>     $sortedText:=$sortedText+Char (Carriage return)+$axLineCode{$nElement}
>   End for
>
> Else
>
>   $sortedText:="ALERT("+Char (Double quote)+"Method passed has no
> content"+Char (Double quote)+")"
>
> End if
>
> SET MACRO PARAMETER ($FULL_METHOD_TEXT;$sortedText)
>
>
>
> 2. Here is the Macro that you have in your Macro v2 folder (you can just
> add these lines to any existing Macros.xml that you may have.
>
>
> <macro name="SortMethod" version="2">
>     <text>
>         <method>SortMethod</method>
>     </text>
> </macro>
>
>
> *    *    *    *    *    *    *    *    *    *    *    *    *    *    *
> *    *    *    *    *    *    *    *    *    *    *    *
>
> To use:
>
> – Be in the method that you wish to sort.
>
> – Call the Macro -- SortMethod -- from the macro dropdown list that is
> part of the method editor.
>
> – Boom, the method is sorted.
>
>
> *    *    *    *    *    *    *    *    *    *    *    *    *    *    *
> *    *    *    *    *    *    *    *    *    *    *    *
>
> It can be a little disconcerting if you accidentally apply this Macro to
> some random method. It will instantly turn into an alphabetized mess.
> Fortunately, the Undo Command will restore its original state.
>
>
>
> > On May 30, 2017, at 8:39 AM, Bob Finnerty via 4D_Tech <
> [hidden email]> wrote:
> >
> > Hi Chip,
> >
> > Here's the pseudocode:
> >
> > Create a 4d method mySortMethod
> > GET MACRO PARAMETER highlighted text
> > Parse returned text to text array with substring using CR as delimiter
> > Sort array
> > Rebuild method text from array: For(1;$element;size of array())+CR
> > SET MACRO PARAMETER highlighted text
> >
> > Then in your macros.xml v2 file:
> >
> > <macro
> >        name="Sort method lines"
> >        in_toolbar="true"
> >        in_menu="true"
> >        type_ahead="false"
> >        version="2"
> >>
> >        <text><method>mySortMethod</method></text>
> > </macro>
> >
> > HTH
> >
> > --
> > Bob Finnerty
> > Exodus Software
> > **********************************************************************
> > 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]
> > **********************************************************************
> >
> > On Tue, May 30, 2017 at 8:04 AM, Chip Scheide via 4D_Tech <
> > [hidden email]> wrote:
> >
> >> Anyone have a macro (or anything else)
> >> which will sort method editor text?
> >>
> >> I have a method which I am using to keep track of other methods I have
> >> worked on.
> >> I would like to sort this list. Currently I am copy/pasting in excel
> >> and sorting and copy/pasting back
> >
> >
>
>


--
Bob Finnerty
*Exodus Software*
**********************************************************************
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...