Documentación sintaxis

Documentación sintaxis

Postby leandro » Wed Oct 30, 2019 2:01 pm

Buenos días para todos

Ya hace varias versiónes de fw que se han adoptado nuevas formas de escribir el código, la mayoria de las novedades vienen de Mr.Nages y Cristobal, las he visto en los samples de xbrowse, y tambien en el siguiente código, me gustaría saber que hacen los caracteres contenedores <||> y de que manera se pueden usar. Así como también el tema de la definición de los objetos con la sintaxis WITH OBJECT END WITH

Code: Select all  Expand view

oDlg:bInit := <||
   @ 30,   50 XIMAGE oImage[1] RESOURCE "Icon1" OF oDlg NOBORDER
   @ 30, 200 XIMAGE oImage[2] RESOURCE "Icon2" OF oDlg NOBORDER
   @ 30, 350 XIMAGE oImage[3] RESOURCE "Icon3" OF oDlg NOBORDER

   AEval( oImage, {|o, n| o:lTransparent := .T. } )
   return nil
>

...

   oExplBar := TExplorerBar():New( nHSay + 3, 1, nPosVSp - 1, oWnd:nHeight() - 2, oWnd, , , , , , , )
   oExplBar:nTopColor     := Rgb( 240, 240, 240 )
   oExplBar:nBottomColor  := aGrad[ 1 ][ 2 ]

   AAdd( aPnels, oExplBar:AddPanel( "DATABASES", "C:\dlyma\Res\pan32.png", , 40, 0, aGrad, oFont, CLR_WHITE, CLR_WHITE ) )
   WITH OBJECT Atail( aPnels ) //oPanel1
      //:nOffSetX        := 100
      :nClrTextSpecial := CLR_WHITE
      :nClrHover       := Rgb( 0, 0, 0 ) //RGB( 66, 142, 255 )
      :nOffSetY        := 12
      :LoadBitmaps( 1, "D:\Fwh\FwhTeam\BmpsVS_32\CheckOut_16x_32.bmp" )
      :LoadBitmaps( 2, "D:\Fwh\FwhTeam\BmpsVS_32\CheckIn_16x_32.bmp" )
      :nTopMargin    := 1
      :nLeftMargin   := nWPanel + 22
      :nRightMargin  := 10
      :nLeft         := aPnels[ 1 ]:nLeftMargin
      :nRight        := oWnd:nWidth - aPnels[ 1 ]:nRightMargin
      :AddLink( "Open", bClick, "C:\dlyma\Res\icon3.bmp", , METRO_OLIVE, , )
      :AddLink( "Explorer", bClick, "D:\Fwh\FwhTeam\BmpsVS_32\DatabaseAuditSpecification_16x_32.bmp", , METRO_OLIVE, , )
      :AddLink( "Structure", bClick, "D:\Fwh\FwhTeam\BmpsVS_32\Databar_16x_32.Bmp", , METRO_OLIVE, , )
      :AddLink( "Tools", bClick, "D:\Fwh\FwhTeam\BmpsVS_32\DatabaseOptions_12882_32.bmp", , METRO_OLIVE, , )
      :AddLink( "Close", bClick, "D:\Fwh\FwhTeam\BmpsVS_32\DatabaseOffline_16x_32.bmp", , METRO_OLIVE, , )
   END

   WITH OBJECT oExplBar
      AAdd( aPnels, :AddPanel( "TOOLS", "C:\dlyma\Res\cart.png", , 40, 0, aGrad, oFont, CLR_WHITE, CLR_WHITE ) )
      AAdd( aPnels, :AddPanel( "EDITOR",   "D:\Fwh\FwhTeam\BmpsVS_32\FrameworkDesignStudio_32x_24.bmp", , 40, 0, aGrad, oFont, CLR_WHITE, CLR_WHITE  ) )
      AAdd( aPnels, :AddPanel( "EXPLORER", "D:\Fwh\FwhTeam\BmpsVS_32\FileDialogReport_32x_24.bmp", , 40, 0, aGrad, oFont, CLR_WHITE, CLR_WHITE  ) )
      AAdd( aPnels, :AddPanel( "EXP./IMPORT", "D:\Fwh\FwhTeam\BmpsVS_32\GetTextFormat_32x_24.Bmp", , 40, 0, aGrad, oFont, CLR_WHITE, CLR_WHITE  ) )
      AAdd( aPnels, :AddPanel( "USERS", "D:\Fwh\FwhTeam\BmpsVS_32\LookupPrincipal_32x_24.bmp", , 40, 0, aGrad, oFont, CLR_WHITE, CLR_WHITE  ) )
      For nPanel := 2 to Len( aPnels )
         WITH OBJECT :aPanels[ nPanel ]
            //:lSpecial        := .T.
            //:nOffSetX        := 60
            :lCollapsed      := .T.
            :LoadBitmaps( 1, "D:\Fwh\FwhTeam\BmpsVS_32\CheckOut_16x_32.bmp" )
            :LoadBitmaps( 2, "D:\Fwh\FwhTeam\BmpsVS_32\CheckIn_16x_32.bmp" )
            :nClrTextSpecial := CLR_WHITE
            :nClrHover       := Rgb( 0, 0, 0 )
            :nTopMargin      := 1
            :nLeftMargin     := nWPanel + 22
            :nRightMargin    := 10
            :nLeft           := :nLeftMargin
            :nRight          := oWnd:nWidth - :nRightMargin
            :nHeight         := :nTitleHeight
         END
         For nItem := nPanel + 1 To Len( :aPanels )
           :aPanels[ nItem ]:nTop -= ( :aPanels[ nPanel ]:nBodyHeight )
         Next
      Next
      :CheckScroll()
   END WITH

 


