grid

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
franco
Posts: 213
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

grid

Post by franco » Sun Dec 27, 2015 1:57 am

Hi to all and best of new year,
My new problem in my invoicing billing progra, is when there are two items on grid, and I delete the first one it still shows on the grid.
When I add another item the grid now shows correct. Delete record 1 and same thin happens. This is no good for invoiceing.
I used sample 37 as a test. Works good until there are 2 records.
Here is a sample. I use 3.21

HMG Data-Bound Grid Demo
* (c) 2010 Roberto Lopez
*/

#include "hmg.ch"

Function Main

Local aValue := { Nil , Nil }
OPNFILS()

GO TOP

set deleted on
* Grid Column Controls Definitions

aCtrl_1 := {'TEXTBOX','CHARACTER'}
aCtrl_2 := {'TEXTBOX','CHARACTER'}


DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 800 ;
HEIGHT 510 ;
TITLE 'Hello World!' ;
MAIN

DEFINE MAIN MENU
POPUP 'File'
ITEM 'Append (Alt+A)' ACTION Form_1.Grid_1.Append
ITEM 'Set RecNo' ACTION Form_1.Grid_1.RecNo := val(InputBox('',''))
ITEM 'Get RecNo' ACTION MsgInfo( Str(Form_1.Grid_1.RecNo) )
ITEM 'Delete (Alt+D)' ACTION Form_1.Grid_1.Delete
ITEM 'Recall (Alt+R)' ACTION Form_1.Grid_1.Recall
ITEM 'Get Value' ACTION ( aValue := Form_1.Grid_1.Value , MsgInfo( Str( aValue [1] ) + ' , ' + Str( aValue [2] ) ) )
ITEM 'Set Value' ACTION ( aValue [ 1 ] := val(InputBox('New Row','Selected Cell (Value)')) , aValue [ 2 ] := val(InputBox('New Col','Selected Cell (Value)')) , Form_1.Grid_1.Value := { aValue [ 1 ] , aValue [ 2 ] } )
ITEM 'Save Pending Changes (Alt+S)' ACTION Form_1.Grid_1.Save
ITEM 'Clear Changes Buffer (Undo) (ALt+U)' ACTION Form_1.Grid_1.ClearBuffer
END POPUP
END MENU


@ 10,10 GRID Grid_1 ;
WIDTH 770 ;
HEIGHT 440 ;
HEADERS {'Column 1','Column 2'} ;
WIDTHS {140,140};
EDIT ;
VALUE { 1 , 1 } ;
COLUMNCONTROLS { aCtrl_1 , aCtrl_2 } ;
ROWSOURCE "INV" ;
COLUMNFIELDS { 'NUM1' , 'NUM2' } ;
COLUMNWHEN { { || .T. } , { || .T. } } ;
ALLOWDELETE

END WINDOW
CENTER WINDOW Form_1

ACTIVATE WINDOW Form_1

Return


FUNCTION OPNFILS
LOCAL CF
if ! file('inv.dbf')
CF := {}
aADD(CF,{'NUM1' ,'C' , 15,0})
aADD(CF,{'NUM2' ,'C' , 15,0})
DBCREATE( 'INV.DBF',CF )
USE
USE INV EXCLUSIVE NEW
INDEX ON NUM1 TO NUM1
USE


endif

SELECT 1
USE INV ALIAS INV
INDEX ON NUM1 TO NUM1
RETURN


If you compile and run, the first time you delete record 1 it is fine. when you add another record and then delete record 1, this
is when problem starts.

any thoughts ........... Franco

franco
Posts: 213
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Sun Dec 27, 2015 6:39 pm

I found a solution.
I noticed when I deleted second record everything was fine, so in code I appended another record and deleted it before grid save.
Here is my real delete code. I have marked the additions.
If anybody has a better solution let me know ... Thanks Franco
*------------------------------------------------------------------------------*
Procedure Delfrominv()
*------------------------------------------------------------------------------*
Local acell ,cur_rec
IF msgyesno('Delete '+alltrim(item)+' From Invoice')
Form_Grid_IN2.button_2.setfocus
acell := Form_Grid_IN2.Grid_2.VALUE
acell[2] := 1
Form_Grid_IN2.Grid_2.Delete
Form_Grid_IN2.Grid_2.Append // added
Form_Grid_IN2.Grid_2.Delete //added
Form_Grid_IN2.Grid_2.Save
aCell := Form_Grid_IN2.Grid_2.VALUE
acell[2] := 2
*SaveinvoiceCell()

ENDIF

Form_Grid_IN2.Grid_2.SETFOCUS
RETURN

MICROVOLUTION
Posts: 24
Joined: Sat May 30, 2015 5:15 am

Post by MICROVOLUTION » Thu Mar 17, 2016 11:00 pm

PORTUGUESE:
Pessoal, primeiramente bom(a) dia/tarde/noite/madrugada!
2º - O assunto, é completamente do tópico, mas, não sei o que está acontecendo, com o meu computador, mas, aparece uma mensagem de erro ao entrar nas sub-listas de tópicos.
Peço aos administradores/moderadores, que mudem minha postagem para o local correto, por favor!
Vamo lá então à minha dúvida:
Baixei um exemplo do Pablo César noutro tópico/fórum.
Tentei adaptá-lo ao meu sistema, pois o objeto BROWSE que tenho não funciona na HMG.
- Além dos erros que aconteceram durante a compilação, quero uma forma onde eu mande para a função os dados dos arquivos, pois já estão abertos no momento da pesquisa.
- No lugar de ser um MAIN.PRG criei-o com o nome de ROTINAS6.PRG. Por favor, vejam como ficou:

Code: Select all

#include <hmg.ch>
FUNCTION CRIABROWSE_GRID(VARIAVEL,NOME_PROGRAMA,NOME_ARQUIVO,CAB_CAMPOS,TAM_CAMPOS,MASC_CAMPOS,NOME_ARQ)
Private bBackColor:={ || IF( THIS.CELLROWINDEX/2==INT(THIS.CELLROWINDEX/2),;
            { 234,244,255 },{ 255,255,255 } ) }, v_getpesqnome
Private aPesq:={"CODIGO", "PRODUTO", "FORNECEDOR"}
Private cProcura
/*
REQUEST DBFCDX
RDDSETDEFAULT( "DBFCDX" )
If !File("sgf97.dbf")
 Campos:={ {"NB"     ,"C",010,000},;
      {"NOME"    ,"C",040,000},;
      {"NASC"    ,"C",008,000},;
      {"CPF"    ,"C",011,000},;
      {"NIT"    ,"C",011,000},;
      {"ESP"    ,"C",002,000},;
      {"DER"    ,"C",008,000},;
      {"DESP"    ,"C",002,000},;
      {"CONC"    ,"C",008,000},;
      {"IND"    ,"C",008,000},;
      {"MOTIND"   ,"C",003,000},;
      {"MOTINDS"  ,"C",003,000},;
      {"DTIND"   ,"C",008,000},;
      {"END"    ,"C",040,000},;
      {"BAIRRO"   ,"C",017,000},;
      {"CEP"    ,"C",008,000},;
      {"MUN"    ,"C",024,000},;
      {"UF"     ,"C",002,000},;
      {"DDD"    ,"C",004,000},;
      {"TEL"    ,"C",010,000} }
 DbCreate("SGF97.DBF",Campos)
Endif
DBUSEAREA(.T.,,"sgf97.dbf","dbf",,.f.)
If !File("sgf97.cdx")
 dbf->(OrdCreate("sgf97.cdx","Beneficio","dbf->nb",{|| dbf->nb } ))
 dbf->(OrdCreate("sgf97.cdx","Nome","dbf->nome",{|| dbf->nome } ))
 dbf->(OrdCreate("sgf97.cdx","Muncipio","dbf->mun",{|| dbf->mun } ))
Endif
SET INDEX TO "sgf97.cdx"
dbf->( OrdSetFocus(1) )
IF NETERR()
 RETURN nil
ENDIF
*/
 // TITLE "Pesquisa" + NOME_PROGRAMA ICON NIL MAIN; // linha substituída pela 3 linha abaixo 16/3/16w
