GETLIST

478 views
Skip to first unread message

Mohamed Hamza

unread,
Oct 18, 2024, 11:34:51 AMOct 18
to Harbour Users
HI ALL,

HOW TO USE THE GETSYS.PRG TO MANIPULATE  2 OR MORE GETLIST(S).

REGARDS.

MED

davi...@aldeiadigital.com

unread,
Oct 18, 2024, 1:24:54 PMOct 18
to Harbour Users
Maybe you should describe the scenario and your need better.

Hurricane

unread,
Oct 18, 2024, 8:17:23 PMOct 18
to Harbour Users
@gets pending and want to open another @gets list, right?!

//just this:
LOCAL getlist:={}
//... in every function that contains READ.

This is the traditional way to keep each @...GETs list separate...

Hurricane
Em sexta-feira, 18 de outubro de 2024 às 12:34:51 UTC-3, Mohamed Hamza escreveu:

Mohamed Hamza

unread,
Oct 19, 2024, 3:29:16 AMOct 19
to Harbour Users
Hi Hurricane,

I agree  with you , but where to perform the second readmodal() in the getsys.prg?
Regards.
Med

Francesco Perillo

unread,
Oct 19, 2024, 3:46:09 AMOct 19
to harbou...@googlegroups.com
If i understand correctly you want to do nested GETs...

If you look at how @ GET is translated to code, you fill find it just use a variable to hold all the informations, probably the variable name is aGetList or something similar.

I remember to save that variable and define a new PRIVATE aGetList whose visibility is now active.

--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/136e6f4f-077c-414e-8c54-f6bc6268f5c5n%40googlegroups.com.

cod...@outlook.com

unread,
Oct 19, 2024, 4:22:29 AMOct 19
to Harbour Users

For every new GET-READ part, make Getlist as LOCAL Getlist:={}.

I assume that each new GET-READ part is in separate function.

In this way GET variables in one GET-READ part is independent from GET variables in other GET-READ part.

Regards,

Simo.

Mohamed Hamza

unread,
Oct 19, 2024, 7:51:21 AMOct 19
to Harbour Users
Hi,

Do we have to  change the  FUNCTION Settle( GetList, nPos, lInit ) (getsys.prg)    in the  case where the get selected by the user does not belong  to the current getlist.

Regards.
Med  

José M. C. Quintas

unread,
Oct 19, 2024, 10:30:24 AMOct 19
to harbou...@googlegroups.com

PROCEDURE Main

   LOCAL a, b, c, d

LOCAL GetList := {}

   a := b := c := d := Space(20)

   SetMode(25,80)

   CLS

   @ 1, 0 GET a VALID OtherGet( @c, @d )

   @ 2, 0 GET b VALID OtherGet( @c, @d )

   READ

   RETURN


FUNCTION OtherGet( a, b )

LOCAL GetList := {}

SAVE SCREEN

@ 5, 0 GET a

@ 6, 0 GET b

READ

RESTORE SCREEN

RETURN .T.


José M. C. Quintas

--

cod...@outlook.com

unread,
Oct 19, 2024, 1:48:20 PMOct 19
to Harbour Users

Hi.

In usual way of programming you do not need to make any changes in Getsys.prg.

May be only if your application have some special requests regarding GETs, but it is very rare.

So it would be very helpful to explain us your situation with some small part of your PRG.

Regards,

Simo.     

fdaniele

unread,
Oct 19, 2024, 11:06:20 PMOct 19
to Harbour Users
good morning friends

if you want a beautiful getlist() example, take a look to the grump library (clipper)

regards

Daniele

Mohamed Hamza

unread,
Oct 20, 2024, 3:54:20 AMOct 20
to Harbour Users
Hi all,

I want to change the current workarea when the alias of get:name change . So where getsys.prg have to be changed?
Regards.
Med. 

cod...@outlook.com

unread,
Oct 20, 2024, 8:45:16 AMOct 20
to Harbour Users

Hi Med.

I am not sure that I understand correctly what you mean with get:name.