De antemano gracias
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1485
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: Documentación sintaxis

Postby cnavarro » Wed Oct 30, 2019 5:08 pm

Leandro, al fin y al cabo es otra forma de definir un codeblock, con la diferencia que en lugar de llamar a una function que creas abajo con un nombre, de esta forma puedes poner el codigo ahi. Fijate que tiene hasta un return ... ( obligatorio )
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6504
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Documentación sintaxis

Postby nageswaragunupudi » Wed Oct 30, 2019 5:19 pm

From xHarbour documentation:

<|| >
Extended literal code block.
Syntax
<| [<params,...>] | <programcode> >

Arguments
<params,...>
This is an optional comma separated list of parameter names declared for use inside the extended code block. Code block parameters are only visible within the code block and must be placed between the || delimiters.
<programcode>
<programcode> is any kind of program code which is also allowed within the body of a FUNCTION, except for the declaration of STATIC variables. Description
Extended literal code blocks are created in program code using the <|| > characters. They can be used in the same way as regular code blocks but have the advantage that <programcode> can include any statements allowed in the body of a function. This includes statements spanning across multiple lines, such as loops (DO WHILE, FOR and FOR EACH), branching (DO CASE and SWITCH), error handling (BEGIN SEQUENCE and TRY...CATCH).
Even the declaration of LOCAL variables within an extended code block is supported. Only STATIC variables cannot be declared.
The program code, embedded within an extended code block, is executed by passing the code block to the Eval() function. Arguments passed to this function are passed on to the code block and are received by the code block parameters. The expressions and statements in the code block are then executed from left to right, or top to bottom, respectively. The return value of the code block must be specified with the RETURN statement.
Info
See also: {|| }, AEval(), AScan(), ASort(), DbEval(), Eval(), HEval(), LOCAL
Category: Indirect execution , Operators , Special operators , xHarbour extensions
LIB: xhb.lib
DLL: xhbdll.dll

Example
// The example demonstrates the creation of an extended code block as a
// return value of function ConversionBlock(). The code block converts
// values to character strings. Note that the code block calls itself
// recursively within the FOR EACH loop.