DEFINE WINDOW Frm_BROWSE_GRID AT GetDesktopRealTop(),GetDesktopRealLeft() ;
 WIDTH GetDesktopRealWidth() HEIGHT GetDesktopRealHeight() ;
 TITLE NOME_PROGRAMA ICON NIL MODAL; 
 ON INIT Frm_BROWSE_GRID_form_oninit() ON RELEASE Nil ;
 ON INTERACTIVECLOSE Frm_BROWSE_GRID_form_oninteractiveclose();
 ON MOUSECLICK Nil ON MOUSEDRAG Nil ON MOUSEMOVE Nil ;
 ON SIZE Nil ON MAXIMIZE Nil ON MINIMIZE Nil ON PAINT Nil ;
 BACKCOLOR Nil ON GOTFOCUS Nil ON LOSTFOCUS Nil
 
 ON KEY ESCAPE ACTION Thiswindow.Release()

  DEFINE FRAME FramePesq
    ROW  10
    COL  10
    WIDTH 678
    HEIGHT 53
    FONTNAME "Arial"
    FONTSIZE 9
    FONTBOLD .T.
    FONTITALIC .F.
    FONTUNDERLINE .F.
    FONTSTRIKEOUT .F.
    CAPTION "Pesquisar por:"
    BACKCOLOR NIL
    FONTCOLOR NIL
    OPAQUE .T.
  END FRAME

  DEFINE TEXTBOX GetPesq
    ROW  30
    COL  190
    WIDTH 380
    HEIGHT 24
    FONTNAME "Arial"
    FONTSIZE 9
    TOOLTIP ""
    ONCHANGE Nil
    ONGOTFOCUS Nil
    ONLOSTFOCUS Nil
    FONTBOLD .F.
    FONTITALIC .F.
    FONTUNDERLINE .F.
    FONTSTRIKEOUT .F.
    ONENTER (If(Frm_BROWSE_GRID.BotaoPesq.Enabled,Frm_BROWSE_GRID_botaopesq(),))
    HELPID Nil
    TABSTOP .T.
    VISIBLE .T.
    READONLY .F.
    RIGHTALIGN .F.
    DISABLEDBACKCOLOR Nil
    DISABLEDFONTCOLOR Nil
    CASECONVERT NONE
    MAXLENGTH 30
    BACKCOLOR NIL
    FONTCOLOR NIL
    INPUTMASK Replicate("!",40)
    FORMAT NIL
    VALUE ""
  END TEXTBOX

  DEFINE COMBOBOX ComboPesq
    ROW  30
    COL  20
    WIDTH 160
    HEIGHT 100
    ITEMS aPesq
    VALUE 0
    FONTNAME "Arial"
    FONTSIZE 9
    TOOLTIP ""
    ONCHANGE Muda_Chave(This.Value)
    ONGOTFOCUS Nil
    ONLOSTFOCUS Nil
    FONTBOLD .F.
    FONTITALIC .F.
    FONTUNDERLINE .F.
    FONTSTRIKEOUT .F.
    HELPID Nil
    TABSTOP .T.
    VISIBLE .T.
    SORT .F.
    ONENTER Nil
    ONDISPLAYCHANGE Nil
    DISPLAYEDIT .F.
    IMAGE Nil
    DROPPEDWIDTH 0
    ONDROPDOWN Nil
    ONCLOSEUP Nil
  END COMBOBOX

  DEFINE BUTTON BotaoPesq
    ROW  20
    COL  700
    WIDTH 120
    HEIGHT 40
    ACTION Frm_BROWSE_GRID_botaopesq()
    CAPTION "Pesquisa"
    FONTNAME "Arial"
    FONTSIZE 9
    TOOLTIP ""
    FONTBOLD .T.
    FONTITALIC .F.
    FONTUNDERLINE .F.
    FONTSTRIKEOUT .F.
    ONGOTFOCUS Nil
    ONLOSTFOCUS Nil
    HELPID Nil
    FLAT .F.
    TABSTOP .T.
    VISIBLE .T.
    TRANSPARENT .F.
    MULTILINE .F.
    PICTURE Nil
    PICTALIGNMENT TOP
  END BUTTON
 
 DEFINE CHECKBOX Check_1
    ROW  30
    COL  585
    WIDTH 100
    HEIGHT 28
    CAPTION "Busca Parcial"
    VALUE .F.
    FONTNAME "Arial"
    FONTSIZE 9
    TOOLTIP ""
    ONCHANGE cProcura:=""
    ONGOTFOCUS Nil
    ONLOSTFOCUS Nil
    FONTBOLD .F.
    FONTITALIC .F.
    FONTUNDERLINE .F.
    FONTSTRIKEOUT .F.
    BACKCOLOR Nil
    HELPID Nil
    TABSTOP .T.
    VISIBLE .T.
    TRANSPARENT .F.
  END CHECKBOX

  DEFINE GRID Grid_Data
    ROW  70
    COL  10
    WIDTH GetDesktopRealWidth()-30
    HEIGHT GetDesktopRealHeight()-116
    ITEMS Nil
    VALUE Nil
    WIDTHS grid_data_widths()
    HEADERS grid_data_headers()
    FONTNAME "Courier"
    FONTSIZE 9
    TOOLTIP ""
    ONCHANGE Nil
    ONGOTFOCUS Nil
    ONLOSTFOCUS Nil
    FONTBOLD .F.
    FONTITALIC .F.
    FONTUNDERLINE .F.
    FONTSTRIKEOUT .F.
    ONDBLCLICK Nil
    ONHEADCLICK Nil
    ONQUERYDATA Nil
    MULTISELECT .F.
    ALLOWEDIT .T.
    VIRTUAL .F.
    DYNAMICBACKCOLOR grid_data_dynamicbackcolor()
    DYNAMICFORECOLOR Nil
    COLUMNWHEN Nil
    COLUMNVALID Nil
    COLUMNCONTROLS grid_data_columncontrols()
    SHOWHEADERS .T.
    CELLNAVIGATION .F.
    NOLINES .F.
    HELPID Nil
    IMAGE Nil
    JUSTIFY grid_data_justify()
    ITEMCOUNT Nil
    BACKCOLOR NIL
    FONTCOLOR NIL
    HEADERIMAGES Nil
    ROWSOURCE "dbf"
    COLUMNFIELDS grid_data_columnfields()
    ALLOWAPPEND .T.
    ALLOWDELETE .T.
    BUFFERED .F.
    DYNAMICDISPLAY Nil
    ONSAVE Nil
    LOCKCOLUMNS 0
  END GRID

END WINDOW
Frm_BROWSE_GRID.BotaoPesq.Enabled:=.F.
Frm_BROWSE_GRID.Center
Frm_BROWSE_GRID.Activate
RETURN nil

FUNCTION grid_data_columnwhen()
LOCAL aColumnWhen

  // { || .T. } PERMITE A EDICAO
  // { || .F. } NAO PERMITE A EDICAO

 aColumnWhen := { { || .F. },;
 { || .F. },;
 { || .F. },;
 { || .F. },;
 { || .F. },;
 { || .F. },;
 { || .F. },;
 { || .F. },;
 { || .F. },;
 { || .F. },;
 { || .F. } }
         

RETURN aColumnWhen

