March 29, 2024, 01:36:07 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


How to use MESSAGEBOX with CB.

Started by Egil, May 07, 2016, 05:33:16 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Egil

May 07, 2016, 05:33:16 AM Last Edit: May 07, 2016, 05:37:09 AM by Egil
This morning I got a visit by two very young gentlemen that just have started to experiment with the free version of Creative Basic, posted by Graham a while ago: (http://www.ionicwind.com/forums/index.php?topic=5560.0)

They saw I was playing around with messageboxes using IWB, and asked if that also was possible with CB. The CB user manual showed only very basic information, but one of the first posts I read after becoming a member on this forum, was also posted by Graham, and described how to use messageboxes: (http://www.ionicwind.com/forums/index.php?topic=2075.0).

Using Graham's information, a little demo was made. And in case someone else need this information, the code is posted here:


'-------------------------------------------------------------------------------------
' SkeletonWin.CBA
'-------------------------------------------------------------------------------------
'
AutoDefine "Off"

DECLARE About(wnd:window)
DECLARE AskExit(wnd:window)
DECLARE MyMenu(wnd:window)

def win:window  
def run:int  

Window win,-480,0,480,300,0,0,"    CB Skeleton Window",messages  

move win,140,110
print win,"Right-Click for Menu"
run = 1  
WAITUNTIL run = 0  
CLOSEWINDOW win  
END  

'
SUB messages(),int
'-------------------------------------------------------------------------------------
' Main Loop
'-------------------------------------------------------------------------------------
'
SELECT @class

CASE @idcreate  
centerwindow win  

CASE @idclosewindow  
run = 0  

CASE @IDKEYDOWN
if GETKEYSTATE(0x1B) <> 0 then AskExit(win) :' ESC pressed - want to exit?

CASE @IDRBUTTONUP
MyMenu(win)
CASE @IDMENUPICK
SELECT @MENUNUM
case 10
About(win)
case 20
system "http://www.ionicwind.com/forums/index.php?topic=2075.0"
case 30
AskExit(win)
ENDSELECT

ENDSELECT  
RETURN
'-------------------------------------------------------------------------------------


'  
SUB MyMenu(wnd:window)
'-------------------------------------------------------------------------------------
' Contextmenu - Popping up at pointer location
'-------------------------------------------------------------------------------------  
'
CONTEXTMENU wnd,@MOUSEX,@MOUSEY,"I,About,0,10","I,Graham's article,0,20","I,Exit,0,30"

RETURN

'
SUB AskExit(wnd:window)
'-------------------------------------------------------------------------------------
' Ask if you really want to exit
'-------------------------------------------------------------------------------------
'
def txt0$,txt1$,crlf$:string
crlf$=chr$(10)+chr$(13)
txt0$=""
txt1$="        Do you really want to exit? "
if MESSAGEBOX(wnd,txt1$,txt0$,0x30|0x04) = 0x06 then  run = 0
RETURN

'
SUB About(wnd:window)
'-------------------------------------------------------------------------------------
' Showing messagebox
'-------------------------------------------------------------------------------------
'
def txt0$,txt1$,crlf$:string
crlf$=chr$(10)+chr$(13)
txt0$="      Coded with Creative Basic          "
txt1$="      ENJOY!  "
MESSAGEBOX wnd,txt1$,txt0$,0x40
RETURN




I'm always pleasantly surprised to see how quickly these young boys learn how to program, using CB. Their main limitation is the lack of english language skills. Hopefully they'll also learn english very soon.

Support Amateur Radio  -  Have a ham  for dinner!

GWS

Hi Egil,

Your demo works OK  :)

I noticed some strange html type characters had crept into the posted notes - so I've edited them out now ..

I hope your youngsters enjoy Creative .. it's a little jewel of a program.

Best wishes, ;D

Graham
Tomorrow may be too late ..

Egil

Guess the garbelled text was a result of the hacking incidents three years ago.
Every time I see a webpage containing interresting texts, I store a copy of the text in a shareware program called MemPad. I only add the URL from which the texts were copied. And the original text have no "strange characters".

I have observed several times how the young kids enjoy playing with CB. The user interface is so intuitive, that after only a few minutes with guidance they play happily along themselves. Even for kids with no english language knowledge.

Then, as soon as they see that they really can make their own code control a computer, they think robotics. That's where we "lose" them... :-\



Support Amateur Radio  -  Have a ham  for dinner!