I will try with this. Sorry if I write something that you already know or is irrelevant to your problem. The purpose of this is to be more close on what you want to solve.

If you have for example FILE1 and its field Item C10 you can write:

DO WHILE .T.

   @ 10,10 GET FILE1->Item

   READ

   IF LASTKEY()==27

      EXIT

   ENDIF

ENDDO

 

But if you place alias name in memvar say malias, you can also write this:

malias:="FILE1"

 

DO WHILE .T.

   @ 10,10 GET (malias)->Item

   READ

   IF LASTKEY()==27

      EXIT

   ENDIF

   * here you can put another alias (workarea) with  malias:="File2", etc.

ENDDO

 

Changing value of memvar malias you can edit file by your wish (in different workareas). No need to change anything in Getsys.prg .

Requirement is that files must have same structure.

Regards,

Simo.

Mohamed Hamza

unread,
Oct 20, 2024, 10:58:54 AMOct 20
to Harbour Users
Hi,

I am wondering if the sample below works :

mAlias='FILE1'

@0,0 get   (mAlias)->fieldi send  GetAlias()
READ



function getAlias()
local s1

s1:=extractAlias(getactive())
if s1<>mAlias  then mAlias:=s1
return s1

function extractalias(s)
..
..
return ...........................

Francesco Perillo

unread,
Oct 20, 2024, 10:58:56 AMOct 20
to harbou...@googlegroups.com
I have no clear idea of what you need but I'd explore WHEN clause.


cod...@outlook.com

unread,
Oct 20, 2024, 11:52:53 AMOct 20
to Harbour Users
Hi Med.

On this link you can see how to use GetActive():

I can not remember did I ever used GetActive or Send in @GET system, but that depends on application type we develop.

It would be helpful if you describe us what you want to achieve. May be someone can suggest you some other way to solve it.

Regards,
Simo.

José M. C. Quintas

unread,
Oct 21, 2024, 5:32:49 AMOct 21
to harbou...@googlegroups.com

Why to do this ?

Where do you will use the alias ?

It is wrong to use field on get, this will require file locked during all get time.

Wrong to think on getsys to change alias.

What do you want to do ?

A single sample using 3 workareas

SELECT voucher

@ 1, 0 GET nCode VALID client->( SeekNumber( nCode ) )

@ 2, 0 GET nCode2 VALID product->( SeekNumber( nCode2 ) )

READ

FUNCTION SeekNumber( nCode )

   SEEK nCode

   RETURN ! Eof()


José M. C. Quintas

--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

Mohamed Hamza

unread,
Oct 21, 2024, 9:13:07 AMOct 21
to Harbour Users
Hi José M. C. Quintas,

I planed to use multiple DBF in the same input screen and navigate between them using some buttons like previous, next , top, end , seek ....
corresponding to (alias())->skip -1, alias(())-> skip +1,   ........

@0,00 GET DATA1->FIRST            SEND name:='DATA1->FIRST'            WHEN GETALIAS()
@1,20 GET DATA2->LASTNAME  SEND name:='DATA2->LASTNAME'  WHEN GETALIAS()
READ
RETURN

FUNCTION GETALIAS(  )
LOCAL S:=GETACTIVE():name
S:=SUBSTR(S,1,AT("-",S)-1)
IF ALIAS()<>S
SELECT ( S)
ENDIF
RETURN  .T.

Next step is to have 1 getlist for each dbf or better solution as I asked for?

Regards

Med

José M. C. Quintas

unread,
Oct 21, 2024, 9:51:01 AMOct 21
to harbou...@googlegroups.com

Not sure what means "same input screen".

Is it anything like this?


#include "inkey.ch"
#include "dbstruct.ch"

