Page 1 of 1

autoCode5 – the timesaver

Posted: Thu Sep 24, 2009 2:52 pm
by Otto
autoCode5 stays in foreground - you can copy & past during coding your local variables to
autoCode5 then press button local and autoCode5 adds the local definition automatically

Best regards,
Otto

Image

Image

Image

Code: Select all

#include "FiveWin.ch"
#include "TestMemo.ch"

//----------------------------------------------------------------------------//

function Main()

   local oDlg, oGet
   local cText   :=  ""   

   SET _3DLOOK ON

   DEFINE DIALOG oDlg RESOURCE "MEMOEDIT"  Title "autoCode5"

   REDEFINE GET oGet VAR cText MEMO ID ID_MEMO OF oDlg

   oGet:bGotFocus = { || oGet:SetSel( 0, 0 ),;
                         oGet:Goto( oGet:GetLineCount() ),;
                         __Keyboard( Chr( VK_END ) ) }

   REDEFINE BUTTON ID 4002 OF oDlg ACTION ( cText :=  Setlocal( cText ), oGet:refresh() )
    REDEFINE BUTTON ID 4001 OF oDlg ACTION ( cText := "" , oGet:refresh())
    
   ACTIVATE DIALOG oDlg CENTERED ON INIT ( SetWindowPos( oDlg:hWnd, -1, 0, 0, 0, 0, 3 )  )

return nil
//----------------------------------------------------------------------------//

function Setlocal( cText )
    local cTextNew  := "" 
    local cLine  := "" 
    local nFrom  := 0


      while nFrom < Len( cText )
         cLine = ExtractLine( cText, @nFrom )
         
         if UPPER(left(ALLTRIM(cLine),1)) =  "C"
            cTextNew := cTextNew + "local " + cLine + '  := "" ' + CRLF
         elseif UPPER(left(ALLTRIM(cLine),1)) =  "N"
            cTextNew := cTextNew + "local " + cLine + +  '  := 0' + CRLF
         else
            cTextNew := cTextNew + "local " + cLine + CRLF
         endif
         
         SysRefresh()
      end
 
return ( cTextNew )
//----------------------------------------------------------------------------//
rc-file

Code: Select all

#include "..\include\WinApi.ch"
#include "TestMemo.ch"

MEMOEDIT DIALOG DISCARDABLE 18, 18, 187, 113
STYLE WS_POPUP|DS_MODALFRAME|WS_CAPTION|WS_SYSMENU
CAPTION "MemoEditing"
FONT 8, "Arial"
BEGIN
  CONTROL "", 110, "Edit", ES_MULTILINE|ES_WANTRETURN|WS_VSCROLL|WS_BORDER|WS_TABSTOP, 4, 6, 180, 85
  CONTROL "Clear", 4001, "Button", WS_TABSTOP, 52, 96, 45, 15
  CONTROL "local", 4002, "Button", WS_TABSTOP, 4, 96, 45, 15
END

Re: autoCode5 – the timesaver

Posted: Sat Oct 17, 2009 8:49 pm
by Antonio Linares
Otto,

Thanks! :-)

Re: autoCode5 – the timesaver

Posted: Sun Oct 18, 2009 12:40 am
by toninhofwi
Very interesting, thank you.

Toninho.

Re: autoCode5 – the timesaver

Posted: Tue Mar 30, 2010 8:09 am
by Otto
AuoCod5 - Smallest Toolbox for Fivewin

... now with new functionality

You can now easily reformat your code.

Best regards,
Otto


Image

Code: Select all

#include "FiveWin.ch"

//----------------------------------------------------------------------------//

function Main()

   local oDlg, oGet
   local cText   :=  ""   

   SET _3DLOOK ON

   DEFINE DIALOG oDlg RESOURCE "MEMOEDIT"  Title "autoCode5"

   REDEFINE GET oGet VAR cText MEMO ID 110 OF oDlg

   oGet:bGotFocus = { || oGet:SetSel( 0, 0 ),;
                         oGet:Goto( oGet:GetLineCount() ),;
                         __Keyboard( Chr( VK_END ) ) }
    
    
    REDEFINE BUTTON ID 4003 OF oDlg ACTION ( cText := f_format( cText ), oGet:refresh() )
   REDEFINE BUTTON ID 4002 OF oDlg ACTION ( cText := Setlocal( cText ), oGet:refresh() )
    REDEFINE BUTTON ID 4001 OF oDlg ACTION ( cText := "" , oGet:refresh())
    
   ACTIVATE DIALOG oDlg CENTERED ON INIT ( SetWindowPos( oDlg:hWnd, -1, 0, 0, 0, 0, 3 )  )

return nil
//----------------------------------------------------------------------------//