PROCEDURE Main
LOCAL bBlock, lLogic:= .T., nNumber:= 1.23456, aArray := Directory()

bBlock := ConversionBlock()

? Eval( bBlock, aArray )

? Eval( bBlock, lLogic )

? Eval( bBlock, nNumber )

? Eval( bBlock, GetNew() )

? Eval( bBlock, bBLock )
RETURN


FUNCTION ConversionBlock()
LOCAL bBlock

bBlock := <| xValue |
LOCAL cType := Valtype( xValue )
LOCAL cValue, xElem

SWITCH cType
CASE "A"
cValue := "{"
FOR EACH xElem IN xValue
cValue += Eval( bBlock, xElem ) + ","
NEXT
cValue[-1] := "}"
EXIT

CASE "B" ; cValue := "{||...}" ; EXIT
CASE "C" ; cValue := xValue ; EXIT
CASE "D" ; cValue := DtoS(xValue) ; EXIT
CASE "L" ; cValue := IIf(xValue, ".T.",".F.") ; EXIT
CASE "N" ; cValue := LTrim(Str(xValue)) ; EXIT
CASE "O" ; cValue := xValue:className() ; EXIT
DEFAULT
cValue := "NIL"
END

RETURN cValue
>

RETURN bBlock
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10308
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Documentación sintaxis

Postby jvtecheto » Wed Oct 30, 2019 9:24 pm

MR. Raó.

Where is this documentation?

Thanks.

Jose.

Enviado desde mi POCOPHONE F1 mediante Tapatalk
Fwh 19.06 32 bits + Harbour 3.2dev(r2104281802) + Borland 7.4 + FivEdit
User avatar
jvtecheto
 
Posts: 577
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: Documentación sintaxis

Postby leandro » Tue Nov 12, 2019 3:59 pm

Excelente explicación Mr. Nages, me quedo totalmente claro el tema de los contenedores de los codeblocks :D

Por otro lado sigo con la duda de la forma en que se usa la sintaxis WITH OBJECT, no se en que se pueda ver afectadas a futuro nuestras aplicaciones, es necesario hacer los cambios?, para dar un ejemplo claro, en este momento estoy definiendo los xbrowse "a la antigua", así:

Code: Select all  Expand view

  oLamcla:oBrwArti := TXBrowse():New( oCuadro )
  oLamcla:oBrwArti:nMarqueeStyle         := MARQSTYLE_HIGHLROW
  oLamcla:oBrwArti:nRowDividerStyle      := LINESTYLE_LIGHTGRAY
  oLamcla:oBrwArti:nColDividerStyle      := LINESTYLE_LIGHTGRAY
  oLamcla:oBrwArti:nHeaderLines          := 1
  oLamcla:oBrwArti:lColDividerComplete   := .t.
  oLamcla:oBrwArti:lRecordSelector       := .t.
  oLamcla:oBrwArti:nStretchCol           := STRETCHCOL_LAST
  oLamcla:oBrwArti:l2007                 := .f.
  oLamcla:oBrwArti:oFont                 := oFont1

  aCol[ 1]                   := oLamcla:oBrwArti:AddCol()
  aCol[ 1]:bStrData          := { || If( oRsArt:Eof, Space( nWidth ), cValtoChar( oRsArt:Fields( "i_articu" ):Value ) ) }
  aCol[ 1]:cHeader            := "Codigo"
  aCol[ 1]:nHeadStrAlign     := AL_LEFT
  aCol[ 1]:nDataStrAlign     := AL_LEFT
  aCol[ 1]:nWidth            := 80

  aCol[ 2]                   := oLamcla:oBrwArti:AddCol()
  aCol[ 2]:bStrData          := { || If( oRsArt:Eof, Space( nWidth ), cValtoChar( oRsArt:Fields( "i_nombre" ):Value ) ) }
  aCol[ 2]:cHeader            := "Nombre"
  aCol[ 2]:nHeadStrAlign     := AL_LEFT
  aCol[ 2]:nDataStrAlign     := AL_LEFT
  aCol[ 2]:nWidth            := 225

  aCol[ 3]                   := oLamcla:oBrwArti:AddCol()
  aCol[ 3]:bStrData          := { || If( oRsArt:Eof, Space( nWidth ), IF(cValtoChar( oRsArt:Fields( "i_serpro" ):Value )="1","Producto","Servicio") ) }
  aCol[ 3]:cHeader            := "Tipo"
  aCol[ 3]:nHeadStrAlign     := AL_LEFT
  aCol[ 3]:nDataStrAlign     := AL_LEFT
  aCol[ 3]:nWidth            := 90

  aCol[ 4]                   := oLamcla:oBrwArti:AddCol()
  aCol[ 4]:bStrData          := { || If( oRsArt:Eof, Space( nWidth ), cValtoChar( oRsArt:Fields( "i_refere" ):Value ) ) }
  aCol[ 4]:cHeader            := "Referencia"
  aCol[ 4]:nHeadStrAlign     := AL_LEFT
  aCol[ 4]:nDataStrAlign     := AL_LEFT
  aCol[ 4]:nWidth            := 150

  oLamcla:oBrwArti:SetADO( oRsArt )
  oLamcla:oBrwArti:CreateFromResource( 102 )
 


