Scoped List

This forum is for eXpress++ general support.
Message
Author
omni
Posts: 531
Joined: Thu Jan 28, 2010 9:34 am

Scoped List

#1 Post by omni »

Roger,

Trying to use the scoped list (sample 187) but from a file. do you have an example of that. Cannot get all the commands right.

Thanks

Fred
Omni

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Scoped List

#2 Post by rdonnay »

Fred -

The code is in the window. What is giving you a problem?

Code: Select all

FUNCTION XSample_187()

/* This example demonstrates how to use the KEYBLOCK clause
   and COMBO clause  @..DCSAY..GET to drop down a list of
   valid names and scope the list based on the characters
   entered.  If names are in a database, use dbSeek() and
   DC_SetScope() in place of Ascan(). */

LOCAL GetList[0], GetOptions, cName, aNames, cPerformer, lImmediate

cPerformer := Space(30)

aNames := PerformerNames()

@ 0,0 DCSAY 'Enter Performer Name' GET cPerformer ;
      SAYSIZE 0 SAYBOTTOM ;
      KEYBLOCK {|a,b,o|DropDownNames(a,b,o,@cPerformer,aNames)} ;
      COMBO HEIGHT 10 DATA aNames

lImmediate := DC_GetComboImmediate(.t.)
DCREAD GUI FIT TITLE 'Scoped Drop-Down' MODAL
DC_GetComboImmediate(lImmediate)

RETURN nil

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

STATIC FUNCTION DropDownNames( nKey, mp2, oGet, cPerformer, aNames )

LOCAL nFound, cName, nLen := Len(cPerformer), aPerformers

IF Chr(nKey) < 'A' .OR. Chr(nKey) > 'z'
  RETURN nil
ENDIF

oGet:getData()

cName := Alltrim(Upper(cPerformer))

ASize(aNames,0)

aPerformers := PerformerNames()
nFound := AScan( aPerformers, {|c|Alltrim(Upper(c)) = cName} )

IF nFound > 0
  DO WHILE nFound <= Len(aPerformers) .AND. Alltrim(Upper(aPerformers[nFound])) = cName
    AAdd( aNames, aPerformers[nFound])
    nFound++
  ENDDO
  oGet:comboData := aNames  // store scoped array to datasource
  PostAppevent(xbeP_Activate,,,oGet:popupButton) // popup scoped dropdown
  SetAppFocus(oGet)
  DC_CompleteEvents()
ENDIF

oGet:comboData := aPerformers // store full array to datasource

IF Empty(aNames)
  AAdd(aNames,'')
ENDIF

RETURN nil
*** END OF EXAMPLE ***
The eXpress train is coming - and it has more cars.

omni
Posts: 531
Joined: Thu Jan 28, 2010 9:34 am

Re: Scoped List

#3 Post by omni »

Trying to use the actual data file, not an array. The user must select anywhere from 2 to 99 records on a new option in a single window. The standard dropdown is messy with 1000 records on the list.Need to use a scope, and avoid using a standard scan with autoseek. Takes too long one by one. Understand the array and it works.
This appears to be the best option if I can get it to work. And that is what they are requesting...

Thanks

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Scoped List

#4 Post by rdonnay »

You could scope the database and then load the array from the database.
The eXpress train is coming - and it has more cars.

omni
Posts: 531
Joined: Thu Jan 28, 2010 9:34 am

Re: Scoped List

#5 Post by omni »

Roger,