function Setlocal( cText )
    local cTextNew  := "" 
    local cLine  := "" 
    local nFrom  := 0


      while nFrom < Len( cText )
         cLine = ExtractLine( cText, @nFrom )
         
         if UPPER(left(ALLTRIM(cLine),1)) =  "C"
            cTextNew := cTextNew + "local " + cLine + '  := "" ' + CRLF
         elseif UPPER(left(ALLTRIM(cLine),1)) =  "N"
            cTextNew := cTextNew + "local " + cLine + +  '  := 0' + CRLF
         else
            cTextNew := cTextNew + "local " + cLine + CRLF
         endif
         
         SysRefresh()
      end
 
return ( cTextNew )
//----------------------------------------------------------------------------//

function f_format( cText )
    local cTextNew  := cText 

        cTextNew :=  STRTRAN(cTextNew, "*", " * " )
        cTextNew :=  STRTRAN(cTextNew, "-", " - " )
        cTextNew :=  STRTRAN(cTextNew, " - >", "->" )
        
        cTextNew :=  STRTRAN(cTextNew, ":=", " := " )
        cTextNew :=  STRTRAN(cTextNew, "(", "( " )
        cTextNew :=  STRTRAN(cTextNew, ")", " )" )
        
        cTextNew :=  STRTRAN(cTextNew, "[", "[ " )
        cTextNew :=  STRTRAN(cTextNew, "]", " ]" )
        
        cTextNew :=  STRTRAN(cTextNew, ",", ", " )
        cTextNew :=  STRTRAN(cTextNew, " ,", "," )
        
        cTextNew :=  STRTRAN(cTextNew, "  " , " " )
        cTextNew :=  STRTRAN(cTextNew, "   " , " " )
        
        cTextNew :=  STRTRAN(cTextNew, " ,", "," )
        
        cTextNew :=  STRTRAN(cTextNew, "(  )", "()" )
        
        SysRefresh()

return ( cTextNew )
//----------------------------------------------------------------------------//
 
rc-file

Code: Select all

#include "..\include\WinApi.ch"
#include "TestMemo.ch"

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US

MEMOEDIT DIALOG DISCARDABLE 18, 18, 187, 113
STYLE WS_POPUP|DS_MODALFRAME|WS_CAPTION|WS_SYSMENU
CAPTION "MemoEditing"
FONT 8, "Arial"
{
  CONTROL "", 110, "Edit", ES_MULTILINE|ES_WANTRETURN|WS_VSCROLL|WS_BORDER|WS_TABSTOP, 4, 6, 180, 85
  CONTROL "Clear", 4001, "Button", WS_TABSTOP, 136, 96, 45, 15
  CONTROL "local", 4002, "Button", WS_TABSTOP, 4, 96, 45, 15
  CONTROL "Format", 4003, "Button", WS_TABSTOP, 60, 96, 50, 14
}

 

Re: autoCode5 – the timesaver

Posted: Thu Apr 22, 2010 10:49 pm
by Otto
AutoCode5 with a new feature
Sometimes during designing a new dialog/window I add values to the coordinates.
Now AutoCode can sum these values.
Best regards,
Otto

Image

Image

Image

Code: Select all

function f_calc (cText)                                                                    
   local nTemp    := 0                                                                     
   local cTextNew := ""                                                                    
   local cLine    := ""                                                                    
   local nFrom    := 0                                                                     
*----------------------------------------------------------                                
   while nFrom < Len( cText )                                                              
      cLine = ALLTRIM( ExtractLine( cText, @nFrom ) )                                      
      if len(alltrim(cLine)) > 0                                                           
         nTemp  := ( &cLine )                                                              
         cTextNew := cTextNew + "  " + ALLTRIM( str(nTemp ) ) + "  " + CRLF                
      endif                                                                                
      SysRefresh()                                                                         
   end                                                                                     
                                                                                           
return ( cTextNew )                                                                        
                                                                                           
 

Re: autoCode5 – the timesaver

Posted: Fri Apr 23, 2010 6:56 am
by MdaSolution
Good Mr Otto,
But where I can found testmemo.ch ? thanks

Re: autoCode5 – the timesaver

Posted: Fri Apr 23, 2010 7:55 am
by Otto
Best regards,
Otto
rc-file

Code: Select all

#include "c:\FWH\include\winapi.ch"