FUNCTION grid_data_columncontrols()
LOCAL aColumnControls

 aColumnControls := { { "TEXTBOX","CHARACTER" },;
            { "TEXTBOX","CHARACTER" },;
            { "TEXTBOX","CHARACTER" },;
            { "TEXTBOX","CHARACTER" },;
            { "TEXTBOX","CHARACTER" },;
            { "TEXTBOX","CHARACTER" },;
            { "TEXTBOX","CHARACTER" },;
            { "TEXTBOX","CHARACTER" },;
            { "TEXTBOX","CHARACTER" },;
            { "TEXTBOX","CHARACTER" },;
            { "TEXTBOX","CHARACTER" } }
            

RETURN aColumnControls 

FUNCTION grid_data_columnfields()
LOCAL aColumnFields

  aColumnFields := {'&NOME_ARQ.->CDPRODUTO',;
            '&NOME_ARQ.->DSPRODUTO',;
            '&NOME_ARQ.->DSUNIDADE',;
            '&NOME_ARQ.->CDFORNECE',;
            '&NOME_ARQ.->CD_SECAO' ,;
            '&NOME_ARQ.->CDGRUPO' ,;
            '&NOME_ARQ.->VR_UNITAR',; // no original era "9,2" 20/2/16w
            '&NOME_ARQ.->VR_PRECUS',; // no original era "9,2" 20/2/16w
            '&NOME_ARQ.->VP_MARLUC',;
            '&NOME_ARQ.->VR_PREVEN',;
            '&NOME_ARQ.->DT_ULTCOM',;
            '&NOME_ARQ.->DT_ULTVEN',;
            '&NOME_ARQ.->QT_ESTMIN',;
            '&NOME_ARQ.->QT_ESTMAX',;
            '&NOME_ARQ.->QT_ESTTOT'}

/* aColumnFields := { "dbf->nb",;
          "dbf->nome",;
          "dbf->mun",;
          "dbf->cpf",;
          "dbf->nasc",;
          "dbf->nit",;
          "dbf->esp",;
          "dbf->der",;
          "dbf->desp",;
          "dbf->conc",;
          "dbf->tel"}
*/
          

RETURN aColumnFields 

FUNCTION grid_data_headers()
LOCAL aheaders

 aheaders := CAB_CAMPOS

/*
 aheaders := { "Beneficio",;
        "Nome",;
        "Municipio",;
        "CPF",;
        "Nascimento",;
        "NIT",;
        "Esp",;
        "Der",;
        "Desp",;
        "Conc",;
        "Tel"}
*/       

RETURN aheaders

FUNCTION grid_data_widths()
LOCAL awidths := {}

 awidths := { 85, 280, 180, 100, 100, 100, 50, 100, 50, 100, 100 }

RETURN awidths

FUNCTION grid_data_justify()
LOCAL ajustify := {}

 ajustify := { GRID_JTFY_CENTER,;
        GRID_JTFY_LEFT,;
        GRID_JTFY_LEFT,;
        GRID_JTFY_CENTER,;
        GRID_JTFY_CENTER,;
        GRID_JTFY_CENTER,;
        GRID_JTFY_CENTER,;
        GRID_JTFY_CENTER,;
        GRID_JTFY_CENTER,;
        GRID_JTFY_CENTER,;
        GRID_JTFY_CENTER }
        

RETURN ajustify

FUNCTION grid_data_DynamicBackColor()
LOCAL aDynamicBackColor := {}

 aDynamicBackColor := { bBackColor,;
             bBackColor,;
             bBackColor,;
             bBackColor,;
             bBackColor,;
             bBackColor,;
             bBackColor,;
             bBackColor,;
             bBackColor,;
             bBackColor,;
             bBackColor }
            

RETURN aDynamicBackColor

Function Muda_Chave(nVal)
cProcura:=""
Frm_BROWSE_GRID.Grid_Data.Refresh
Frm_BROWSE_GRID.BotaoPesq.Enabled:=.T.
Frm_BROWSE_GRID.GetPesq.SetFocus
Return Nil

Function Frm_BROWSE_GRID_form_oninit()
Return Nil

Function Frm_BROWSE_GRID_form_oninteractiveclose()
Return Nil

Function Frm_BROWSE_GRID_botaopesq()
Local nVal:=GetProperty("Frm_BROWSE_GRID","ComboPesq","Value")
Local lVal:=GetProperty("Frm_BROWSE_GRID","Check_1","Value")
Local nRec:=dbf->( Recno() )
Local lContinua:=.F.

cNewProcura:=AllTrim(GetProperty("Frm_BROWSE_GRID","GetPesq","Value"))
If cNewProcura==cProcura
 lContinua:=.T.
Else
 cProcura:=cNewProcura
Endif
dbf->( OrdSetFocus( nVal ) )
If lVal
 Do Case
   Case nVal=1
    If lContinua
     Skip
    If Eof()
     Goto Top
    Endif
     Locate Rest for cProcura $ Nb
   Else
    Locate for cProcura $ Nb
   Endif
  Case nVal=2
     If lContinua
     Skip
    If Eof()
     Goto Top
    Endif
     Locate Rest for cProcura $ Nome
   Else
     Locate for cProcura $ Nome
   Endif
  Case nVal=3
     If lContinua
     Skip
    If Eof()
     Goto Top
    Endif
       Locate Rest for cProcura $ Mun
   Else
     Locate for cProcura $ Mun
   Endif
 EndCase
Else
 dbf->(DBSeek( cProcura )) 
Endif
If !Found()
 MsgStop(Chr(34)+cProcura+Chr(34)+Chr(13)+Chr(10)+"não encontrado em "+aPesq[nVal]+" !")
 dbf->( OrdSetFocus( 0 ) )
 Goto nRec
 Frm_BROWSE_GRID.Grid_Data.Refresh
Else
 dbf->( OrdSetFocus( 0 ) )
 Frm_BROWSE_GRID.Grid_Data.Value := {dbf->(Recno()),nVal}
Endif
Frm_BROWSE_GRID.Grid_Data.SetFocus
Return Nil

*********************************************************************************************************
************************** códigos da linguagem C/C++ ***************************************************
#pragma BEGINDUMP

#define HB_OS_WIN_USED
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include "hbapi.h"

HB_FUNC (GETDESKTOPREALTOP) 
{
 RECT rect;
 SystemParametersInfo( SPI_GETWORKAREA, 1, &rect, 0 );

 hb_retni(rect.top);

}
HB_FUNC (GETDESKTOPREALLEFT) 
{
 RECT rect;
 SystemParametersInfo( SPI_GETWORKAREA, 1, &rect, 0 );

 hb_retni(rect.left);

}

HB_FUNC (GETDESKTOPREALWIDTH) 
{
 RECT rect;
 SystemParametersInfo( SPI_GETWORKAREA, 1, &rect, 0 );

 hb_retni(rect.right - rect.left);

}

HB_FUNC (GETDESKTOPREALHEIGHT) 
{
 RECT rect;
 SystemParametersInfo( SPI_GETWORKAREA, 1, &rect, 0 );

 hb_retni(rect.bottom - rect.top);
}

#pragma ENDDUMP
************************** códigos da linguagem C/C++ ***************************************************
*********************************************************************************************************
OBSs:
1 - No início do meu sistema é criado diversas matrizes com o nome, conteúdo dos campos, indexes de todos os arquivos. No caso aqui, o arquivo é o DCI10010 (produtos), mas, quero mandar para a função também esta matriz.
2 - Estou usando HMG 3.4.2.
3 - A chamada a esta função é:

Code: Select all