For one it works fine. We have a new window where the user defines how many selections to make (up to a certain max) out of the database. We have tried setting up vars for each entry and using & to define the counter. Appears to work but once one is selected all of the remaining only accept that one. There are no other vars to assign the 'counter' to. (The counter is for each selection.

Below is the code. There must be something that locks the selection but so far in our testing we have not found it.
Do you see something right off hand??

Not familiar with the getdata() or its purpose.

I can send the one file used if you think you need to run it.

Update..if you rather I can give you your same example back with what I am trying to do. I will do that..

Thanks

Fred
Omni

omni
Posts: 531
Joined: Thu Jan 28, 2010 9:34 am

Re: Scoped List

#6 Post by omni »

Maybe just a question.

if this is set up as a loop using all arrays to get multiple items, based on prior answers to similar methods,I think it has to be anchored or the returns are not correct. How would it be anchored, or would that take multiple anchors?
The return is only right on the last one in the loop at best.

Fred

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Scoped List

#7 Post by rdonnay »

Your code disappeared. You must have deleted it.
Post it in a zip file or send it to me by email.
The eXpress train is coming - and it has more cars.

omni
Posts: 531
Joined: Thu Jan 28, 2010 9:34 am

Re: Scoped List

#8 Post by omni »

Sent an email..thanks

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Scoped List

#9 Post by rdonnay »

Here is some code that shows the correct way to do what you want.
This uses no private variables and no macros.
Just compile and run it.

Code: Select all

#INCLUDE "dcdialog.CH"
#INCLUDE "appevent.CH"

FUNCTION Main()

LOCAL GetList[0], GetOptions, cName, aPerformers[6], lImmediate, ;
      aNames[6], nRow := 1, bBlock, i

AFill(aPerformers,Space(30))
AFill(aNames,PerformerNames())

FOR i := 1 TO Len(aPerformers)

  bBlock := AnchorBlock( @aPerformers[i], @aNames[i] )
  @ nRow,0 DCSAY 'Enter Performer Name' GET aPerformers[i] ;
      SAYSIZE 0 SAYBOTTOM ;
      KEYBLOCK bBlock ;
      COMBO HEIGHT 10 DATA aNames[i]

  nRow += 2

NEXT

lImmediate := DC_GetComboImmediate(.t.)
DCREAD GUI FIT TITLE 'Scoped Drop-Down' MODAL ADDBUTTONS
DC_GetComboImmediate(lImmediate)

wtf aPerformers pause

RETURN nil

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

STATIC FUNCTION AnchorBlock( cPerformer, aNames )

RETURN {|a,b,o|DropDownNames(a,b,o,@cPerformer,@aNames)}

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

STATIC FUNCTION DropDownNames( nKey, mp2, oGet, cPerformer, aNames )

LOCAL nFound, cName, nLen := Len(cPerformer), aPerformers

IF Chr(nKey) < 'A' .OR. Chr(nKey) > 'z'
  RETURN nil
ENDIF

oGet:getData()

cName := Alltrim(Upper(cPerformer))

ASize(aNames,0)

aPerformers := PerformerNames()
nFound := AScan( aPerformers, {|c|Alltrim(Upper(c)) = cName} )

IF nFound > 0
  DO WHILE nFound <= Len(aPerformers) .AND. Alltrim(Upper(aPerformers[nFound])) = cName
    AAdd( aNames, aPerformers[nFound])
    nFound++
  ENDDO
  oGet:comboData := aNames  // store scoped array to datasource
  PostAppevent(xbeP_Activate,,,oGet:popupButton) // popup scoped dropdown
  SetAppFocus(oGet)
  DC_CompleteEvents()
ENDIF

oGet:comboData := aPerformers // store full array to datasource

IF Empty(aNames)
  AAdd(aNames,'')
ENDIF

RETURN nil

* -------

PROC appsys ; RETURN

* -------

STATIC FUNCTION PerformerNames()

RETURN { ;
   'Annie Hall', ;
   'Arlo Guthrie', ;
   'Bette Midler', ;
   'Bob Dylan', ;
   'Bobbie Gentry', ;
   'Buddy Holly', ;
   'Canned Heat', ;
   'Carol Elliot', ;
   'Carole King', ;
   'Caroline Aikin', ;
   'Cat Stevens', ;
   'Catie Curtis', ;
   'Cheryl Wheeler', ;
   'Chuck Prophet', ;
   'Chuck Pyle', ;
   'Crosby, Stills, Nash', ;
   'Danny Kaye', ;
   'Dar Williams', ;
   'Dr Hook', ;
   'Eliza Gilkyson', ;
   'Elton John', ;
   'Elvis Presley', ;
   'Gail Davies', ;
   'Glenn Miller', ;
   'Gordon Rowland', ;
   'Greg Brown', ;
   'Harry McClintock', ;
   'Itzhak Perlman', ;
   'James Taylor', ;
   'Jan Stanfield', ;
   'Jefferson Airplane', ;
   'Jim Croce', ;
   'Jimi Hendrix', ;
   'Jimmy Dean', ;
   'John Denver', ;
   'Joni Mitchell', ;
   'Journey', ;
   'Kevin Welch', ;
   'Krystian Zimermann', ;
   'Led Zeppelin', ;
   'Lyle Lovett', ;
   'Lynn Miles', ;
   'Madeleine Peyroux', ;
   'Michael Jackson', ;
   'Michael Lille', ;
   'Mumbo Gumbo', ;
   'Norah Jones', ;
   'Ray Charles', ;
   'Richard Pryor', ;
   'Richard Shindell', ;
   'Richie Havens', ;
   'Robin Williams', ;
   'Roy Orbison', ;
   'Sam Cooke', ;
   'Slobberbone', ;
   'Steppenwolf', ;
   'Susan Werner', ;
   'Ten Years After', ;
   'The Beatles', ;
   'The Doors', ;
   'The Eagles', ;
   'The Flatlanders', ;
   'The Moody Blues', ;
   'Tim Bays', ;
   'Toby Keith', ;
   'Tom Paxton', ;
   'Tom Petty', ;
   'Tom Prasada-Rao', ;
   'Van Morrison', ;
   'Vance Gilbert', ;
   'Vic Chestnutt', ;
   'Willie Nelson', ;
   'Yo-yo Ma', ;
   'Yundi Li'}
The eXpress train is coming - and it has more cars.

omni
Posts: 531
Joined: Thu Jan 28, 2010 9:34 am

Re: Scoped List

#10 Post by omni »

Thanks.

Post Reply