MEMOEDIT DIALOG DISCARDABLE 18, 18, 187, 134
STYLE WS_POPUP|DS_MODALFRAME|WS_CAPTION|WS_SYSMENU
CAPTION "MemoEditing"
FONT 8, "Arial"
{
  CONTROL "", 110, "Edit", ES_MULTILINE|ES_WANTRETURN|WS_VSCROLL|WS_BORDER|WS_TABSTOP, 4, 6, 180, 85
  CONTROL "Clear", 4001, "Button", WS_TABSTOP, 136, 96, 45, 15
  CONTROL "local", 4002, "Button", WS_TABSTOP, 4, 96, 45, 15
  CONTROL "Format", 4003, "Button", WS_TABSTOP, 60, 96, 50, 14
  CONTROL "Calc", 4004, "Button", WS_TABSTOP, 60, 112, 50, 14
}

 
prg-file

Code: Select all

#include "FiveWin.ch"
#include "autocod5.ch"

//----------------------------------------------------------------------------//

function Main()

   local oDlg, oGet
   local cText   :=  ""   

   SET _3DLOOK ON

   DEFINE DIALOG oDlg RESOURCE "MEMOEDIT"  Title "autoCode5"

   REDEFINE GET oGet VAR cText MEMO ID ID_MEMO OF oDlg

   oGet:bGotFocus = { || oGet:SetSel( 0, 0 ),;
                         oGet:Goto( oGet:GetLineCount() ),;
                         __Keyboard( Chr( VK_END ) ) }
  
  
  REDEFINE BUTTON ID 4004 OF oDlg ACTION ( cText := f_calc( cText ), oGet:refresh() )
  REDEFINE BUTTON ID 4003 OF oDlg ACTION ( cText := f_format( cText ), oGet:refresh() )
   REDEFINE BUTTON ID 4002 OF oDlg ACTION ( cText := Setlocal( cText ), oGet:refresh() )
  REDEFINE BUTTON ID 4001 OF oDlg ACTION ( cText := "" , oGet:refresh())
  
   ACTIVATE DIALOG oDlg CENTERED ON INIT ( SetWindowPos( oDlg:hWnd, -1, 0, 0, 0, 0, 3 )  )

return nil
//----------------------------------------------------------------------------//

function Setlocal( cText )
  local cTextNew  := "" 
  local cLine  := "" 
  local nFrom  := 0


      while nFrom < Len( cText )
         cLine = ExtractLine( cText, @nFrom )
         
         if UPPER(left(ALLTRIM(cLine),1)) =  "C"
          cTextNew := cTextNew + "local " + cLine + '  := "" ' + CRLF
         elseif UPPER(left(ALLTRIM(cLine),1)) =  "N"
          cTextNew := cTextNew + "local " + cLine + +  '  := 0' + CRLF
         elseif left(ALLTRIM(cLine),1) =  "a"
          cTextNew := cTextNew + "local " + cLine + +  '  := {}' + CRLF
         else
          cTextNew := cTextNew + "local " + cLine + CRLF
         endif
         
         SysRefresh()
      end
 
return ( cTextNew )
//----------------------------------------------------------------------------//

function f_format( cText )
  local cTextNew  := cText 

    cTextNew :=  STRTRAN(cTextNew, "*", " * " )
  //  cTextNew :=  STRTRAN(cTextNew, "-", " - " )
    cTextNew :=  STRTRAN(cTextNew, " - >", "->" )
    
    cTextNew :=  STRTRAN(cTextNew, ":=", " := " )
    cTextNew :=  STRTRAN(cTextNew, "(", "( " )
    cTextNew :=  STRTRAN(cTextNew, ")", " )" )
    
    cTextNew :=  STRTRAN(cTextNew, "[", "[ " )
    cTextNew :=  STRTRAN(cTextNew, "]", " ]" )
    
    cTextNew :=  STRTRAN(cTextNew, ",", ", " )
    cTextNew :=  STRTRAN(cTextNew, " ,", "," )
    cTextNew :=  STRTRAN(cTextNew, " ;", ";" )
    
    cTextNew :=  STRTRAN(cTextNew, "  " , " " )
    cTextNew :=  STRTRAN(cTextNew, "   " , " " )
    
    cTextNew :=  STRTRAN(cTextNew, " ,", "," )
    
    cTextNew :=  STRTRAN(cTextNew, "(  )", "()" )
    
    cTextNew :=  STRTRAN(cTextNew, "  " , " " )
    
    SysRefresh()

return ( cTextNew )
//----------------------------------------------------------------------------//

function f_calc (cText)
   local nTemp    := 0
   local cTextNew := "" 
   local cLine    := "" 
   local nFrom    := 0
*----------------------------------------------------------
   while nFrom < Len( cText )
      cLine = ALLTRIM( ExtractLine( cText, @nFrom ) )
      if len(alltrim(cLine)) > 0 
         nTemp  := ( &cLine )
         cTextNew := cTextNew + "  " + ALLTRIM( str(nTemp ) ) + "  " + CRLF
      endif 
      SysRefresh()
   end

return ( cTextNew )
//----------------------------------------------------------------------------//