WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Boxes Examples from Users

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Use Boxes in a Quiz Format

Keywords:   boxes playwaveform 

Here's a nice example of how to use the Boxes functions, in a quiz format:
:top

cr = num2char(13)

IntControl(12,5,0,0,0)
;;;;;;;; Assorted Colors ;;;;;;;;;
DKBLUE="0,0,128"
BLUE="0,0,255"
LTGRAY="192,192,192"
GRAY="128,128,128"
DKGRAY="64,64,64"
GREEN="0,255,0"
RED="255,0,0"
BLACK="0,0,0"
WHITE="255,255,255"
YELLOW="255,255,0"

; question format is "question?|ans1@ans2@ans3@ans4|correct answer"
Question1="What is the capitol of Arizona?   | Phoenix  @ Madison @ Oak Creek @ Tuscon            |1"
Question2="What is the biggest tourist%cr%attraction in Arizona?      | The Great Barrier Reef      @ The Grand Canyon      @ The Grand Tetons     @ Sid's Seafood Emporium |2"
Question3="Where is Scottsdale%cr% from Phoenix? | North    @ West    @East      @ South             |2"
Question4="What is the population %cr%of Arizona?     | One      @ Two     @Three     @Four              |4"


BoxesUp("100,100,1000,1000",@ZOOMED)

Questionflag=0         ; 0 = start screen  1=Q1  2=Q2    999=Exit

While QuestionFlag!=999
   if questionflag==0
      gosub start
   else
      if IsDefined(Question%questionflag%)
        gosub doquestion
      else

  BoxDataClear(1,"buttons")

       BoxTextFont(1,"Times",275,80,0|0)
       BoxDrawText(1,"10,50,1000,1000","All Done!",@TRUE,1);;;
       BoxTextFont(1,"Times",75,80,0|0)
       BoxDrawText(1,"10,650,1000,1000","Thanks for taking the quiz.",@TRUE,1);;;
        Display(5,"Finished","No more questions")

;        Message("Huzzah","No more questions")
        questionflag=0 
      endif  
   endif 
endwhile

Exit

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:START ; The start screen
  BoxDataClear(1,"top")
  BoxColor(1,"0,0,128",4)
  BoxCaption(1,"Arizona, The Grand Canyon State                                                By: Katherine Eaton")
  bFacts=7

  bStart=6
  bExit=5  ;;;;;;;;;;;;;;;;;;MHW;;;;;;;;;;;;;;;;;;;

  BoxDrawRect(1,"0,0,1000,1000",2)
  BoxTextColor(1,"255,255,0")
  BoxTextFont(1,"Times",275,80,0|0)
  BoxDrawText(1,"160,50,1000,1000","Arizona",@TRUE,0);;;
;   BoxTextColor(1,"255,0,0")
  BoxTextFont(1,"Times",75,80,0|0)
  BoxDrawText(1,"205,320,1000,1000","The Grand Canyon State",@TRUE,0);;;
;   BoxTextColor(1,"0,255,0")
  BoxTextFont(1,"Times",35,80,0|0)
  BoxDrawText(1,"225,420,1000,1000","                             By: Katherine Eaton",@True,0);;;
  BoxTextColor(1,Green)
  BoxTextFont(1,"Times",75,80,0|0)
;  BoxDrawText(1,"10,650,1000,1000","To take a quiz on Arizona.",@TRUE,1);;;
  BoxDrawText(1,"10,750,1000,1000","Put on the headphones and press a button.",@TRUE,1);;;
  BoxTextFont(1,"Times",75,80,0|0)

 BoxButtonDraw(1,bFacts,    "Listen to facts on Arizona",  "200,860,500,930")        

 BoxButtonDraw(1,bStart,    "Take the quiz",  "600,860,850,930")    
 BoxButtonDraw(1,bExit,        "Exit",  "930,930,980,980")          
;;;;;;;;;;;;;MHW;;;;;;;;;;;;;

:wait
BoxButtonWait()

if BoxButtonStat(1,bFacts) 
       PlayWaveForm("C:\Arizona\Facts.wav", 1)
       gosub wait
       endif
if BoxButtonStat(1,bExit)
  questionflag=999    ; exit
else
  questionflag=1      ;proceed to question 1
endif
return

;;;;;;;;;;;;;;; END OF START SCREEN ;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;The Questioner;;;;;;;;;;;;;;;;;;;;;;;
:DoQuestion


