basicprogramming.org


Welcome, Guest. Please login or register.
Did you miss your activation email?
Forum time; Jul 31. 2010, 05:56
Home Help Search Calendar Login Register
News: Have you got suggestions for BasicProgramming.org? Let's hear them!
Interested in creating your own programming language? Check out the QDepartment group!

+  BASIC programming forum
|-+  Basic Coding
| |-+  General Basic Programming
| | |-+  Q&A
| | | |-+  Yabasic - Graphic menu
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Reply Print
Author Topic: Yabasic - Graphic menu  (Read 341 times)
Mainchip
Guest
« on: Mar 15. 2008, 18:17 » Reply with quote

Hi guys,

I have been using yabasic a lot lately and I have not really used graphics. The yabasic demo has a sort of menu where you can you the arrow keys to scroll up and down the menu and press enter on the navigation, can anyone create a really simple one using the graphic window so I can see how it works.

Thank you,
Mainchip.
Report to moderator   Logged
Mainchip
Guest
« Reply #1 on: Mar 16. 2008, 14:51 » Reply with quote

I have changed my mind about this, I do not want to use the graphic window.

Can someone create me a simple menu that moves up and down with arrow keys. Can they also explain how it works so I can learn from this.

Thank you,
Report to moderator   Logged
Derek
Administrator
Hero Member
*****
Offline Offline

Posts: 1001



WWW
« Reply #2 on: Mar 16. 2008, 16:05 » Reply with quote

Hi,

a few years ago I wrote a library for displaying a menu in the console. I've uploaded it to http://basicprogramming.org/derek/lib/menu.yab I haven't looked at it for a long time but it may help you.

If you want something less complicated as a demo then ask and I'll write something more basic but that will not happen till tomorrow night at the earliest, I'm afraid.

Code:
dim a$(3,2)
a$(1,1)="option 1"
a$(2,1)="option 2"
a$(3,1)="option 3"
opt = menu(a$())
print "Option was ", opt
will print a menu and allow a choice to be made. The choice will be marked in the second dimension of the array so next time it is used the previous choice will be highlighted.

Sorry you haven't had a reply earlier but I've been busy all day.

Derek.
« Last Edit: Mar 16. 2008, 16:06 by Derek » Report to moderator   Logged

wget http://*
Mainchip
Guest
« Reply #3 on: Mar 16. 2008, 17:09 » Reply with quote

Hey,

Thanks for this, I don't really understand it much. I going to take action and I am going to read the Yabasic manual I hope this allows me to understand and learn more.

How would I go about making my own commands, I remember once you telling me that:

Example$ - Can only store words.

Example - Can only store numbers.

But how can I create yabasic code, then re-use it if possible by just typing a simple command.

Not sure if this is possible, I guess not though because things would be a lot simpler.

Thank you,
Report to moderator   Logged
Derek
Administrator
Hero Member
*****
Offline Offline

Posts: 1001



WWW
« Reply #4 on: Mar 17. 2008, 11:53 » Reply with quote

Hi,

a trivial example of creating your own command would be:
Code:
sub DoubleThisNumber(number)
local answer
answer = number * 2
return answer
end sub
So everytime you wanted to multiply a number by two you'd say:
Code:
RandomNumber = ran(255)
RandomNumber = DoubleThisNumber(RandomNumber)
Functions/subroutines can also be used with strings:
Code:
RandomNumber$ =Str$( ran(255) )
RandomNumber$ = DoubleThisNumber$(RandomNumber$)
//
sub DoubleThisNumber$(number$)
local answer$
answer$ = number$ + number$
return answer$
end sub

I have no idea why anyone would to use those functions but they demonstrate the technique nicely.

Derek.
Report to moderator   Logged

wget http://*
Mainchip
Guest
« Reply #5 on: Mar 18. 2008, 16:59 » Reply with quote

Hi,

Thank you Derek this actually helped a lot.

Thank you,
Mainchip.
Report to moderator   Logged
Pages: [1] Go Up Reply Print 
« previous next »
Jump to:  
Atom RDF RSS 0.91 RSS 2.0


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!