PROCEDURE Main

   LOCAL GetList := {}
   LOCAL nKey, nCont, cName, cField, aStru

   SetMode(33,100)
   CLS

   USE jpreguso

   aStru := dbStruct()

   DO WHILE .T.

      FOR nCont = 1 TO Len( aStru )
         cName := aStru[ nCont, DBS_NAME ]
         FOR EACH cField IN { cName }
            IF nCont > 21
               EXIT
            ENDIF
            @ nCont ,  0  SAY cField GET &cField
            IF nCont > 21
               EXIT
            ENDIF
         NEXT
         IF nCont > 21
            EXIT
         ENDIF
      NEXT
      CLEAR GETs
      @ 23, 0 SAY "PgUp, PgDn, Home, End, ESC"
      nKey := Inkey(0)
      DO CASE
      CASE nKey == K_PGUP ; dbSkip()
      CASE nKey == K_PGDN ; dbSkip(-1)
      CASE nKey == K_HOME ; dbGoTop()
      CASE nKey == K_END ; dbGoBottom()
      CASE nKey == K_ESC ; EXIT
      OTHERWISE; LOOP
      ENDCASE

   ENDDO

   CLOSE DATABASES

   RETURN

José M. C. Quintas

jmcqu...@gmail.com

unread,
Oct 21, 2024, 9:59:51 AMOct 21
to Harbour Users
Excluded duplicated code.

#include "inkey.ch"
#include "dbstruct.ch"

PROCEDURE Main

   LOCAL GetList := {}
   LOCAL nKey, nCont, cName, cField, aStru

   SetMode(33,100)
   CLS

   USE jpreguso
   aStru := dbStruct()

   DO WHILE .T.

      FOR nCont = 1 TO Len( aStru )
         IF nCont > 21
            EXIT
         ENDIF
         cName := aStru[ nCont, DBS_NAME ]
         FOR EACH cField IN { cName }
            @ nCont ,  0  SAY cField GET &cField
         NEXT

      NEXT
      CLEAR GETs
      @ 23, 0 SAY "PgUp, PgDn, Home, End, ESC"
      nKey := Inkey(0)
      DO CASE
      CASE nKey == K_PGUP ; dbSkip()
      CASE nKey == K_PGDN ; dbSkip(-1)
      CASE nKey == K_HOME ; dbGoTop()
      CASE nKey == K_END ; dbGoBottom()
      CASE nKey == K_ESC ; EXIT
      ENDCASE

   ENDDO

   CLOSE DATABASES

   RETURN

José M. C. Quintas

Francesco Perillo

unread,
Oct 21, 2024, 10:04:12 AMOct 21
to harbou...@googlegroups.com
Ok so you have 3 DBFs whose fields are on screen and you want do change the record pointed and shown on screen.

It is still not clear why you want to use GETs... do you want to edit the values? Directly in the DBF? 

I believe it is bad practice.
I think it can be done forcing the GET system to reload the values from the DBFs but I don't remember how to do it.





Mohamed Hamza

unread,
Oct 21, 2024, 10:04:50 AMOct 21
to Harbour Users
Hi Jose

Not sure what means "same input screen

Draw 2 boxes   : Box1 contains all fields of dbf1  Box2 contains all fields of dbf2.
At top of screen we set some buttons '( next previous ....) . 
the question :  how to switch between dbf1 and dbf2 ?

Regards
Med

José M. C. Quintas

unread,
Oct 21, 2024, 10:40:18 AMOct 21
to harbou...@googlegroups.com

#include "inkey.ch"
#include "dbstruct.ch"

PROCEDURE Main

   LOCAL nKey, nSelect1, nSelect2

   SET EXCLUSIVE OFF
   SetMode(33,100)
   SET COLOR TO W/B,N/W,,,W/BR
   CLS

   use jpreguso ALIAS one new
   nSelect1 := Select()
   use jpreguso ALIAS two new
   nSelect2 := Select()
   DO WHILE .T.
      Show( 0, nSelect1, .F. )
      Show( 40, nSelect2,.F. )
      @ 23, 0 SAY "PgUp, PgDn, Home, End, A_EditA, B_EditB, ESC"


      nKey := Inkey(0)
      DO CASE

      CASE nKey == K_PGUP ; ( nSelect1 )->( dbSkip(-1) );    ( nselect2 )->( dbSkip(-1) )
      CASE nKey == K_PGDN ; ( nSelect1 )->( dbSkip() );  ( nSelect2 )->( dbSkip() )
      CASE nKey == K_HOME ; ( nselect1 )->(dbGoTop() );    ( nSelect2 )->( dbGoTop() )
      CASE nKey == K_END ; ( nSelect1 )->( dbGoBottom() ); ( nSelect2 )->( dbGoBottom() )
      CASE Upper( Chr( nKey ) ) == "A"; Show( 0, nSelect1, .T. )
      CASE Upper( Chr( nKey ) ) == "B"; Show( 40, nSelect2, .T. )


      CASE nKey == K_ESC ; EXIT

      ENDCASE
   ENDDO
   CLOSE DATABASES
   RETURN

