dynamic configuration of buttons (OpenInsight Specific)
At 09 NOV 2001 05:40:36PM Kerry Walter wrote:
Hello all:
We have 15 buttons on a logon form that call various windows or stored
procedures. We'd like to re-configure the CLICK events of those buttons
based on who is logging into the system.
For example, the CLICK events for buttons one and two for user 'A' might be:
APPNAM*OIWINEXESTANDARD_FRAME parameters=PSOURCES','LOGON_FRAME' APPNAM*OIWINEXESTANDARD_FRAME
parameters=CONTACTS','LOGON_FRAME'
while the CLICK events for buttons one and two for user 'B' might be:
APPNAM*OIWINEXESTANDARD_FRAME parameters= 'GENERA','LOGON_FRAME' APPNAM*OIWINEXESTANDARD_FRAME
parameters= 'PSOURCES','LOGON_FRAME'
The currently hard-coded Quickevent is:
Event: CLICK
QuickEvent Options: Start a window
Send message to: Entity; APPNAM*OIWINEXE**STANDARD_FRAME
message=null
Parameters: 'PSOURCES','LOGON_FRAME'
return value in; Control null, property null
Basically we need to change the first of the two parameters to a previously
set global common variable, but I cannot see any way to do this via ORIG_STRUCT
Thanks very much. Kerry
At 09 NOV 2001 09:27PM James Birnie wrote:
Hi Kerry,
To setup a global variable you use the COMMON command. Setup an Insert record in the system editor eg.
COMPILE INSERT G_Company COMMON /G_Company/ companyCode$, companyName$, companyRec$where companyCode$, companyName$, companyRec$ are the variables thar can be referenced from anywhere. Alternately if you could setup them up as @variables within your main window eg.
SET_PROPERTY('MyMainWindow',@companyCode,'myCompanyCode') …etc
I'd advise setting up a commuter stored procedure for your window. To access your global variable, call the Insert setup above from your stored proc. eg
COMPILE FUNCTION MyMainWindow_cr(routine, params) $INSERT G_Company $INSERT LOGICAL valid=TRUE$ controlId=FIELD(routine,'.',2,2) windowId =FIELD(controlId,'.',1) BEGIN CASE CASE routine=CLICK.':windowId:'.buttonName' ... END CASE RETURN validFrom your window call this routine from your CLICK event script within each button control eg.
DECLARE FUNCTION MyMainWindow_cr valid=MyMainWindow_cr('CLICK.':ctrlentid, '') RETURN validThis is the way I work anyway!
Best of Luck.
At 11 NOV 2001 03:57PM Oystein Reigem wrote:
Kerry,
There are several alternatives. Here are the ones I can think of:
(1) Let each quickevent not start a window but call one common stored procedure. Let the quickevent have a parameter which is the name of the button which calls the stored procedure. Then the stored procedure can check which button called it. I assume you can also make the stored procedure know which user is logged on. You must have solved that problem already. From those two pieces of information the stored procedure can decide which window to start, and start it with a Start_Window call.
If you solve the problem this way your stored procedure is close to what is called a commuter function. A commuter function contains the programming for all the events of a form. There is a fairly standard way of doing and calling commuter functions, described in postings here on this list.
I think this is approximately what James describes. Except that he suggests calling the common function from a scripted (user) event instead of a quickevent.
(2) A more primitive version of this is to have 15 different stored procedures - one for each button. Then there's no need for any parameters, but each procedure must, for each possible user, know which window to start.
(3) Have hard-coded buttons and move/show/hide them according to your needs. Let's say there are 25 windows altogether that you want started from your 15 buttons. Then make 25 buttons, each hard-coded in its quickevent to start one specific window. This is what you got now, really - buttons hard-coded to start one specific window. Then let the CREATE event of your window check which user is logged on, and move the relevant buttons to appropriate places on the form (by changing their SIZE property), and make the other buttons invisible (VISIBLE property).
- Oystein -
At 12 NOV 2001 03:32PM Robert Lee wrote:
Or another approach…
Once you have identified your user, you can set either the MISC property or @ property of each button so that it contains the name of the window to call.
Eg
x=Set_Property(@window : '.BUTTON_1', 'MISC', windowname1)
x=Set_Property(@window : '.BUTTON_2', 'MISC', windowname2)
…
Or
x=Set_Property(@window : '.BUTTON_1', '@WINDOWNAME', windowname1)
Then for each of the buttons, instead of calling a window, call a simple program which reads the property of the button and then runs that window.
windowname=Get_Property(CtrlEntId, 'MISC')
x=Start_Window(windowname, @window, '')
If you want to call a program instead of the window, you can user the CALL @ statement.
ProgramName=Get_Property(CtrlEntId, 'MISC')
CALL @ProgramName(@window)
Or a function …
FunctionName=Get_Property(CtrlEntId, 'MISC')
Rv=FUNCTION(@FunctionName (@window))
There are a plethora of ways to do this.
Happy experiments…
Robert Lee
At 13 NOV 2001 08:13AM Oystein Reigem wrote:
Kerry,
Now you've got so many ways of doing it there's one for every button!
![]()
Don't hesitate to ask again. (E.g, if you get more buttons.)
![]()
- Oystein -