Amiguinhos,
No caso de arquivos .MEM ao utilizar o salvamento de variaveis nele ele irá levar todas as variaveis ativas na memoria, no seu caso para facilitar, crie as variaveis com referencia direta a tabela manipulada, ex:
Código: Selecionar todos
...
CLIENTES_NOME := "ROCHINHA"
CLIENTES_FONE := "(011)3534-3099"
...
Use o comando
SAVE TO clientes ALL LIKE CLIENTES_*
Para auxiliar na sua empreitada analise o trecho abaixo:
Código: Selecionar todos
#include "hbclass.ch" // cabeçalho para uso de classe
CLASS Tnfwh
DATA cTitle
DATA aTables
DATA aFields
METHOD New( cTitle, aTables ) CONSTRUCTOR
METHOD AddReg()
METHOD recuperarPorCodigo( cCod )
METHOD incluir()
ENDCLASS
METHOD New( cTitle, aTables ) CLASS Tnfwh
::cTitle := Tnfwh
::aTables := aTables
::aFields := {}
return nil
METHOD AddReg() CLASS Tnfwh
LOCAL field_cnt := fcount()
LOCAL counter := 0
private field_name
field_cnt = fcount()
for counter = 1 to field_cnt
field_name = lower(field(counter))
::aFields
public &field_name
next
RETURN Self
METHOD recuperarPorCodigo( cCod ) CLASS TCliente
local lRet
use clientes shared new
index on codigo to i_cod
seek cCod
if found()
::codigo := allTrim( clientes->codigo )
::nome := allTrim( clientes->nome )
lRet := .t.
else
lRet := .f.
endif
close clientes
return lRet
METHOD incluir() CLASS TCliente
local cNovoCod
use clientes shared new
dbGoBottom()
cNovoCod = strZero( val(clientes->codigo)+1, 5 )
if ( alltrim( ::nome ) == "" )
alert( "Campo NOME não pode ser vazio no método de inclusão!" )
close clientes
return .f.
endif
dbAppend()
clientes->codigo := cNovoCod
::codigo := cNovoCod
clientes->nome := upper( ::nome )
dbCommit()
close clientes
return .t.
FUNCTION InitVars()
local field_cnt := fcount(), counter := 0
private field_name
field_cnt = fcount()
for counter = 1 to field_cnt
field_name = lower(field(counter))
public &field_name
next
return(.t.)
FUNCTION initObjs
local field_cnt := fcount(), counter := 0
private field_name, retorno := {}
field_cnt = fcount()
for counter = 1 to field_cnt
field_name = "o" + lower(field(counter))
field_reto = AADD( retorno, "o" + lower(field(counter)) )
public &field_name
next
return retorno
FUNCTION RefreshObjs
local field_cnt := fcount(), counter := 0
private field_name, retorno := {}
field_cnt = fcount()
for counter = 1 to field_cnt
field_name = "o"+alltrim(lower(field(counter)))+":Refresh()"
eval( {|| &field_name })
next
return retorno
FUNCTION EqualVars
local field_cnt := fcount(), counter := 0
private field_name, retorno := {}
field_cnt = fcount()
for counter = 1 to field_cnt
field_name = LOWER(FIELD(counter))
M->&field_name := _FIELD->&field_name
next
return retorno
FUNCTION ReplaceVars
local field_cnt := fcount(), counter := 0
private field_name, retorno := {}
field_cnt = fcount()
for counter = 1 to field_cnt
field_name = LOWER(FIELD(counter))
_FIELD->&field_name := m->&field_name
next
return retorno
FUNCTION ReleaseVars
local field_cnt := fcount(), counter := 0
private field_name, retorno := {}
field_cnt = fcount()
for counter = 1 to field_cnt
field_name = LOWER(FIELD(counter))
RELEASE m->&field_name
next
return retorno
Este é um código puramente academico e não foi testado.