En los ejemplos que vienen actualmente en FW, se esta haciendo de la siguiente manera:

Code: Select all  Expand view

   @ 0,0 XBROWSE oBrw OF ownd ALIAS cAlias ;
      AUTOSORT AUTOCOLS FOOTERS FASTEDIT LINES CELL ;
      BACKGROUND 'PAPER'

   WITH OBJECT oBrw:Salary
      :nFooterType      := AGGR_TOTAL
      :bLClickFooter    := { |r,c,f,o| FooterAggrClick( r, c, f, o ) }
   END

   AEval( oBrw:aCols, { |o| o:cToolTip := { 'Column :' + CRLF + o:cHeader, 'ToolTip' } } )

   WITH OBJECT oBrw
      // for all cols
      :nEditTypes    := EDIT_GET
      // for browse
      :bClrRowFocus  := :bClrSelFocus
      :bPopUp        := { |o| ColMenu( o ) }
      :Married:SetCheck( { "GREEN", "RED" }, EDIT_GET )
      :MakeTotals()
      :CreateFromCode()
   END
 


Como mencione anteriormente, este necesario ir migrando la sintaxis? y si en alguna parte de la WIKI de FW existe documentación, al menos un poco?

De antemano gracias
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1485
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: Documentación sintaxis

Postby leandro » Tue Nov 12, 2019 4:00 pm

Excelente explicación Mr. Nages, me quedo totalmente claro el tema de los contenedores de los codeblocks :D

Por otro lado sigo con la duda de la forma en que se usa la sintaxis WITH OBJECT, no se en que se pueda ver afectadas a futuro nuestras aplicaciones, es necesario hacer los cambios?, para dar un ejemplo claro, en este momento estoy definiendo los xbrowse "a la antigua", así:

