Resolved Selectable Menu From Comma Delimited Value

Rob Case

New Member
All,

I'm sure there is an easier way but I'm drawing blanks. I have a database record for printer names that is comma delimiter. I want to display this as a menu where a user can select the printer to print too.

<code>
def var menu as char format 'x(30)'.
def work-table wk_printlist
field printname as char format 'x(4)'.
def var x as int.

find sysctl where sys_param = 'LBL_PRNT_LSR'.
assign menu = sys_value.
/* this assigns menu as "PT01,PT02,PT03,PT04*/


/* now I'm putting each print name into its own record in my work-table */

do x = 1 to NUM-ENTRIES(menu):
create wk_printlist.
assign printname = ENTRY(x,menu).
end.

/* here I would like to provide a menu of wk_printlist.printname but i'm having trouble figuring out how to do this*/

</code>

Any ideas on how I can provide a menu or is there an easier way I'm not aware of?

Thanks in advance.
Rob.
 

Osborne

Active Member
I don't know if this is of any help, in the samples folder there are four programs - menucre.p and menuex1-3.p's - that show how to create dynamic menus from menu data contained in a single string. Otherwise, try something along these lines:
Code:
DEFINE VARIABLE hMenu AS HANDLE NO-UNDO.
DEFINE VARIABLE hSubMenu AS HANDLE NO-UNDO.
DEFINE VARIABLE hMenuItem AS HANDLE NO-UNDO.

CREATE MENU hMenu.
CREATE SUB-MENU hSubMenu
  ASSIGN PARENT = hMenu
  LABEL = "Printers".

FOR EACH wk_printlist:
  CREATE MENU-ITEM hMenuItem
     ASSIGN PARENT = hSubMenu
            LABEL = wk_printlist.printname
  TRIGGERS:
     ON CHOOSE PERSISTENT RUN PrinterAction IN THIS-PROCEDURE.
  END TRIGGERS.
END.

CURRENT-WINDOW:MENUBAR = hMenu.
 

Rob Case

New Member
Thanks Osborne. I was able to get the "Printers" label to show up but not successful in getting the list of printers. I'm running Progress 10.2B08 and using Editor software.
 

Osborne

Active Member
It sounds as though something is out when creating the menu items. Try this:
Code:
DEFINE VARIABLE menu AS CHAR INITIAL "PT01,PT02,PT03,PT04" NO-UNDO.
DEFINE VARIABLE x AS INT NO-UNDO.
DEFINE VARIABLE hMenu AS HANDLE NO-UNDO.
DEFINE VARIABLE hSubMenu AS HANDLE NO-UNDO.
DEFINE VARIABLE hMenuItem AS HANDLE NO-UNDO.
DEFINE VARIABLE hWin AS HANDLE NO-UNDO.

CREATE WINDOW hWin ASSIGN
  TITLE = "Select Printer"
  HEIGHT = 12
  WIDTH = 80
  THREE-D = TRUE
  SENSITIVE = TRUE.

CREATE MENU hMenu.
CREATE SUB-MENU hSubMenu
  ASSIGN PARENT = hMenu
  LABEL = "Printers".

DO x = 1 TO NUM-ENTRIES(menu):
   CREATE MENU-ITEM hMenuItem
   ASSIGN PARENT = hSubMenu
   LABEL = ENTRY(x,menu)
   TRIGGERS:
   ON CHOOSE PERSISTENT RUN printerAction IN THIS-PROCEDURE (INPUT ENTRY(x,menu)).
   END TRIGGERS.
END.

hWin:MENUBAR = hMenu.
VIEW hWin.
WAIT-FOR WINDOW-CLOSE OF hWin.

PROCEDURE printerAction:
   DEFINE INPUT PARAMETER pMenu AS CHAR NO-UNDO.

   MESSAGE "Printer selected =" pMenu VIEW-AS ALERT-BOX.
END PROCEDURE.
 

Rob Case

New Member
Got farther but now I'm getting this error:
CREATE WINDOW in character-mode is not supported. (4139)

Progress is hosted on a Linux server using terminal emulation to access.
 

Osborne

Active Member
Ah, thought it was GUI you were designing for. For character replace:
Code:
CREATE WINDOW hWin ASSIGN
  TITLE = "Select Printer"
  HEIGHT = 12
  WIDTH = 80
  THREE-D = TRUE
  SENSITIVE = TRUE.
with:
Code:
hWin = CURRENT-WINDOW.
 
Top