CRIABROWSE_GRID (VARIAVEL,'PCI10011',NOME_ARQUIVO,CABEC_CAMPOS,TAM_MEMO,MASCARAS,ARQUIVO)
Na sequência, o conteúdo e explicação de cada elemento passado é:
VARIAVEL = variável do antigo GET onde foi pressionado a tecla F4 (ah! esta tecla aciona este CRIABROWSE_GRID);
PCI10011 = nome do módulo que está chamando a função;
NOME_ARQUIVO = nome do arquivo na linguagem do usuário, no exemplo acima: "Produtos";
CABEC_CAMPOS = matriz contendo todos os cabeçalhos (nome dos campos para o usuário interpretar/visualizar);
TAM_MEM = matriz contendo campos memo, caso existam. No exemplo = nil (cada elemento da matriz);
MASCARAS = Picture (do clipper @say/get) para formatação do visual dos campos;
ARQUIVO = conteúdo do select() atual, ou seja, o nome do arquivo aberto.
Vou acrescentar ainda a matriz contendo todos os dados completos do arquivo, mas, ainda não consegui pensar como fazer isso de uma forma geral.
No caso do arquivo de produtos, vejam, por obséquio, o conteúdo da matriz DCI10010 (PRODUTOS):

Code: Select all

private DCI10010 := {{{'PRODUTOS',;
           'Produtos',;
           '&DIR\PRODUTOS.DBF'},;
           {'ICI10010',;
           'str (CDPRODUTO,13)',;
           '&DIR\DCI10010.NTX'},;
           {'ICI10700',;
           'DSPRODUTO',;
           '&DIR\ICI10700.NTX'},;
           {'ICI10701',;
           'str (CDGRUPO,02) + DSPRODUTO',;
           '&DIR\ICI10701.NTX'},;
           {'ICI10702',;
           'str (CDFORNECE,04) + str (CDGRUPO,02) + DSPRODUTO',;
           '&DIR\ICI10702.NTX'}},;
          {'CDPRODUTO'     ,'N', 13, 0},;
          {'DSPRODUTO'     ,'C', 40, 0},;
          {'DSUNIDADE'     ,'C', 2, 0},;
          {'CDFORNECE'     ,'N', 4, 0},;
          {'CD_SECAO'      ,'N', 1, 0},;
          {'CDGRUPO'      ,'N', 2, 0},;
          {'VR_UNITAR'     ,'N', 10, 4},; // no original era "9,2" 20/2/16w
          {'VR_PRECUS'     ,'N', 10, 4},; // no original era "9,2" 20/2/16w
          {'VP_MARLUC'     ,'N', 6, 2},;
          {'VR_PREVEN'     ,'N', 9, 2},;
          {'DT_ULTCOM'     ,'D', 8, 0},;
          {'DT_ULTVEN'     ,'D', 8, 0},;
          {'QT_ESTMIN'     ,'N', 6, 2},;
          {'QT_ESTMAX'     ,'N', 6, 2},;
          {'QT_ESTTOT'     ,'N', 8, 3}}
Bom, agora voltando ao exemplo que o professor postou e, que modifiquei para o meu exemplo, mudei algumas coisas para ficar o mais próximo da minha realidade, mas, a mais drástica delas, foi trocar o formulário de MAIN para MODAL, pois já tenho um MAIN em aberto.
Infelizmente, as mensagens de erros foram muitas, vejam por favor:

Code: Select all

Harbour 3.2.0dev (r1509031202)
Copyright (c) 1999-2015, http://harbour-project.org/
C:\MVinfo\MIGRAR\SiCCA\SiCCA3603hmg\sci10000\rotinas6.prg(54) Error E0030 Syntax error "syntax error at 'WINDOW'"
C:\MVinfo\MIGRAR\SiCCA\SiCCA3603hmg\sci10000\rotinas6.prg(72) Error E0030 Syntax error "syntax error at '.T.'"
C:\MVinfo\MIGRAR\SiCCA\SiCCA3603hmg\sci10000\rotinas6.prg(90) Error E0030 Syntax error "syntax error at '.'"
C:\MVinfo\MIGRAR\SiCCA\SiCCA3603hmg\sci10000\rotinas6.prg(157) Error E0030 Syntax error "syntax error at '.F.'"
C:\MVinfo\MIGRAR\SiCCA\SiCCA3603hmg\sci10000\rotinas6.prg(184) Error E0030 Syntax error "syntax error at '.F.'"
C:\MVinfo\MIGRAR\SiCCA\SiCCA3603hmg\sci10000\rotinas6.prg(238) Error E0030 Syntax error "syntax error at '.'"
C:\MVinfo\MIGRAR\SiCCA\SiCCA3603hmg\sci10000\rotinas6.prg(239) Error E0030 Syntax error "syntax error at '.'"
C:\MVinfo\MIGRAR\SiCCA\SiCCA3603hmg\sci10000\rotinas6.prg(240) Error E0030 Syntax error "syntax error at '.'"
C:\MVinfo\MIGRAR\SiCCA\SiCCA3603hmg\sci10000\rotinas6.prg(383) Error E0030 Syntax error "syntax error at '.'"
C:\MVinfo\MIGRAR\SiCCA\SiCCA3603hmg\sci10000\rotinas6.prg(384) Error E0030 Syntax error "syntax error at '.'"
C:\MVinfo\MIGRAR\SiCCA\SiCCA3603hmg\sci10000\rotinas6.prg(385) Error E0030 Syntax error "syntax error at '.'"
C:\MVinfo\MIGRAR\SiCCA\SiCCA3603hmg\sci10000\rotinas6.prg(447) Error E0030 Syntax error "syntax error at '.'"
C:\MVinfo\MIGRAR\SiCCA\SiCCA3603hmg\sci10000\rotinas6.prg(450) Error E0030 Syntax error "syntax error at '.'"
C:\MVinfo\MIGRAR\SiCCA\SiCCA3603hmg\sci10000\rotinas6.prg(452) Error E0030 Syntax error "syntax error at '.'"
14 errors
No code generated.
As linhas acima são as seguintes:
54 (linha) - Esta não está só, pois trata-se de uma linha com (;):
DEFINE WINDOW Frm_BROWSE_GRID AT GetDesktopRealTop(),GetDesktopRealLeft() ;
WIDTH GetDesktopRealWidth() HEIGHT GetDesktopRealHeight() ;
TITLE NOME_PROGRAMA ICON NIL MODAL;
ON INIT Frm_BROWSE_GRID_form_oninit() ON RELEASE Nil ;
ON INTERACTIVECLOSE Frm_BROWSE_GRID_form_oninteractiveclose();
ON MOUSECLICK Nil ON MOUSEDRAG Nil ON MOUSEMOVE Nil ;
ON SIZE Nil ON MAXIMIZE Nil ON MINIMIZE Nil ON PAINT Nil ;
BACKCOLOR Nil ON GOTFOCUS Nil ON LOSTFOCUS Nil
As demais linhas dos erros são:
72 - OPAQUE .T.
90 - ONENTER (If(Frm_BROWSE_GRID.BotaoPesq.Enabled,Frm_BROWSE_GRID_botaopesq(),))
157 - 184 TRANSPARENT .F.
238-240
Frm_BROWSE_GRID.BotaoPesq.Enabled:=.F.
Frm_BROWSE_GRID.Center
Frm_BROWSE_GRID.Activate
383 - 385
Frm_BROWSE_GRID.Grid_Data.Refresh
Frm_BROWSE_GRID.BotaoPesq.Enabled:=.T.
Frm_BROWSE_GRID.GetPesq.SetFocus
447 - Frm_BROWSE_GRID.Grid_Data.Refresh
450 - Frm_BROWSE_GRID.Grid_Data.Value := {dbf->(Recno()),nVal}
452 - Frm_BROWSE_GRID.Grid_Data.SetFocus
Bom, acho que a única linha que sei resolver (acho) é a 450, pois troquei o "alias" dbf pelo nome do meu que é NOME_ARQ, mas, é só acho, não tenho certeza.
Um última informação: Meu sistema ainda é DBFNTX, então, a pesquisa será em torno disso. Não me perguntem "como?", pois não sei.
Portanto, se alguns dos professores puderem nos ajudar a clarear a mente, pois esse universo gráfico, já tinha até desistido (temporariamente) de dezembro/2015 até março/2016, usando a GTWVG. Mas, percebi que em alguns casos não tenho como escapar.
E no caso de um Frente de Loja, sem muitas informações gráficas, fica até difícil de se vender um sistema nesse mercado tão competitivo
ENGLISH:

