ernie
New Member
Posts: 44
|
Post by ernie on Feb 5, 2020 9:04:37 GMT -5
I am writing a program that will have many windows. I want all of them to have the same menu. Is there a way to do this so I don't have to write separate menu code for each window? This might be something like:
#page$ = "#page1"
[menuMaker] menu #page$, " File", "Open", [menuOpen], "Save", [menuSave], "Save As", [menuSaveAs], "Generate Report", [menuReport] menu #page$, "Report", "Narrative Report", [menuNarrative], "Bullet Report", [menuBullet] menu #page$, "Help", "Psych-Writer Help", [menuHelp] menu #page$, "About", "About", [menuAbout] return
thanks in advance..
|
|
|
Post by Rod on Feb 5, 2020 11:36:50 GMT -5
When it feels difficult to do you should be thinking why? Why is it difficult to have the same menu across fifteen windows. The answer? Perhaps you should not have fifteen windows.
So you have one window, what are the fifteen things you want to do in it?
|
|
ernie
New Member
Posts: 44
|
Post by ernie on Feb 5, 2020 11:57:58 GMT -5
collecting data from 18-page questionnaire over 1,200 variables too much for one page
|
|
|
Post by sarossell on Feb 5, 2020 12:11:36 GMT -5
Perhaps tabs in a single window might serve better?
|
|
ernie
New Member
Posts: 44
|
Post by ernie on Feb 5, 2020 13:07:13 GMT -5
Is there anyone here that can answer the question that I asked?
|
|
|
Post by Rod on Feb 5, 2020 14:58:52 GMT -5
Ok, so to define the question a little more. You want a gui window system that will take a scripted eighteen page document that contains 1200 variables and will have a single menu system.
While a single window will allow a single menu it will involve paging in the eighteen pages of scripted variable input.
If I was tackling that I would probably re-statictext, reposition, show and hide, a utility set of textboxes. Each page I would clear up, re statictext, hide unwanted textboxes and allow page up or page down and or save where we are. So a few buttons as well.
If they move forwards grab what they have input and save it away. I would build an array of saved responses till we have a complete set.
There are examples of changing static text and showing and hiding textboxes. They can actually be moved on screen as well but to make the task simpler I would allow plenty room for static text and keep the textboxes in a semi rigid matrix.
So the page changes when they move page. The statictext changes to the new input prompts and the textboxes clkear to allow new new data. The user answers the questions then presses the move on or save button or indeed step back button.
All doable.
When I get a little time I will code a demo of what I mean.
|
|
|
Post by Chris Iverson on Feb 5, 2020 15:11:18 GMT -5
In native LB code? No.
You can write generator code to spit out multiple copies of the menu code with the matching window handle attached, but the MENU command does not accept window handle variables, so you cannot use the same code on multiple windows, unless each window has the same handle, which is going to make your logic flow very complex, to figure out which "window" you intend to be using. Possible, but complicated.
You could also do it using API commands to build the menu, but the problem with that is then you have to restructure your entire program to be able to use DLL calls and window messages, learn the win32 menu API, and learn how to use WMLiberty to response to menu "clicks", since you can't use branch labels to respond to API-generated menus.
Here's an example of generator code that you can modify to output the handle you need:
page$ = "#page1"
print "[menuMaker]" print " menu " + page$ + ", "+ chr$(34) +"File" + chr$(34) + ", "+ chr$(34) +"Open" + chr$(34) + ", [menuOpen], "+ chr$(34) +"Save" + chr$(34) + ", [menuSave], " + chr$(34) +"Save As" + chr$(34) + ", [menuSaveAs], " + chr$(34) + "Generate Report" + chr$(34) + ", [menuReport]" print " menu " + page$ + ", "+ chr$(34) +"Report" + chr$(34) + ", "+ chr$(34) +"Narrative Report" + chr$(34) + ", [menuNarrative], "+ chr$(34) +"Bullet Report" + chr$(34) + ", [menuBullet]" print " menu " + page$ + ", "+ chr$(34) +"Help" + chr$(34) + ", "+ chr$(34) +"Psych-Writer Help" + chr$(34) + ", [menuHelp]" print " menu " + page$ + ", "+ chr$(34) +"About" + chr$(34) + ", "+ chr$(34) +"About" + chr$(34) + ", [menuAbout]" print " return"
The reason the others were suggesting alternatives is because of how complicated this kind of thing can be across multiple windows.
|
|
|
Post by Rod on Feb 5, 2020 15:12:41 GMT -5
For such a large questionnaire you are going to need some sort of input template check. You will have utility textboxes that just take data but you will need to have some form of template checking routine that only allows desired data through. There have been examples in the past. A date format, a numeric format in a specific range, etc. You will probably need some utility comboboxes that you can show and hide as well to allow fixed list input.
|
|
|
Post by Rod on Feb 5, 2020 15:43:19 GMT -5
The gist of changing the contents of a window. Can be much more complex as you can show and hide textbox/combobox in the same location etc, limitless possibilities.
dim answers$(1200) nomainwin statictext #t.1, "Answer this question about your age",20,20,260,25 textbox #t.tx1, 20, 50, 260, 25 statictext #t.2, "Answer this question about your father",20,80,260,25 textbox #t.tx2, 20, 110, 260, 25 statictext #t.3, "Answer this question about your mother",20,140,260,25 textbox #t.tx3, 20, 170, 260, 25 button #t.bt1,"Move On",[move],UL,20,200,260,25
WindowWidth = 350 : WindowHeight = 290 open "Simple paging" for window as #t #t "trapclose [quit]" page=0 answer=1 wait
[move] 'get the answers #t.tx1 "!contents? a$" answer$(answer)=a$ : answer=answer+1 #t.tx1 "" #t.tx2 "!contents? a$" answer$(answer)=a$ : answer=answer+1 #t.tx2 "" #t.tx3 "!contents? a$" answer$(answer)=a$ : answer=answer+1 #t.tx3 "" page=page+1 select case page case 1 #t.1, "Answer this question about your wife" #t.2, "Answer this question about your father in law" #t.3, "Answer this question about your mother in law" end select wait
[quit] close #t end
|
|
|
Post by sarossell on Feb 5, 2020 17:57:01 GMT -5
Perhaps it would be possible to maphandle the page names instead. That way, the menu could be coded once but the page contents could be managed with names for each window. That and/or hiding and showing elements might do the trick.
Another idea might be to create one very long window with one menu that scrolls the pages.
More than one way to skin a cat.
:@)
|
|
|
Post by Rod on Feb 6, 2020 3:17:42 GMT -5
You could also sit a small menu window on top and other windows come and go below it. However my solution uses one window, one menu and perhaps ten or so reusable text boxes. Can’t get fewer controls than that. The exercise then becomes a an eighteen page scripting exercise. Just keep the static text content in an array, keep the answered there too. So one array holds all the script and eventually all the answers. Pretty slick strategy imho
So I don’t recommend any form of multiple menu.
|
|
|
Post by Rod on Feb 6, 2020 4:57:53 GMT -5
Slightly tidier example. If I was adding more it would be another page array that controlled the formatting show hide text/combo etc etc. But I would need to know a little more about the formatting that might happen.
I know we did not immediately answer your initial question, I hope you can see why.
nomainwin menu #t, " File", "Open", [menuOpen], "Save", [menuSave], "Save As", [menuSaveAs], "Generate Report", [menuReport] menu #t, "Report", "Narrative Report", [menuNarrative], "Bullet Report", [menuBullet] menu #t, "Help", "Psych-Writer Help", [menuHelp] menu #t, "About", "About", [menuAbout] dim a$(1200)'1200 questions dim q$(1200)'1200 answers dim p(120)'120 page starting points q$(1)="Answer this question about your age" q$(2)="Answer this question about your father" q$(3)="Answer this question about your mother" q$(4)="Answer this question about your wife" q$(5)="Answer this question about your father in law" q$(6)="Answer this question about your mother in law" q$(7)="What are your ambitions in life?" q$(8)="What indeed" q$(9)="the last question" p(1)=1 p(2)=4 p(3)=7 page=1
button #t.bp,"Previous",[previous],UL,20,10,260,20 statictext #t.1,q$(1) ,20,35,260,20 textbox #t.tb1, 20, 60, 260, 20 statictext #t.2, q$(2),20,85,260,20 textbox #t.tb2, 20, 110, 260, 20 statictext #t.3, q$(3),20,140,260,20 textbox #t.tb3, 20, 170, 260, 20 button #t.bn,"Save / Next",[move],UL,20,200,260,20
WindowWidth = 350 : WindowHeight = 290 open "Simple paging" for window as #t #t "trapclose [quit]" wait
[move] 'save away current answers answer=p(page) #t.tb1 "!contents? a$" : a$(answer)=a$ : answer=answer+1 #t.tb2 "!contents? a$" : a$(answer)=a$ : answer=answer+1 #t.tb3 "!contents? a$" : a$(answer)=a$ : answer=answer+1 'increase page to limit and show new questions page=page+(page<3) answer=p(page) #t.1, q$(answer) : #t.tb1 a$(answer) : answer=answer+1 #t.2, q$(answer) : #t.tb2 a$(answer) : answer=answer+1 #t.3, q$(answer) : #t.tb3 a$(answer) wait
[previous] 'save away current answers answer=p(page) #t.tb1 "!contents? a$" : a$(answer)=a$ : answer=answer+1 #t.tb2 "!contents? a$" : a$(answer)=a$ : answer=answer+1 #t.tb3 "!contents? a$" : a$(answer)=a$ : answer=answer+1 'decrease page to limit and show new questions page=page-(page>1) answer=p(page) #t.1, q$(answer) : #t.tb1 a$(answer) : answer=answer+1 #t.2, q$(answer) : #t.tb2 a$(answer) : answer=answer+1 #t.3, q$(answer) : #t.tb3 a$(answer) wait
[quit] close #t end
|
|
|
Post by honkytonk on Feb 6, 2020 7:36:00 GMT -5
You don't say if you ask the questions one by one. In this case, only one window A question file and an answer file A button to scroll through the questions A button to save the answers in the order of the questions A comparison of the two files to recover questions-> answers.
|
|
|
Post by metro on Feb 6, 2020 8:42:16 GMT -5
never had to use MAPHANDLE so just for "kicks & giggles" I thought I'd have a play could get messy with 1200 variables and multiple windows better solutions already posted.....
nomainwin GLOBAL x winName$ = "first second third" for x = 1 to 3 call createWindow word$(winName$, x) next x wait
sub createWindow title$
WindowWidth = 350 WindowHeight = 400 SELECT CASE x case 1 UpperLeftX = 10 UpperLeftY = 100 case 2 UpperLeftX =360 UpperLeftY = 100 case 3 UpperLeftX =710 UpperLeftY = 100 END SELECT menu #1, " File", "Open", [menuOpen], "Save", [menuSave], "Save As", [menuSaveAs], "Generate Report", [menuReport] menu #1, "Report", "Narrative Report", [menuNarrative], "Bullet Report", [menuBullet] menu #1, "Help", "Psych-Writer Help", [menuHelp] menu #1, "About", "About", [menuAbout] graphicbox #1.gbox, 10, 1, 70, 20 graphicbox #1.gbox2, 82, 1, 70, 20 Button #1.btn , "Add Text", AddText, UL, 240, 210 texteditor #1.te, 10, 30, 200, 200 open "text "+title$ for window as #1 CALL SetGB CALL SetGB2 #1.te "this is the "+title$+" window" #1 "trapclose aboutToClose" handle$ = "#"+title$ maphandle #1, handle$ end sub
SUB AddText handle$
SELECT CASE handle$
CASE "#first.btn" #first.te,"HERE @ First Window" CASE "#second.btn" #second.te,"HERE at TWO" CASE "#third.btn" #third.te,"HERE at Third" END SELECT
END SUB
[popupMenu] popupMenu "Reports", [Report1], "Search", [Search], "Calc", [Calc] WAIT
[Report1] Notice " reports in progress" WAIT
[Search] NOTICE "To Be Coded" WAIT
[Calc] notice "Calculate work in progress" WAIT
[popupMenu2] popupMenu "More", [Report2], "Search", [Search2], "Calc", [Calc2] WAIT [Report2] Notice " MORE reports in progress" WAIT [Search2] NOTICE "To Be Coded" WAIT
[Calc2] notice "Calculate work in progress"
WAIT
SUB SetGB #1.gbox, "home" 'center the pen #1.gbox, "goto 10 12" #1.gbox, "down" 'ready to draw #1.gbox, "backcolor buttonface" 'fill the graphics area red #1.gbox, "fill buttonface" #1.gbox, "color black " #1.gbox, "\Reports" #1.gbox, "flush" 'make the graphics stick ' #1.gbox, "when rightButtonUp [popupMenu]" #1.gbox, "when leftButtonUp [popupMenu]" END SUB
SUB SetGB2 #1.gbox2, "home" 'center the pen #1.gbox2, "goto 10 12" #1.gbox2, "down" 'ready to draw #1.gbox2, "backcolor buttonface" 'fill the graphics area red #1.gbox2, "fill buttonface" #1.gbox2, "color black " #1.gbox2, "\Extra's" #1.gbox2, "flush" 'make the graphics stick #1.gbox2, "when leftButtonUp [popupMenu2]" END SUB sub aboutToClose handle$ Notice "closing "; #handle$ close #handle$ end sub
[menuMaker] menu #1, " File", "Open", [menuOpen], "Save", [menuSave], "Save As", [menuSaveAs], "Generate Report", [menuReport] menu #1, "Report", "Narrative Report", [menuNarrative], "Bullet Report", [menuBullet] menu #1, "Help", "Psych-Writer Help", [menuHelp] menu #1, "About", "About", [menuAbout] return
|
|