ThisQuestion=Question%questionflag%
Question=strtrim(ItemExtract(1,ThisQuestion,"|"))
Answers=ItemExtract(2,ThisQuestion,"|")
Ans1=strtrim(ItemExtract(1,Answers,"@"))
Ans2=strtrim(ItemExtract(2,Answers,"@"))
Ans3=strtrim(ItemExtract(3,Answers,"@"))
Ans4=strtrim(ItemExtract(4,Answers,"@"))
CorrectAnswer=strtrim(ItemExtract(3,ThisQuestion,"|"))

Playwaveform("C:\Arizona\question%questionflag%.wav",1)



  BoxDataClear(1,"top")
  BoxColor(1,"0,0,128",4)
  BoxCaption(1,"Arizona, The Grand Canyon State                                      By Katherine Eaton")

  BoxDrawRect(1,"0,0,1000,1000",2)

  BoxTextFont(1,"Times",75,80,0|0)
  BoxTextColor(1,"255,255,0")
  BoxDrawText(1,"125,800,1000,1000","The Grand Canyon State",0,0);;;
  BoxTextFont(1,"Times",35,80,0|0)
  BoxDrawText(1,"125,900,1000,1000","                             By: Katherine Eaton",0,0);;;
  BoxTextFont(1,"Times",75,80,0|0)
;   BoxDataTag(1,"tag1")

;;;;; This section creates the fancy banner headline in a box
             rectNote="100,30,900,270"
             NoteHeight=275
             rectNoteText="70,200,950,800"
             
             rectnoteline1="0,0,1000,0"
             rectNoteline2="1000,1000,1000,0"
             rectNoteLine3="0,1000,1000,1000"
             rectNoteLine4="0,0,0,1000"
             notepenwidth=20
             rectnoteline1b="40,150,960,150"
             rectNoteline2b="960,840,960,150"
             rectNoteLine3b="40,840,960,840"
             rectNoteLine4b="40,150,40,840"
             notepenwidthb=10
             wbid=2
             Thermid=3
             Noteid=4
;debug(@on)
       BoxNew(Noteid,rectNote,1)
       BoxColor(Noteid,LTGRAY,0)       ; Light Gray no gradient
       BoxDrawRect(Noteid,"",2)
;;;;;  --------- This line changes the headline font-----------------      
       BoxTextFont(Noteid,"Arial",NoteHeight,170,0)
       BoxTextColor(Noteid,RED)
       
       BoxPen(Noteid,WHITE,notepenwidth)
       boxdrawline(Noteid,rectNoteLine1)
       boxdrawline(Noteid,rectNoteLine4)
       BoxPen(Noteid,GRAY,notepenwidth)
       boxdrawline(Noteid,rectNoteLine2)
       boxdrawline(Noteid,rectNoteLine3)
       BoxPen(Noteid,WHITE,notepenwidthb)
       boxdrawline(Noteid,rectNoteLine2b)
       boxdrawline(Noteid,rectNoteLine3b)
       BoxPen(Noteid,GRAY,notepenwidthb)
       boxdrawline(Noteid,rectNoteLine1b)
       boxdrawline(Noteid,rectNoteLine4b)
       

         BoxDrawText(Noteid,rectNoteText,question,1,4)

bA=1
bB=2
bC=3
bD=4
bexit=5

   BoxDataTag(1,"buttons")

  BoxButtonDraw(1,bA,       "A.",  "100,320,250,390")
  BoxDrawText(1,"350,310,300,400",Ans1,0,0);;;

  BoxButtonDraw(1,bB,        "B.", "100,410,250,480")    
  BoxDrawText(1,"350,400,300,400",Ans2,0,0);;;

  BoxButtonDraw(1,bC,       "C.", "100,500,250,570")    
  BoxDrawText(1,"350,590,300,490",Ans3,0,0);;;

  BoxButtonDraw(1,bD,       "D.", "100,590,250,660")    
  BoxDrawText(1,"375,655,303,580",Ans4,0,0);;;

  BoxButtonDraw(1,bExit,    "Exit",  "750,860,900,930")    



;;; Select a button  ;;;;
while 1
BoxButtonWait() 

bWho=0
while bWho == 0
       for x =1 to 5
              if BoxButtonStat(1,x) then bWho=x
       next
endwhile       


if bWho==bExit
   questionflag=0
   PlayWaveForm(" ", 0)
   BoxDestroy(Noteid)
   return
else
   if bWho==CorrectAnswer
      PlayWaveForm("C:\Arizona\Right.wav", 0)
      questionflag=questionflag+1
      BoxDestroy(Noteid)  
      return
   else
      PlayWaveForm("C:\Arizona\Wrong.wav", 0)
   endif
endif  

end while

Article ID:   W12751
Filename:   Arizona Quiz Box Example.txt
File Created: 1999:04:15:16:49:22
Last Updated: 1999:04:15:16:49:22