Personal, first good (a) day / afternoon / evening / morning!
2 - The subject is full of topic, but do not know what's going on with my computer, but an error message when entering the sub-lists of topics.
I ask the administrators / moderators to change my posting to the correct location, please!
Let's go then to my question:
I downloaded an example of Pablo Cesar another topic / forum.
I tried to adapt it to my system because the BROWSE object that do not work in HMG.
- In addition to the errors that occurred during compilation, I want a way where I send to the function of the data files, as they are already open at the time of the survey.
- Instead of being a MAIN.PRG created it with the name of ROTINAS6.PRG. Please see how it went:

Code: Select all

 #include <hmg.ch>
CRIABROWSE_GRID FUNCTION (VARIABLE, Program_Name, FILENAME, CAB_CAMPOS, TAM_CAMPOS, MASC_CAMPOS, fname)
Private bBackColor: = {|| IF (THIS.CELLROWINDEX / 2 == int (THIS.CELLROWINDEX / 2) ,;
            {234,244,255} {255,255,255})}, v_getpesqnome
Private aPesq: = { "CODE", "PRODUCT", "SUPPLIER"}
Private cProcura
/ *
REQUEST DBFCDX
RDDSETDEFAULT ( "DBFCDX")
If! File ( "sgf97.dbf")
 Fields: = {{ "NB", "C"} 010 000 ,;
      { "NAME", "C", 040 000} ,;
      { "BIRTH", "C"} 008 000 ,;
      { "CPF", "C"} 011 000 ,;
      { "NIT", "C"} 011 000 ,;
      { "ESP", "C"} 002 000 ,;
      { "DER", "C"} 008 000 ,;
      { "DESP", "C"} 002 000 ,;
      { "CONC", "C"} 008 000 ,;
      { "IND", "C"} 008 000 ,;
      { "MOTIND", "C"} 003 000 ,;
      { "MOTINDS", "C"} 003 000 ,;
      { "DTIND", "C"} 008 000 ,;
      { "END", "C"} 040 000 ,;
      { "NEIGHBORHOOD", "C", 017 000} ,;
      { "CEP", "C", 008 000} ,;
      { "MUN", "C"} 024 000 ,;
      { "UF", "C"} 002 000 ,;
      { "DDD", "C"} 004 000 ,;
      { "TEL", "C", 010 000}}
 DbCreate ( "SGF97.DBF" Campos)
endif
DBUSEAREA (.T. ,, "Sgf97.dbf", "dbf" ,,. F.)
If! File ( "sgf97.cdx")
 dbf -> (OrdCreate ( "sgf97.cdx", "Benefit", "dbf-> nb" {|| dbf-> nb}))
 dbf -> (OrdCreate ( "sgf97.cdx", "name", "dbf-> name" {|| dbf-> name}))
 dbf -> (OrdCreate ( "sgf97.cdx", "muncipio", "dbf-> mun", {|| dbf-> mun}))
endif
SET INDEX TO "sgf97.cdx"
dbf -> (OrdSetFocus (1))
IF NETERR ()
 RETURN nil
ENDIF
* /
 // TITLE "search" + Program_Name ICON NIL MAIN; // Line 3 replaced by the line below 16/3 / 16w
DEFINE WINDOW AT Frm_BROWSE_GRID GetDesktopRealTop () GetDesktopRealLeft ();
 GetDesktopRealWidth WIDTH () GetDesktopRealHeight HEIGHT ();
 TITLE Program_Name ICON NIL MODAL;
 ON INIT Frm_BROWSE_GRID_form_oninit () ON RELEASE Nil;
 ON INTERACTIVECLOSE Frm_BROWSE_GRID_form_oninteractiveclose ();
 ON mouseclick Nil Nil ON ON MOUSEDRAG mousemove Nil;
 ON SIZE ON MAXIMIZE Nil Nil Nil ON MINIMIZE ON PAINT Nil;
 BACKCOLOR Nil Nil ON ON GotFocus LOSTFOCUS Nil
 
 KEY ACTION ON ESCAPE Thiswindow.Release ()

  DEFINE FRAME FramePesq
    ROW 10
    COL 10
    WIDTH 678
    HEIGHT 53
    FontName "Arial"
    FONTSIZE 9
    FontBold .T.
    FontItalic .F.
    FontUnderline .F.
    FONTSTRIKEOUT .F.
    CAPTION "Search for:"
    BACKCOLOR NIL
    FONTCOLOR NIL
    OPAQUE .T.
  END FRAME

  DEFINE TEXTBOX GetPesq
    ROW 30
    COL 190
    WIDTH 380
    HEIGHT 24
    FontName "Arial"
    FONTSIZE 9
    TOOLTIP ""
    onchange Nil
    OnGotFocus Nil
    OnLostFocus Nil
    FontBold .F.
    FontItalic .F.
    FontUnderline .F.
    FONTSTRIKEOUT .F.
    OnEnter (If (Frm_BROWSE_GRID.BotaoPesq.Enabled, Frm_BROWSE_GRID_botaopesq ()))
    HelpID Nil
    TABSTOP .T.
    VISIBLE .T.
    READONLY .F.
    RIGHTALIGN .F.
    DisabledBackColor Nil
    DISABLEDFONTCOLOR Nil
    CASECONVERT NONE
    MAXLENGTH 30
    BACKCOLOR NIL
    FONTCOLOR NIL
    InputMask Replicate ( "", 40)
    FORMAT NIL
    VALUE ""
  END TEXTBOX

  DEFINE COMBOBOX ComboPesq
    ROW 30
    COL 20
    WIDTH 160
    HEIGHT 100
    ITEMS aPesq
    VALUE 0
    FontName "Arial"
    FONTSIZE 9
    TOOLTIP ""
    Onchange Muda_Chave (This.Value)
    OnGotFocus Nil
    OnLostFocus Nil
    FontBold .F.
    FontItalic .F.
    FontUnderline .F.
    FONTSTRIKEOUT .F.
    HelpID Nil
    TABSTOP .T.
    VISIBLE .T.
    SORT .F.
    onEnter Nil
    ONDISPLAYCHANGE Nil
    DISPLAYEDIT .F.
    IMAGE Nil
    DROPPEDWIDTH 0
    OnDropDown Nil
    ONCLOSEUP Nil
  END COMBOBOX

  DEFINE BUTTON BotaoPesq
    ROW 20
    COL 700
    WIDTH 120
    HEIGHT 40
    ACTION Frm_BROWSE_GRID_botaopesq ()
    CAPTION "Search"
    FontName "Arial"
    FONTSIZE 9
    TOOLTIP ""
    FontBold .T.
    FontItalic .F.
    FontUnderline .F.
    FONTSTRIKEOUT .F.
    OnGotFocus Nil
    OnLostFocus Nil
    HelpID Nil
    FLAT .F.
    TABSTOP .T.
    VISIBLE .T.
    TRANSPARENT .F.
    MULTILINE .F.
    PICTURE Nil
    PICTALIGNMENT TOP
  END BUTTON
 
 DEFINE CHECKBOX Check_1
    ROW 30
    COL 585
    WIDTH 100
    HEIGHT 28
    CAPTION "Partial Search"
    VALUE .F.
    FontName "Arial"
    FONTSIZE 9
    TOOLTIP ""
    Onchange cProcura: = ""
    OnGotFocus Nil
    OnLostFocus Nil
    FontBold .F.
    FontItalic .F.
    FontUnderline .F.
    FONTSTRIKEOUT .F.
    BACKCOLOR Nil
    HelpID Nil
    TABSTOP .T.
    VISIBLE .T.
    TRANSPARENT .F.
  END CHECKBOX

  DEFINE GRID Grid_Data
    ROW 70
    COL 10
    GetDesktopRealWidth WIDTH () - 30
    HEIGHT GetDesktopRealHeight () - 116
    ITEMS Nil
    VALUE Nil
    Widths grid_data_widths ()
    HEADERS grid_data_headers ()
    FontName "Courier"
    FONTSIZE 9
    TOOLTIP ""
    onchange Nil
    OnGotFocus Nil
    OnLostFocus Nil
    FontBold .F.
    FontItalic .F.
    FontUnderline .F.
    FONTSTRIKEOUT .F.
    ondblclick Nil
    ONHEADCLICK Nil
    ONQUERYDATA Nil
    MULTISELECT .F.
    AllowEdit .T.
    VIRTUAL .F.
    grid_data_dynamicbackcolor DynamicBackColor ()
    DynamicForeColor Nil
    COLUMNWHEN Nil
    COLUMNVALID Nil
    COLUMNCONTROLS grid_data_columncontrols ()
    ShowHeaders .T.
    CELLNAVIGATION .F.
    NOLINES .F.
    HelpID Nil
    IMAGE Nil
    JUSTIFY grid_data_justify ()
    ITEMCOUNT Nil
    BACKCOLOR NIL
    FONTCOLOR NIL
    HEADERIMAGES Nil
    Rowsource "dbf"
    COLUMNFIELDS grid_data_columnfields ()
    ALLOWAPPEND .T.
    AllowDelete .T.
    BUFFERED .F.
    DYNAMICDISPLAY Nil
    onSave Nil
    LockColumns 0
  END GRID