Code: Select all  Expand view

  oLamcla:oBrwArti := TXBrowse():New( oCuadro )
  oLamcla:oBrwArti:nMarqueeStyle         := MARQSTYLE_HIGHLROW
  oLamcla:oBrwArti:nRowDividerStyle      := LINESTYLE_LIGHTGRAY
  oLamcla:oBrwArti:nColDividerStyle      := LINESTYLE_LIGHTGRAY
  oLamcla:oBrwArti:nHeaderLines          := 1
  oLamcla:oBrwArti:lColDividerComplete   := .t.
  oLamcla:oBrwArti:lRecordSelector       := .t.
  oLamcla:oBrwArti:nStretchCol           := STRETCHCOL_LAST
  oLamcla:oBrwArti:l2007                 := .f.
  oLamcla:oBrwArti:oFont                 := oFont1

  aCol[ 1]                   := oLamcla:oBrwArti:AddCol()
  aCol[ 1]:bStrData          := { || If( oRsArt:Eof, Space( nWidth ), cValtoChar( oRsArt:Fields( "i_articu" ):Value ) ) }
  aCol[ 1]:cHeader            := "Codigo"
  aCol[ 1]:nHeadStrAlign     := AL_LEFT
  aCol[ 1]:nDataStrAlign     := AL_LEFT
  aCol[ 1]:nWidth            := 80

  aCol[ 2]                   := oLamcla:oBrwArti:AddCol()
  aCol[ 2]:bStrData          := { || If( oRsArt:Eof, Space( nWidth ), cValtoChar( oRsArt:Fields( "i_nombre" ):Value ) ) }
  aCol[ 2]:cHeader            := "Nombre"
  aCol[ 2]:nHeadStrAlign     := AL_LEFT
  aCol[ 2]:nDataStrAlign     := AL_LEFT
  aCol[ 2]:nWidth            := 225

  aCol[ 3]                   := oLamcla:oBrwArti:AddCol()
  aCol[ 3]:bStrData          := { || If( oRsArt:Eof, Space( nWidth ), IF(cValtoChar( oRsArt:Fields( "i_serpro" ):Value )="1","Producto","Servicio") ) }
  aCol[ 3]:cHeader            := "Tipo"
  aCol[ 3]:nHeadStrAlign     := AL_LEFT
  aCol[ 3]:nDataStrAlign     := AL_LEFT
  aCol[ 3]:nWidth            := 90

  aCol[ 4]                   := oLamcla:oBrwArti:AddCol()
  aCol[ 4]:bStrData          := { || If( oRsArt:Eof, Space( nWidth ), cValtoChar( oRsArt:Fields( "i_refere" ):Value ) ) }
  aCol[ 4]:cHeader            := "Referencia"
  aCol[ 4]:nHeadStrAlign     := AL_LEFT
  aCol[ 4]:nDataStrAlign     := AL_LEFT
  aCol[ 4]:nWidth            := 150

  oLamcla:oBrwArti:SetADO( oRsArt )
  oLamcla:oBrwArti:CreateFromResource( 102 )
 


En los ejemplos que vienen actualmente en FW, se esta haciendo de la siguiente manera:

Code: Select all  Expand view

   @ 0,0 XBROWSE oBrw OF ownd ALIAS cAlias ;
      AUTOSORT AUTOCOLS FOOTERS FASTEDIT LINES CELL ;
      BACKGROUND 'PAPER'

   WITH OBJECT oBrw:Salary
      :nFooterType      := AGGR_TOTAL
      :bLClickFooter    := { |r,c,f,o| FooterAggrClick( r, c, f, o ) }
   END

   AEval( oBrw:aCols, { |o| o:cToolTip := { 'Column :' + CRLF + o:cHeader, 'ToolTip' } } )

   WITH OBJECT oBrw
      // for all cols
      :nEditTypes    := EDIT_GET
      // for browse
      :bClrRowFocus  := :bClrSelFocus
      :bPopUp        := { |o| ColMenu( o ) }
      :Married:SetCheck( { "GREEN", "RED" }, EDIT_GET )
      :MakeTotals()
      :CreateFromCode()
   END
 


Como mencione anteriormente, este necesario ir migrando la sintaxis? y si en alguna parte de la WIKI de FW existe documentación, al menos un poco?

De antemano gracias
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1485
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: Documentación sintaxis

Postby cnavarro » Tue Nov 12, 2019 4:23 pm

Leandro, la sintaxis de Fw no ha cambiado, salvo la adición en los metacomandos de nuevas claúsulas y comandos.
Creo que a lo que te refieres es sintaxis del propio Harbour, por lo que tendrás que buscarlo en la documentacion del compilador. De todas formas, como ves, hacemos lo que podemos, y si tienes alguna duda más, seguro que podremos ayudarte
Un saludo
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6504
Joined: Wed Feb 15, 2012 8:25 pm
Location: España


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 14 guests