1
EXEMPLO DE PIVO,GRAFICO,ESTRUTURA
ROTINAS DIVERSAS
WIN_PIVO
_arquivos is Structure
representante_nome is string
cidade_nome is string
cliente_nome is string
data_Venda is Date
valor_Venda is currency
END
st_arquivo is _arquivos
garr_array is array of _arquivos
=================
//st_arquivo is _arquivos
//garr_array is array of _arquivos
TableDeleteAll(TABLE_PIVO)
FOR EACH duplicata_pagar
st_arquivo.representante_nome="AMARILDO"
st_arquivo.cidade_nome="NOVO HAMBURGO"
st_arquivo.cliente_nome="ASSS"
st_arquivo.data_Venda=duplicata_pagar.data_vencimento
st_arquivo.valor_Venda=duplicata_pagar.valor_titulo
TableAddLine(TABLE_PIVO,st_arquivo.representante_nome,st_arquivo.cidade_nome,st_arquivo.cliente_nome,st_arquivo.data_Venda,st_arquivo.valor_Venda)
ArrayAddLine(garr_array,st_arquivo)
END
IF KeyPressed(VK_F5) THEN
MyWindow..Plane=2
ReturnToCapture(EDT_NomeMaterial)
END
// C:\WINDEV 20\Personal\External
// Definition of constants used by Windows for the keyboard keys
// (especially _EVE.wparam in WM_KEYDOWN)
// The keys from [0] to [9] and from [A] to [Z] are identified by their ASCII code
// (charact("0")=0x30 - charact("9")=0x39) and (charact("A")=0x41 - charact("Z")=0x5A)
// Check beside Microsoft (msdn.microsoft.com) for a full description of these constants
// These constants can only be used with KeyPressed() and
// with the following APIs: GetAsyncKeyState() and GetKeyState().
// These values are returned by no message or API. DON'T test them in WM_KEYDOWN.
VK_LSHIFT = 0xA0
VK_RSHIFT = 0xA1
VK_LCONTROL = 0xA2
VK_RCONTROL = 0xA3
VK_LMENU = 0xA4
VK_RMENU = 0xA5
PROCEDURE matos_f_Soma_Com_Peso_Desc(pNro is string, _MenorPeso is int)
_Tam is int = Length(pNro)
_Peso is 2-byte unsigned int = 0
FOR i=1 TO _Tam
_Peso = _Peso + (Asc(pNro[[i]]) -48) * (_Tam-i+_MenorPeso)
END
RESULT _Peso
---------------------------------------------------------------------------------------------------------------------
// (c) Matos Informatica - 26 02 2015
// Summary: retorna TRUE se o CNPJ está correto ou FALSE se está incorreto
// Syntax:
//[ <Result> = ] matos_f_cnpj_validar (<pCNPJ> is string)
//
// Parameters:
// pCNPJ (ANSI string): número da inscrição CNPJ-MF
// Return Value:
// boolean: TRUE se o CNPJ está correto ou FALSE se está incorreto
// Matos 26 02 2015
PROCEDURE matos_f_cnpj_validar(pCNPJ is string)
_CNPJ is string
_Peso is 2-byte unsigned int
_Resto is 1-byte int
_Digito is 1-byte int
FOR i=1 _TO_ Length(pCNPJ)
IF 47 < Asc(pCNPJ[[i]]) < 58 THEN _CNPJ+=pCNPJ[[i]]
END
IF Length(_CNPJ) <> 14 THEN RESULT False
// calculo do primeiro digito verificador (posição 13)
_Peso = matos_f_Soma_Com_Peso_Desc(_CNPJ[[1 TO 4]],2) ...
+ matos_f_Soma_Com_Peso_Desc(_CNPJ[[5 TO 12]],2)
_Resto = modulo(_Peso,11)
IF _Resto < 2 THEN _Digito = 0 ELSE _Digito = 11 - _Resto
IF Asc(_CNPJ[[13]])-48 <> _Digito THEN RESULT False
// calculo do segundo digito verificador (posição 14)
_Peso = matos_f_Soma_Com_Peso_Desc(_CNPJ[[1 TO 5]],2) ...
+ matos_f_Soma_Com_Peso_Desc(_CNPJ[[6 TO 13]],2)
_Resto = modulo(_Peso,11)
IF _Resto < 2 THEN _Digito = 0 ELSE _Digito = 11 - _Resto
IF Asc(_CNPJ[[14]])-48 <> _Digito THEN RESULT False ELSE RESULT True