home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ANews 3
/
AnewsCD3.iso
/
DP
/
Programmation
/
PureBasic_Demo
/
Examples
/
Sources
/
Program1.pb
< prev
next >
Wrap
Text File
|
1999-10-10
|
3KB
|
139 lines
;
; Example program for the PureBasic programming langage
;
; Coded by AlphaSOUND - © 1999 Fantaisie Software
;
;
; 26/06/1999
; First version
;
WbStartup() ; This program can be started from the Workbench
InitWindow (10) ; All init stuffs
InitTagList(10) ;
InitGadget (10) ;
InitScreen (10) ;
InitRequester()
FindScreen(0,"") ; Catch the frontmost screen..
Dim texts.s(10)
; Now, create our window layout, fully font sensitive. To achieve that,
; we have 3 variables:
;
; HFont : To have the height of used gadget font
; HGadget : Our default gadget height
; DistGad : Our default distance between 2 gadgets (height only)
;
; With these, we can manipulate the gadget position very easely.
;
If CreateGadgetList(0,ScreenID())
HFont = ScreenFontHeight()
HGadget = HFont+6
DistGad = HGadget+4
HG = HFont+10
b3$ = "File Requester"
Buttongadget(3,10,HG,200,HGadget,b3$,0) : HG = HG+DistGad
b4$ = "Font Requester"
Buttongadget(4,10,HG,200,HGadget,b4$,0) : HG = HG+DistGad
b5$ = "Screen Requester"
Buttongadget(5,10,HG,200,HGadget,b5$,0) : HG = HG+DistGad
ResetTagList(#GTPA_Depth, 5)
PaletteGadget(2,10,HG,200,HGadget,0,TagListID()) : HG = HG+DistGad
texts(0) = "This is"
texts(1) = "A cool"
texts(2) = "PureBasic"
texts(3) = "Example"
ResetTagList(#GTCY_Labels,texts())
cyclegadget(6,10,HG,150,HGadget,0,TagListID()) : HG = HG+DistGad+4
b0$ = "Ok"
Buttongadget(0,10,HG,96,HGadget,b0$,0)
b1$ = "Cancel"
Buttongadget(1,115,HG,96,HGadget,b1$,0)
endif
Title.s = "PureBasic Test !"
ResetTagList(#WA_Title,Title)
If OpenWindow(2,100,100,215, HGadget*7+25, #WFLG_DRAGBAR | #WFLG_CLOSEGADGET, TagListID())
AttachGadgetList(0, WindowID())
Repeat
Repeat
VWait()
Event.l = WindowEvent()
Until Event<>0
If Event = #IDCMP_GADGETUP
Select EventGadget()
Case 0
Event = #IDCMP_CLOSEWINDOW
Case 1
Event = #IDCMP_CLOSEWINDOW
Case 2
NPrint("Palette gadget: "+Str(EventCode()))
Case 3
NPrint("File Requester: '"+FileRequester(0)+"'")
Case 4
FontRequester(0)
Case 5
ScreenRequester(0)
case 6
NPrint("Cycle gadget: "+Str(EventCode()))
If EventCode() = 2
GoSuB Surprise
Endif
EndSelect
Endif
Until Event = #IDCMP_CLOSEWINDOW
Else
NPrint("Error, I can't open the window")
Endif
End
Surprise:
ResetTagList(#WA_Title,Title)
If OpenWindow(1,200,200,200,30,#WFLG_DRAGBAR | #WFLG_CLOSEGADGET, TagListID())
Repeat
VWait()
Event.l = WindowEvent()
Until Event = #IDCMP_CLOSEWINDOW
CloseWindow(1)
Event = 0
Endif
Return