END WINDOW
Frm_BROWSE_GRID.BotaoPesq.Enabled: F =..
Frm_BROWSE_GRID.Center
Frm_BROWSE_GRID.Activate
RETURN nil

FUNCTION grid_data_columnwhen ()
aColumnWhen LOCAL

  // {|| .T. } ALLOWS EDICAO
  // {|| .F. } NOT ALLOW THE ISSUE

 aColumnWhen: = {{|| .F. } ,;
 {|| .F. } ,;
 {|| .F. } ,;
 {|| .F. } ,;
 {|| .F. } ,;
 {|| .F. } ,;
 {|| .F. } ,;
 {|| .F. } ,;
 {|| .F. } ,;
 {|| .F. } ,;
 {|| .F. }}
         

RETURN aColumnWhen

FUNCTION grid_data_columncontrols ()
aColumnControls LOCAL

 aColumnControls: = {{ "TEXTBOX", "CHARACTER"} ,;
            { "TEXTBOX", "CHARACTER"} ,;
            { "TEXTBOX", "CHARACTER"} ,;
            { "TEXTBOX", "CHARACTER"} ,;
            { "TEXTBOX", "CHARACTER"} ,;
            { "TEXTBOX", "CHARACTER"} ,;
            { "TEXTBOX", "CHARACTER"} ,;
            { "TEXTBOX", "CHARACTER"} ,;
            { "TEXTBOX", "CHARACTER"} ,;
            { "TEXTBOX", "CHARACTER"} ,;
            { "TEXTBOX", "CHARACTER"}}
            

RETURN aColumnControls

FUNCTION grid_data_columnfields ()
aColumnFields LOCAL

  aColumnFields: = { '& fname .-> CDPRODUTO' ,;
            '& Fname .-> DSPRODUTO' ,;
            '& Fname .-> DSUNIDADE' ,;
            '& Fname .-> CDFORNECE' ,;
            '.- & Fname> CD_SECAO';
            '.- & Fname> CDGRUPO';
            '& Fname .-> VR_UNITAR' ,; // The original was "9.2" 20/2 / 16w
            '& Fname .-> VR_PRECUS' ,; // The original was "9.2" 20/2 / 16w
            '& Fname .-> VP_MARLUC' ,;
            '& Fname .-> VR_PREVEN' ,;
            '& Fname .-> DT_ULTCOM' ,;
            '& Fname .-> DT_ULTVEN' ,;
            '& Fname .-> QT_ESTMIN' ,;
            '& Fname .-> QT_ESTMAX' ,;
            '& Fname .-> QT_ESTTOT'}

/ * AColumnFields: = { "dbf-> nb" ,;
          "Dbf-> name" ,;
          "Dbf-> mun" ,;
          "Dbf-> cpf" ,;
          "Dbf-> born" ,;
          "Dbf-> nit" ,;
          "Dbf-> esp" ,;
          "Dbf-> der" ,;
          "Dbf-> Dumped" ,;
          "Dbf-> conc" ,;
          "Dbf-> tel"}
* /
          

RETURN aColumnFields

FUNCTION grid_data_headers ()
aheaders LOCAL

 aheaders: = CAB_CAMPOS

/ *
 aheaders: = { "Benefit" ,;
        "Name",;
        "County",;
        "CPF" ,;
        "Birth",;
        "NIT" ,;
        "Esp" ,;
        "Der" ,;
        "Expenses" ,;
        "Conc" ,;
        "Tel"}
* /

RETURN aheaders

FUNCTION grid_data_widths ()
awidths PLACE: = {}

 awidths: = {85, 280, 180, 100, 100, 100, 50, 100, 50, 100, 100}

RETURN awidths

FUNCTION grid_data_justify ()
ajustify PLACE: = {}

 ajustify: = {GRID_JTFY_CENTER ,;
        GRID_JTFY_LEFT ,;
        GRID_JTFY_LEFT ,;
        GRID_JTFY_CENTER ,;
        GRID_JTFY_CENTER ,;
        GRID_JTFY_CENTER ,;
        GRID_JTFY_CENTER ,;
        GRID_JTFY_CENTER ,;
        GRID_JTFY_CENTER ,;
        GRID_JTFY_CENTER ,;
        GRID_JTFY_CENTER}
        

RETURN ajustify

FUNCTION grid_data_DynamicBackColor ()
aDynamicBackColor PLACE: = {}

 aDynamicBackColor: = {bBackColor ,;
             bBackColor ,;
             bBackColor ,;
             bBackColor ,;
             bBackColor ,;
             bBackColor ,;
             bBackColor ,;
             bBackColor ,;
             bBackColor ,;
             bBackColor ,;
             bBackColor}
            

RETURN aDynamicBackColor

Function Muda_Chave (nVal)
cProcura: = ""
Frm_BROWSE_GRID.Grid_Data.Refresh
Frm_BROWSE_GRID.BotaoPesq.Enabled: = T..
Frm_BROWSE_GRID.GetPesq.SetFocus
return Nil

Frm_BROWSE_GRID_form_oninit function ()
return Nil

Frm_BROWSE_GRID_form_oninteractiveclose function ()
return Nil

Frm_BROWSE_GRID_botaopesq function ()
nVal Location: = GetProperty ( "Frm_BROWSE_GRID", "ComboPesq", "Value")
lVal Location: = GetProperty ( "Frm_BROWSE_GRID", "Check_1", "Value")
Local NREC: dbf = -> (RECNO ())
Local lContinua: F =..

cNewProcura: = alltrim (GetProperty ( "Frm_BROWSE_GRID", "GetPesq", "Value"))
If cNewProcura == cProcura
 lContinua: = T..
else
 cProcura: = cNewProcura