FUNCTION Show( nCol, nAlias, lEdit )

   LOCAL nCont, cName, cField, aStru, GetList := {}

   SELECT ( nAlias )
   aStru := dbStruct()


   FOR nCont = 1 TO Len( aStru )

      IF nCont > 21
         EXIT
      ENDIF
      cName := aStru[ nCont, DBS_NAME ]
      FOR EACH cField IN { cName }

         @ nCont, nCol SAY cField GET &cField
      NEXT
   NEXT
   IF lEdit
      rLock()
      READ
   ELSE
      CLEAR GETS
   ENDIF

   RETURN Nil

José M. C. Quintas

Mohamed Hamza

unread,
Oct 21, 2024, 12:56:01 PMOct 21
to Harbour Users
Hi Jose,

Why you do the same action for 2 dbf at the same time (CASE nKey == K_PGUP ; ( nSelect1 )->( dbSkip(-1) );    ( nselect2 )->( dbSkip(-1) )
we only need  to skip in 1 dbf at time !!!  so we have to write ( alias() )-> dbskip) where alias() is the active dbf.

Regads

cod...@outlook.com

unread,
Oct 21, 2024, 2:40:17 PMOct 21
to Harbour Users
Hi Med.

Try this example.
Adjust to your files.
I used functional keys to navigate and to switch files.
 
***begin************************************************************************
#xcommand FPUBLIC <idFunc> [ DEFAULT <xDefault> ] ;   // you can put this command in your .ch file
     => ;
     FUNCTION <idFunc> ( xNewValue ) ;;
     STATIC xValue [ := <xDefault> ] ;;
     LOCAL xOldValue := xValue       ;;
     IF xNewValue != NIL           ;;
        xValue := xNewValue         ;;
     END                           ;;
     RETURN ( xOldValue )
*
#include "inkey.ch"  
*----------------------------------------------------------------------------
FUNCTION Test()
*
LOCAL Getlist:={}
LOCAL mfile,x1,y1
*

use file2 new

use file1 new

mfile:="1"
Falias("file1")

x1:=10; y1:=10

SETKEY(K_F5,   { || Fmprev(x1,y1) })  // navigation
SETKEY(K_F8,   { || Fmnext(x1,y1) })
SETKEY(K_F9,   { || Fmfile(@mfile) }) // switch file

cls

@ 05,10 say "F5-previous record,  F6-next record"
@ 06,10 say "F8-swith DBF"
@ 06,26 say Falias()

DO WHILE .T.
   @ x1+00,y1+00 get file1->field1
   @ x1+01,y1+00 get file1->field2
   @ x1+02,y1+00 get file1->field3

   @ x1+00,y1+40 get file2->field1
   @ x1+01,y1+40 get file2->field2
   @ x1+02,y1+40 get file2->field3


   READ

   IF LASTKEY()==27
      EXIT
   ENDIF
ENDDO

CLOSE DATABASES

QUIT

*-------------------------------------------

function Fmfile(mfile)  // switch file

IF mfile=="1"
   mfile:="2"
   Falias("file2")
ELSE  // "2"
   mfile:="1"
   Falias("file1")
ENDIF
@ 06,26 say Falias()

return NIL
*-------------------------------------------------

