#Basic Help
11 messages in this thread
I have a problem creating menus in my basic programs. The way I read the
manual,I should be able to place a check mark alongside a menu ME remove the
checkmark (with the menu item still activated) with MENU x,x,1. What I find is
that when I create a menu item with a checkmark, it is virtually impossible to
remove it save destroying the entire menu with "menu reset" and then recreating
it without the chechmark. Where did I go wrong? My frustration level will
appreciate your reply.
Gene
Gene, I think you have the idea for creating a menu. Say you have a menu
item MENU 5,2 that was initialized with a checkmark on (MENU 5,2,2). If
you want the checkmark to disappear, just do a MENU 5,2,1 . I just tried
it and it seems to work. I imaging you can ghost the item with MENU 5,2,0
but never tried it.
73, Kelly
Kelly, The process you described is just what I couldn't get to work (which
puzzled me greatly because it is the logical way to "uncheck" a menu). I just
got the 1.2 version of basic and tried the x,x,1 vs. x,x,2 toggle with negative
results. Since you say it works for you, I'll log off and try again and see
what I'm doing wrong. Thanks for the reply!
Gene
Gene,
I will leave you another reply with the simple program I made to try your
problem on. I dunno, it seemed kinda simple. When I looked in the Advanced
Amiga Basic book I thought it said that the toggling of the checkmark was
automatic, but it is not so. You have to turn the checkmark on and off your
self. Anyways, I don't think this was your problem.
The little program makes a new menu (#5). There are three items in the
menu. The first item will just print a comment when ever you hit it.
The second one has the checkmark in it. Every time you hit it, it will
toggle the checkmark, and also print what happened. The third menu item
just removes the menu and quits.
I don't know why you are having any problems. It all seemed so simple.
Maybe you will see what you are overlooking. I never used menus before, so
this helped to break my shyness (?) of using them. Hope this helps.
73, Kelly
MENU 5,0,1,"Test"
MENU 5,1,1,"Hit me"
MENU 5,2,2," Hi"
MENU 5,3,1,"Finish"
ON MENU GOSUB CheckMenu
MENU ON
toggle = 1
WHILE 1<>2
SLEEP
WEND
STOP
CheckMenu:
menuid = MENU(0)
menuitem = MENU(1)
IF menuitem = 3 THEN
MENU OFF
MENU RESET
STOP
END IF
IF menuitem = 2 THEN PRINT "Hi there!"
IF menuitem = 1 THEN
MENU 5,2,2-toggle
toggle = 1-toggle
PRINT "you toggled me"
END IF
RETURN
Kelly,
Yes, there is definitely an ovesight smewhere on my part, but I sure couldn't
find it. I will definitely fire up your program and see where I went wrong.
Hope to get back to you right away…if I get sidetracked for a couple of days,
please forgive me. I will let you know how it worked out. I am very
appreciative of your interest.
Gene
Kelly,
Got it! You pointed out a fact that I was missing, or that is missing from
my literature. It seems that a text ID is not required behind the menu and item
ID's. In fact, it seems that rewriting the entire menu and item ID's with a new
checkmark,uncheckmark number is totally ignored. For example:
menu 5,0,1, "Test"
menu 5,1,2, " Hi there"
menu 5,1,1, " Hi there"
keepgoing:goto keepgoing
..does not produce a checkmarked "Hi there" immediately followed by an
uncheckmarked "Hi there". The menu item stays checkmarked eternally, even
though it seemingly was last told to be unchecked in the above command
progression. What does work is:
menu 5,0,1, "Test"
menu 5,1,2, " Hi there"
menu 5,1,1
keepgoing:goto keepgoing
The above does not include text to rewrite the uncheckmarked "version" of hi
there, nor does it want a comma following the last "1" in 5,1,1. You'll note
that I simplified the examples (I hope) for clarity; in neither case did I
expect to see a checkmarked item appear before it was replaced by it's
5ncheckmarked offspring. Much thanx for the understandable and concise example
that has solved my problem. Obviously the world needs 1) more people like you.
2) better manuals, or 3) people that can read manuals better than I can.
Nowhere have I read that you can write "menu 5,1,1 and get anything other than
"syntax error" because of the lack of a comma and item description enclosed in
quotes! Lesson learned. Uh…one more thing. The while/wend loop in your
example raises a question. The "while 1<>2" must(?) refer to the current menu
selection, how does the while/wend know to distinguish between the menu
selection values and other values being bandied about in the program? I guess
what I mean is I don't understand the syntax of while/wend arguments. If you
have any energy left after answering my other dumb question, please fire away!
Thanks again, Gene
/ex
Gene, glad I could help.
1) Thanks.
2) I know what you mean. Actually, the AmigaBasic manual for the Amiga is
probably the best manual CBM has ever shipped for any of their computers.
What I wish they would add to the manual is a few pages to act as a quick
reference of what the commands are. They could have an alphabetical list of
all the AmigaBasic commands with a one liner about what the command does,
then have another list, but broken down into 'type' of commands, like sound,
graphics, math, string manipulation, etc. It would make it a lot easier for
people to find the command to do what they want especially when they can't
remember what the command is!! (I fall into that category since I don't use
too many of the features of AmigaBasic)
3) hehe
The "while 1<>2 … wend" ha he haha ha ha.. (SORRY about that)
No, it has nothing to do with the menus. I wanted a loop that would go on
forever, and that was the first thing that popped into my head!
Since 1 will never equal 2, the loop will go on forever. I terminate the
loop via the menu command I had in my menu. The while…wend has nothing to
do with the menu stuff.
Hope that cleared up that little bit of confusion I may have inflicted into
your mind 8).
73, Kelly
Cute Kelly. Ye old 'dynamic halt'. I used to get those in my assembly code
all the time (intentionally of course). And if you believe that (intentional
in my code), I have a real good deal in some land! <grin>
73s,
bill
Gene,
I investigated your problem; and sure enough there appears to be a bug. MENU
5,1,2," Checked":MENU 5,1,1," Uncheck" fails Doing these commands will
NOT reset the check mark. Only redefining the Menu title will allow this series
of commands to work. Toggling MENU 5,1,2," Test":MENU 5,1,1 will work all
day. BTW the first set of code will redefine the menu item title, but it
leaves the checkmark.
What I've found was the following: MENU 5,1,2," Checked":MENU 5,1,1,"
Uncheck" fails MENU 5,1,1," Uncheck":MENU 5,1,2," Checked" works MENU
5,1,1," Uncheck":MENU 5,1,2 works MENU 5,1,2," Checked":MENU
5,1,1 works
As a last word, get the book "Advanced Amiga Basic", by Tom R. Halfhill and
Charles Brannon, Compute! Publications, Inc. It decribes all sorts of good and
wonderful things.
Sid
Sid,
I sure love to be right, but not when it costs me ( and every body else's
time) figuring these things out. Your investigation is much apprecitated – you
and Kelly should probably be writing the darned manuals. My frustration level
on this one ac~ually caused me to write a "menu reset" command into a program
followed by a complete redefintion of the entire menu, just to uncheck a menu
item. It workeked. On your recommendation, I will definitely order "Advanced
Amiga Basic". I don't own any games for my Amiga: there are enough things to
keep me occupied with the capabilities of the machine and what it will do for
me in my work, and Basic has done the job for me so far (in comparison with the
time I would have to spend learning "C" or machine language). Somebody should
start a basic programming section hereabouts! There would probably be a lot of
fans. Let's keep at it – hope to be able to help you in return someday.
Gene