endif
dbf -> (OrdSetFocus (nVal))
if lVal
 the Case
   Case nVal = 1
    if lContinua
     Skip
    If Eof ()
     Goto Top
    endif
     Locate Rest for cProcura $ Nb
   else
    Locate is cProcura $ Nb
   endif
  Case nVal = 2
     if lContinua
     Skip
    If Eof ()
     Goto Top
    endif
     Locate Rest for cProcura $ Name
   else
     Locate for $ cProcura Name
   endif
  Case nVal = 3
     if lContinua
     Skip
    If Eof ()
     Goto Top
    endif
       Locate Rest for cProcura $ Mun
   else
     Locate is cProcura $ Mun
   endif
 ENDCASE
else
 dbf -> (DBSeek (cProcura))
endif
If! Found ()
 MsgStop (Chr (34) + cProcura + Chr (34) + Chr (13) + Chr (10) + "not found in" + aPesq [nVal] + "!")
 dbf -> (OrdSetFocus (0))
 Goto nrec
 Frm_BROWSE_GRID.Grid_Data.Refresh
else
 dbf -> (OrdSetFocus (0))
 Frm_BROWSE_GRID.Grid_Data.Value: = {dbf -> (RECNO ())} nVal
endif
Frm_BROWSE_GRID.Grid_Data.SetFocus
return Nil

*********************************************************************************************************
************************** Code of C / C ++ language ****************** *********************************
#pragma BEGINDUMP

#define HB_OS_WIN_USED
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include "hbapi.h"

HB_FUNC (GETDESKTOPREALTOP)
{
 RECT rect;
 SystemParametersInfo (SPI_GETWORKAREA, 1, & rect, 0);

 hb_retni (rect.top);

}
HB_FUNC (GETDESKTOPREALLEFT)
{
 RECT rect;
 SystemParametersInfo (SPI_GETWORKAREA, 1, & rect, 0);

 hb_retni (rect.left);

}

HB_FUNC (GETDESKTOPREALWIDTH)
{
 RECT rect;
 SystemParametersInfo (SPI_GETWORKAREA, 1, & rect, 0);

 hb_retni (rect.right - rect.left);

}

HB_FUNC (GETDESKTOPREALHEIGHT)
{
 RECT rect;
 SystemParametersInfo (SPI_GETWORKAREA, 1, & rect, 0);

 hb_retni (rect.bottom - rect.top);
}

#pragma ENDDUMP
************************** Code of C / C ++ language ****************** *********************************
*********************************************************************************************************
OBSs:
1 - At the beginning of my system created several arrays with the name, field contents, indexes all the files. In the case here, the file is DCI10010 (products), but I want to send to the function also this matrix.
2 - I'm using HMG 3.4.2.
3 - The call to this function is:

Code: Select all

 CRIABROWSE_GRID (VARIABLE, 'PCI10011', FILENAME, CABEC_CAMPOS, TAM_MEMO, MASKS, FILE) [/ code]
Further, the content and explanation of each element is passed:
VARIABLE = the old GET variable which was pressed F4 (ah this key triggers this CRIABROWSE_GRID!);
PCI10011 = module name that is calling the function;
FILENAME = filename in the user's language, in the example above: "Products";
CABEC_CAMPOS = array containing all the headers (the field name for the user play / view);
TAM_MEM = array containing memo fields, if any. In the example = phenyl (each array element);
MASKS = Picture (of clipper @ say / get) for formatting the look of the fields;
FILE = select the content () current, ie the name of the open file.
I will also add the array containing all the complete file data, but still could not think how to do this in general.
In the case of product file, see, I pray you, the content of DCI10010 matrix (PRODUCT):
[Code] private DCI10010: = {{{ 'GOODS' ,;
           'Products',;
           '& DIR \ PRODUTOS.DBF'} ,;
           { 'ICI10010' ,;
           'Str (CDPRODUTO, 13)' ,;
           '& DIR \ DCI10010.NTX'} ,;
           { 'ICI10700' ,;
           'DSPRODUTO' ,;
           '& DIR \ ICI10700.NTX'} ,;
           { 'ICI10701' ,;
           'Str (CDGRUPO 02) + DSPRODUTO' ,;
           '& DIR \ ICI10701.NTX'} ,;
           { 'ICI10702' ,;
           'Str (CDFORNECE, 04) + str (CDGRUPO 02) + DSPRODUTO' ,;
           '& DIR \ ICI10702.NTX'}} ,;
          { 'CDPRODUTO', 'N', 13, 0} ,;
          { 'DSPRODUTO', 'C', 40, 0} ,;
          { 'DSUNIDADE', 'C', 2, 0} ,;
          { 'CDFORNECE', N '', 4, 0} ,;
          { 'CD_SECAO', N '', 1, 0} ,;
          { 'CDGRUPO', 'C', 2, 0} ,;
          { 'VR_UNITAR', 'N', 10, 4} ,; // The original was "9.2" 20/2 / 16w
          { 'VR_PRECUS', 'N', 10, 4} ,; // The original was "9.2" 20/2 / 16w
          { 'VP_MARLUC', N '', 6} 2 ,;
          { 'VR_PREVEN', N '', 9} 2 ,;
          { 'DT_ULTCOM', 'D', 8, 0} ,;
          { 'DT_ULTVEN', 'D', 8, 0} ,;
          { 'QT_ESTMIN', N '', 6} 2 ,;
          { 'QT_ESTMAX', N '', 6} 2 ,;
          { 'QT_ESTTOT', 'N', 8, 3}} 
Well, now back to the example that the teacher posted and that I modified for my example, I changed some things to stay as close to my reality, but the most dramatic of them was to change the MAIN form to modal, since I already have a MAIN open.
Unfortunately, the error messages were many, please see:

Code: Select all

 Harbour 3.2.0dev (r1509031202)
