Há poucos dias com a ajuda de vocês consegui colocar os gets numéricos para avançar da direita para a esquerda, então tomei a liberdade de modificar o getsys postado pelo Daniel e colocar uma ajuda a cada GET, ou seja, a medida em que o opegador vai navegando pelos GETs vai aparecendo um box com uma informação previamente definida pelo programador.
Para que isso podesse acontecer, foi criado um comando chamado AJUDA no formato ( AJUDA "Help a informar para o usuário" ), que está no arquivo teste.ch.
Para quebrar as linhas, basta colocar um "|" na frase, que a função dbox vai quebrar a menssagem a ser passada ao usuário, Ex:
Código: Selecionar todos
@ 1,1 GET mCampo ;
Pict "@!";
Vali mCampo $ 'MF'
AJUDA 'Sexo:| Masculino|Feminino'
READ
...vai aparecer assim:
[_] <---- //campo a getar
+-------------+ <---- //ajuda mostrada na tela
|Sexo: |
| Masculino |
| Feminino |
+-------------+
Para o box ser mostrado na tela, usei a lib do GAS (GASP52PM.LIB), que contém as funções CONTA() e DBOX().
Deverá ser usadas também as variáveis DRVxxx. que contém as informações das cores usadas na função DBOX.
Abaixo segue os arquivos:
Arquivo TESTE.CH
Código: Selecionar todos
/*
Comandos criados para auxiliar o comando GET para receber mais outros
parametro e armazenar na variavel de instancia "CARGO". Este artificio
e' usado para guardar o texto de ajuda.
Criador : Clodoaldo Monteiro
Rotinas do GASDOS
*/
#command AJUDA <var> => STORECARGO(<var>,ATAIL(getlist),1)
Código: Selecionar todos
#include "Getexit.ch"
#include "Inkey.ch"
#include "TESTE.ch"
LOCAL nVar1 := 0.00, ;
nVar2 := 0, ;
cVar2 := Space(12), ;
nVar3 := 0
LOCAL GetList := {}
// vari veis para a fun‡Æo dbox() e errorsys()
drvcara=CHR(178); mold="ÚÄ¿³ÙÄÀ³ÃÄ´"
drvmenucen=.f.
drvcorpad="W+/RB" ; drvcorbox="W+/B" // cores default
drvcormsg="W+/N*" ; drvcorenf="W+/R"
drvcorget="W+/BG" ; drvcortel="W+/B"
drvcorhlp="GR+/G" ; drvcortna="GR/N"
drvtitpad="GR+/RB" ; drvtitbox="GR+/B" // cores dos titulos default
drvtitmsg="GR+/N*" ; drvtitenf="GR+/R"
drvtitget="GR+/BG" ; drvtittel="GR+/B"
drvtithlp="W+/G" ; drvtittna="W/N"
CLEAR SCREEN
@ 10, 10 SAY "Enter nVar1" GET nVar1 pict '@E 999,999,999.99'
@ 11, 10 SAY "Enter nVar2" GET nVar2 PICT '@E 999,999,999.99'
AJUDA 'Entre com o valor da vari vel 2'
@ 12, 10 SAY "Enter cVar2" GET cVar2 PICT '@!'
AJUDA 'Informe a vari vel 3'
@ 13, 10 SAY "Enter nVar3" GET nVar3 PICT '@E 999,999,999.99'
READ
RETUCódigo: Selecionar todos
/***
*
* Getsys.prg
*
* Standard Clipper 5.2 GET/READ Subsystem
*
* Copyright (c) 1991-1993, Computer Associates International, Inc.
* All rights reserved.
*
* This version adds the following public functions:
*
* ReadKill( [<lKill>] ) --> lKill
* ReadUpdated( [<lUpdated>] ) --> lUpdated
* ReadFormat( [<bFormat>] ) --> bFormat | NIL
*
* NOTE: compile with /m /n /w
*
* Alterada por : Dercide de Freitas Alvarez
* Utilize para entrada numerica "@EZ 999,999,999.99"
* A Barra de espaco limpa o campo
* A acentuacao devera ser feita usando virgula e aspas simples
* sempre antes da tecla.
* Alterada por : Daniel Denobie
* Picture "@M" para letras minuscula (ideia do Toledo)
*
*/
#include "Inkey.ch"
#include "Getexit.ch"
/***
* Nation Message Constants
* These constants are used with the NationMsg(<msg>) function.
* The <msg> parameter can range from 1-12 and returns the national
* version of the system message.
*/
#define _GET_INSERT_ON 7 // "Ins"
#define _GET_INSERT_OFF 8 // " "
#define _GET_INVD_DATE 9 // "Invalid Date"
#define _GET_RANGE_FROM 10 // "Range: "
#define _GET_RANGE_TO 11 // " - "
#define K_UNDO K_CTRL_U
//#define O_HELP 7 // texto de ajuda on-line do campo
//
// State variables for active READ
//
STATIC sbFormat
STATIC slUpdated := .F.
STATIC slKillRead
STATIC slBumpTop
STATIC slBumpBot
STATIC snLastExitState
STATIC snLastPos
STATIC soActiveGet
STATIC scReadProcName
STATIC snReadProcLine
//
// Format of array used to preserve state variables
//
#define GSV_KILLREAD 1
#define GSV_BUMPTOP 2
#define GSV_BUMPBOT 3
#define GSV_LASTEXIT 4
#define GSV_LASTPOS 5
#define GSV_ACTIVEGET 6
#define GSV_READVAR 7
#define GSV_READPROCNAME 8
#define GSV_READPROCLINE 9
#define GSV_COUNT 9
/***
*
* ReadModal()
*
* Standard modal READ on an array of GETs
*
*/
FUNCTION ReadModal( GetList, nPos )
LOCAL oGet
LOCAL aSavGetSysVars
LOCAL nCursor := SetCursor()
drvautohelp=IF(TYPE("drvautohelp")!="L",.t.,drvautohelp)
IF ( VALTYPE( sbFormat ) == "B" )
EVAL( sbFormat )
ENDIF
IF ( EMPTY( GetList ) )
// S'87 compatibility
SETPOS( MAXROW() - 1, 0 )
RETURN (.F.) // NOTE
ENDIF
// Preserve state variables
aSavGetSysVars := ClearGetSysVars()
// Set these for use in SET KEYs
scReadProcName := PROCNAME( 1 )
snReadProcLine := PROCLINE( 1 )
// Set initial GET to be read
IF !( VALTYPE( nPos ) == "N" .AND. nPos > 0 )
nPos := Settle( Getlist, 0 )
ENDIF
IF READINSERT()
SETCURSOR(2) // modo de Inser‡„o
ELSE
SETCURSOR(1) // modo normal
ENDIF
WHILE !( nPos == 0 )
// Get next GET from list and post it as the active GET
PostActiveGet( oGet := GetList[ nPos ] )
// Read the GET
IF ( VALTYPE( oGet:reader ) == "B" )
EVAL( oGet:reader, oGet ) // Use custom reader block
ELSE
GetReader( oGet ) // Use standard reader
ENDIF
// Move to next GET based on exit condition
nPos := Settle( GetList, nPos )
ENDDO
// Restore state variables
SETCURSOR(nCursor)
RestoreGetSysVars( aSavGetSysVars )
// S'87 compatibility
SETPOS( MAXROW() - 1, 0 )
RETURN ( slUpdated )
/***
*
* GetReader()
*
* Standard modal read of a single GET
*
*/
PROCEDURE GetReader( oGet )
LOCAL nKey,cKey,cRet,original
LOCAL press, pp, Tecl_p, ar_db:=ALIAS(), n_cp, qt_lin_hlp, lihlp, tela_hlp,;
c_box, t_box, tmp_, vlr_defa:=.f., ncol,nrow
PRIVATE lPrimKey := .T.
PRIV im_aj_at_:=0
oget:setfocus() // complementar entao ativa o GET
tmp_=READVAR()
IF !EMPT(oget:cargo) //.AND. EMPT(&tmp_.) // se o campo esta vazio e pode ter valor inicial
tmp_=oget:cargo
IF VALTYPE(tmp_)="A" .AND. LEN(tmp_)>2 // se o valor definido no "cargo"
IF !EMPT(tmp_[3]).AND.EMPT(oget:original) // e' o valor inicial
tmp_=EVAL(&("{||"+tmp_[3]+"}")) // pega o default
lihlp=LEN(get:buffer)
IF oget:picture=NIL .OR. AT("@K",oget:picture)>0 .OR. AT("@S",oget:picture)>0
pp="@X"
ELSE
pp=oget:picture
ENDI
oget:buffer:=LEFT(TRAN(tmp_,pp)+SPAC(lihlp),lihlp)
oget:assign()
updated:= .T.
vlr_defa:=.t.
ENDI
ENDI
ENDI
oget:killfocus() // desativa o GET
// Read the GET if the WHEN condition is satisfied
IF ( GetPreValidate( oGet ) )
// Activate the GET for reading
oGet:setFocus()
WHILE ( oGet:exitState == GE_NOEXIT )
lihlp=0
IF im_aj_at_<2 // ajuda em cada campo
IF drvautohelp .AND. !EMPT(oget:cargo)
tmp_=oget:cargo
IF !EMPT(tmp_[1])
qt_lin_hlp=CONTA("|",tmp_[1])+1 //at2() ‚ uma fun‡Æo da fast.lib
IF oget:row+qt_lin_hlp+3>MAXROW()
IF oget:row-qt_lin_hlp-3>=0
lihlp=oget:row-qt_lin_hlp-3
ENDI
ELSE
lihlp=oget:row+1
ENDI
IF lihlp>0
tela_hlp=SAVESCREEN(0,0,MAXROW(),79)
c_box=drvcorbox; t_box=drvtitbox
drvcorbox=drvcorhlp; drvtitbox=drvtithlp
DBOX(tmp_[1],lihlp,oget:col+2,,.F.)
drvcorbox=c_box; drvtitbox=t_box
ENDI
ENDI
ENDI
IF im_aj_at_=1
DISPEND() // apresenta tela de uma vez so
ENDI
ENDI
im_aj_at_=3
// Check for initial typeout (no editable positions)
IF ( oGet:typeOut )
oGet:exitState := GE_ENTER
ENDIF
// Tratamento para entrada Direita -> Esquerda
IF ( oGet:type == "N" ) .And. ( Len( oGet:buffer ) > oGet:DecPos )
oGet:Pos := Len( oGet:buffer ) + 1
oGet:End()
oGet:ToDecPos()
oGet:Left()
ELSEIF ( oGet:type == "N" )
oGet:Pos := Len( oGet:buffer ) + 1
oGet:End()
ENDIF
cKey := ''
nKey := 0
// Apply keystrokes until exit
original := oGet:buffer
WHILE ( oGet:exitState == GE_NOEXIT )
// Armazena a tecla que foi pressionada anteriormente
cKey := Chr(nKey)
// Le a Pr¢xima tecla
nKey := inkey( 0 )
// Ajusta Caract‚r de Retorno
IF !READINSERT()
cRet := CHR(19)
ELSE
cRet := CHR(08)
ENDIF
// Faz o tratamento dos acentos
IF ( oGet:type == "C" )
* @ 24, 10 say oGet:picture
* Inkey(0)
// Virgula
IF ( cKey = CHR(44) )
IF ( nKey = ASC("c") )
KEYBOARD cRet + '‡'
LOOP
ENDIF
IF ( nKey = ASC("C") )
KEYBOARD cRet + '€'
LOOP
ENDIF
ENDIF
// Aspas
IF ( cKey = CHR(34) )
IF ( nKey = ASC('U') )
KEYBOARD cRet + 'š'
LOOP
ENDIF
IF ( nKey = ASC('u') )
KEYBOARD cRet + '