function Fmnext(x1,y1)  // navigate next record
local nn
dbSelectArea(Falias())
SKIP +1
IF EOF()
   GOTO 1
ENDIF

IF Falias()=="file1"
   nn:=00
ELSE
   nn:=40
ENDIF
@ x1+00,y1+nn say (Falias())->field1  // refreash display on screen
@ x1+01,y1+nn say (Falias())->field2
@ x1+02,y1+nn say (Falias())->field3

return NIL
*-------------------------------------------------

function Fmprev(x1,y1)  // navigate previous record
local nn
dbSelectArea(Falias())
SKIP -1
IF BOF()
   GOTO 1
ENDIF

IF Falias()=="file1"
   nn:=00
ELSE
   nn:=40
ENDIF
@ x1+00,y1+nn say (Falias())->field1  // refreash display on screen
@ x1+01,y1+nn say (Falias())->field2
@ x1+02,y1+nn say (Falias())->field3

return NIL
*-------------------------------------------------
*
FPUBLIC Falias DEFAULT "file1"
*
***end************************************************************************

Regards,
Simo.

cod...@outlook.com

unread,
Oct 21, 2024, 3:18:19 PMOct 21
to Harbour Users
Here are my test files.
Regards,
Simo.

file2.dbf
file1.dbf

José M. C. Quintas

unread,
Oct 21, 2024, 3:21:57 PMOct 21
to harbou...@googlegroups.com

It is a sample only.


Another way is to use multithread and more than one window.

Check available GTs for multithread.

Same sample using multithread.

Change to existing  DBF

Compile using 

hbmk2 test.prg -mt -gui


#include "inkey.ch"
#include "dbstruct.ch"
#include "hbgtinfo.ch"

PROCEDURE Main

   LOCAL lMainVisible := .T.

   IF lMainVisible
      SetMode(25,80)
      CLS
   ENDIF

   hb_ThreadStart( { || Main2() } )
   hb_ThreadStart( { || Main2() } )

   IF lMainVisible
      ? "hit a key to close all"
      Inkey(0)
   ELSE
      hb_ThreadWaitForAll()
   ENDIF


   RETURN

PROCEDURE Main2

   LOCAL nKey, nSelect1, nSelect2

   hb_gtReload( hb_gtInfo( HB_GTI_VERSION ) )

Mohamed Hamza

unread,
Oct 22, 2024, 4:28:23 AMOct 22
to Harbour Users
Hi all,

So far no one has convinced me to avoid getsystem to change the current alias. GetList contains all objects we need and we can add pushbuttons  to  navigate, to edit dbf.

Regards.
Med

cod...@outlook.com

unread,
Oct 22, 2024, 4:48:50 AMOct 22
to Harbour Users
Hi Med.

That is why this forum exist. To ask question and make your own conclusion or solution based on others ideas. It is always good to exchange experiences.

It would be helpful if you inform us how did you implemented your solution. May be someone can have same situation as you.

Regards,

Simo.

Hurricane

unread,
Oct 22, 2024, 9:13:10 AMOct 22
to Harbour Users
Hi Med,

There are simple and better alternatives, but...

Do you use Windows and which version?
Do you use Harbour for...
  • Just studying, passing the time?
  • Professional use, helping with internal routines?
  • Professional use, selling my software?
Regards,
Hurricane

José M. C. Quintas

unread,
Oct 22, 2024, 11:22:58 AMOct 22
to harbou...@googlegroups.com

Yes getlist contains all objects.

You can't change the object from one alias to another.

Use variables and you are free to load/save on any dbf.

button1: load from dbf 1 to variables and edit

button2: load from dbf2 to variables and edit

button3: save to dbf1

button4: save to dbf2

José M. C. Quintas

Mohamed Hamza

unread,
Oct 22, 2024, 11:38:37 AMOct 22
to Harbour Users
Hi Hurricane,

I am coming from clipper world and I want  to keep the text mode but with the concept of none modal programming.
of course i use windows 7 system.

Regards.
Med
Reply all
Reply to author
Forward
0 new messages