Copyright (c) 1999-2015, http://harbour-project.org/
C: \ MVinfo \ MIGRATE \ sicca \ SiCCA3603hmg \ sci10000 \ rotinas6.prg (54) E0030 Error Syntax error "syntax error at 'WINDOW'"
C: \ MVinfo \ MIGRATE \ sicca \ SiCCA3603hmg \ sci10000 \ rotinas6.prg (72) E0030 Error Syntax error "syntax error at '.T.'"
C: \ MVinfo \ MIGRATE \ sicca \ SiCCA3603hmg \ sci10000 \ rotinas6.prg (90) E0030 Error Syntax error "syntax error at '.'"
C: \ MVinfo \ MIGRATE \ sicca \ SiCCA3603hmg \ sci10000 \ rotinas6.prg (157) Error E0030 Syntax error "syntax error at '.F.'"
C: \ MVinfo \ MIGRATE \ sicca \ SiCCA3603hmg \ sci10000 \ rotinas6.prg (184) Error E0030 Syntax error "syntax error at '.F.'"
C: \ MVinfo \ MIGRATE \ sicca \ SiCCA3603hmg \ sci10000 \ rotinas6.prg (238) Error E0030 Syntax error "syntax error at '.'"
C: \ MVinfo \ MIGRATE \ sicca \ SiCCA3603hmg \ sci10000 \ rotinas6.prg (239) Error E0030 Syntax error "syntax error at '.'"
C: \ MVinfo \ MIGRATE \ sicca \ SiCCA3603hmg \ sci10000 \ rotinas6.prg (240) Error E0030 Syntax error "syntax error at '.'"
C: \ MVinfo \ MIGRATE \ sicca \ SiCCA3603hmg \ sci10000 \ rotinas6.prg (383) Error E0030 Syntax error "syntax error at '.'"
C: \ MVinfo \ MIGRATE \ sicca \ SiCCA3603hmg \ sci10000 \ rotinas6.prg (384) Error E0030 Syntax error "syntax error at '.'"
C: \ MVinfo \ MIGRATE \ sicca \ SiCCA3603hmg \ sci10000 \ rotinas6.prg (385) Error E0030 Syntax error "syntax error at '.'"
C: \ MVinfo \ MIGRATE \ sicca \ SiCCA3603hmg \ sci10000 \ rotinas6.prg (447) Error E0030 Syntax error "syntax error at '.'"
C: \ MVinfo \ MIGRATE \ sicca \ SiCCA3603hmg \ sci10000 \ rotinas6.prg (450) Error E0030 Syntax error "syntax error at '.'"
C: \ MVinfo \ MIGRATE \ sicca \ SiCCA3603hmg \ sci10000 \ rotinas6.prg (452) Error E0030 Syntax error "syntax error at '.'"
14 errors
In the code generated. 
The above lines are the following:
54 (Line) - This is not only because it is a line with (;):
DEFINE WINDOW AT Frm_BROWSE_GRID GetDesktopRealTop () GetDesktopRealLeft ();
GetDesktopRealWidth WIDTH () GetDesktopRealHeight HEIGHT ();
TITLE Program_Name ICON NIL MODAL;
ON INIT Frm_BROWSE_GRID_form_oninit () ON RELEASE Nil;
ON INTERACTIVECLOSE Frm_BROWSE_GRID_form_oninteractiveclose ();
ON mouseclick Nil Nil ON ON MOUSEDRAG mousemove Nil;
ON SIZE ON MAXIMIZE Nil Nil Nil ON MINIMIZE ON PAINT Nil;
BACKCOLOR Nil Nil ON ON GotFocus LOSTFOCUS Nil
The remaining lines of the errors are:
72 - OPAQUE .T.
90 - onEnter (If (Frm_BROWSE_GRID.BotaoPesq.Enabled, Frm_BROWSE_GRID_botaopesq ()))
157-184 TRANSPARENT .F.
238-240
Frm_BROWSE_GRID.BotaoPesq.Enabled: F =..
Frm_BROWSE_GRID.Center
Frm_BROWSE_GRID.Activate
383-385
Frm_BROWSE_GRID.Grid_Data.Refresh
Frm_BROWSE_GRID.BotaoPesq.Enabled: = T..
Frm_BROWSE_GRID.GetPesq.SetFocus
447 - Frm_BROWSE_GRID.Grid_Data.Refresh
450 - Frm_BROWSE_GRID.Grid_Data.Value: = {dbf -> (RECNO ())} nVal
452 - Frm_BROWSE_GRID.Grid_Data.SetFocus
Well, I think the only line I know to solve (I think) is the 450 because I changed the "alias" dbf the name of mine who is fname, but just think, I'm not sure.
One last piece of information: My system is still DBFNTX, then the search will be around that. Do not ask me "how?", Because I do not know.
So if some of the teachers can help us clear the mind, because this graphic universe, had even given up (temporarily) December / 2015 to March / 2016 using GTWVG. But I realized that in some cases have no escape.
And in the case of a Store Front without many graphical information, it is even difficult to sell a system that market so competitive

MICROVOLUTION
Posts: 24
Joined: Sat May 30, 2015 5:15 am

Post by MICROVOLUTION » Tue Dec 05, 2017 11:04 am

Good Morning.
I'm learning to migrate now by the graphical mode that HMG allows using IDE / HMG 3.4.4. a screen for supermarket sale.
As we are accustomed as the procedural mode of the traditional clipper / harbor language I still can not understand the idea of ​​how POO works - Object Oriented Programming. I know that for most of you what I'm going to ask "may even be" idiotisse, but, I need a lot of help, otherwise I would not be bothering them.
My system is mixed (console along with gui).
Then in this first GUI screen, it is called by the CONSOLE screen which contains the main menu and sub-menus.

To receive the products and quantities of the sale, I am using two (2) TEXTBOX.
For them to appear on the screen, I'm using a MATRIX that is placed inside the GRID_

As soon as the user enters the product code (TXTCDPRODUTO) it automatically goes to the TXTQT (TEXTBOX of the quantity of that product that will be released on sale.

Well, so far so good. But when you check the quantity in the stock and that everything is okay, we show on the left screen a replica of what the printed version will look like.
Products are usually launched on-screen through GRID_

The PROBLEM is the moment you click on the GRID horizontal scroll bar to see all. I created a screen with a very basic GRID (as in ACHOICE that it is exclusively for CONSOLE) ... the GRID erases everything that is shown and the system is so slow looking like a wagon.

My GRID_ codes are in a few lines. See:

Code: Select all

define window frm_main
(...)
                        define GRID grid_1
                           row 50
                           col 08
                           WIDTH 440 
                           HEIGHT 350 
                           HEADERS {'Cd','Nome Prd','Qt','Vr.Un.','Vr.Total'} 
                           WIDTHS {100,240,30,50,100,120}
                           ColumnCONTROLS { {'TEXTBOX','NUMERIC', '999999999999'} , 'TEXTBOX' , 'TEXTBOX' , 'TEXTBOX' , 'TEXTBOX' } 
                           DYNAMICFORECOLOR { fColor , fColor , fColor , fColor , fColor } 
                           cellnavigation .t.
                           EDITOPTION GRID_EDIT_DEFAULT
                           allowedit .t.
                        end GRID
(...)
end window
the above lines are to start the GRID TEXTBOX, labels, etc.

Now the lines below are after the end of END WINDOW and are to individually place the products on the screen through GRID - as I explained well above.

Code: Select all

     Frm_Main.Grid_1.AddItem ( { prod[01,01] , prod[01,02] , prod[01,03], prod[01,04], prod[01,05] } )
just that are my grid lines and nothing else.
The images before clicking on the scroll bar and after clicking are just below.
If anyone knows and can help me, I will be grateful↓:
antes do erro →
grid_antes do erro.png
grid_antes do erro.png (10.85 KiB) Viewed 297 times
após clicarmos na barra de rolagem o sistema trava/fica lento →
grid_após erro.png
grid_após erro.png (8.09 KiB) Viewed 297 times

User avatar
andyglezl
Posts: 859
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 7 times
Been thanked: 25 times
Contact:

Post by andyglezl » Wed Dec 06, 2017 3:48 pm

Andrés González López
Desde Guadalajara, Jalisco. México.

franco
Posts: 213
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Wed Dec 06, 2017 5:02 pm

Do you have a working consol clipper pos system . And are you using tables.....

franco
Posts: 213
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Wed Dec 06, 2017 6:50 pm

Thanks andres, I am going to try grid refresh() instead of grid save. If I need more help I will create new post.
Franco ;)
Last edited by franco on Wed Dec 06, 2017 8:55 pm, edited 2 times in total.

User avatar
andyglezl
Posts: 859
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 7 times
Been thanked: 25 times
Contact:

Post by andyglezl » Wed Dec 06, 2017 7:21 pm

Hola Franco

Porqué no copias a un array (como respaldo) la columna que necesitas
y antes de guardar las puedes comparas ?
-----------------------------------------------------------------------------------------
Hi Franco

Why not copy to an array (as backup) the column you need
And before you save you can compared?


P.D.
Franco ó Microvolution, creo que deben de hacer su pregunta en otro hilo
para no confundir las respuestas de los 2.
----------------------------------------------------------------------------
Franco or Microvolution, I think you should ask your question in another thread
To not confuse the answers of the 2.
Andrés González López
Desde Guadalajara, Jalisco. México.

franco
Posts: 213
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Wed Dec 06, 2017 8:30 pm

Andres, Thank you I will create a new post. I do not know how to remove this post.

User avatar
serge_girard
Posts: 1907
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 318 times
Been thanked: 74 times
Contact:

Post by serge_girard » Thu Dec 07, 2017 9:03 am

Microvolution,

Please send all source in a ZIP file in a new topic. Much easier!

Serge

Post Reply