
-----------------------------------
Bruski
Sat Jun 14, 2003 11:16 am

Thanks you for all the help...but i need just a bit more
-----------------------------------
hey sorry for posting before demanding some things :( , i guess i was a bit stressed out at the moment, however ive solved most of my problems except for 2 that i cant seem to get around...they fairly simple i belive but i dont know the answer to them...I was just wondering if after you press the quit button the window closes instead of just ending the run. and the other question is how can i change the background of my checkboxes so that they are white, thank you hope im not asking too much...

heres the code 


import GUI 

View.Set ("graphics:650;300,nobuttonbar") 

%Declare identifiers
var nameTextField, addressTextField, cityTextField, provinceTextField, postalTextField, costTextField, yes2,no2, yes1,no1, fillClearButton,statusButton, refreshButton, quitButton : int 
var total, tax, cost, subTotal, GSTtot, PSTtot, discount, membership : real 
var tot := "" 
var sub := "" 
var gst := "" 
var pst := "" 
var dis := ""
var mem := ""
var pos := ""
var fill := true
const gstTax:=0.07 
const pstTax:=0.08 
var draw : boolean := false 
tax := 0.15 
var memFee:=0
var disTotal:=0.1

%procedures for fields and buttons
procedure NameEntered (text : string) 
   GUI.SetSelection (addressTextField, 0, 0) 
   GUI.SetActive (addressTextField) 
end NameEntered 

procedure AddressEntered (text : string) 
   GUI.SetSelection (cityTextField, 0, 0) 
   GUI.SetActive (cityTextField) 
end AddressEntered 

procedure CityEntered (text : string) 
   GUI.SetSelection (provinceTextField, 0, 0) 
   GUI.SetActive (provinceTextField) 
end CityEntered 

procedure ProvinceEntered (text : string) 
   GUI.SetSelection (postalTextField, 0, 0) 
   GUI.SetActive (postalTextField) 
end ProvinceEntered 

procedure PostalEntered (text : string) 
   GUI.SetSelection (costTextField, 0, 0) 
   GUI.SetActive (costTextField) 
end PostalEntered 

procedure CheckBoxPressed (filled : boolean)
        if yes1= GUI.GetEventWidgetID then
           memFee:=0
           disTotal:=0.1
        elsif yes2= GUI.GetEventWidgetID then
          memFee:=5
          disTotal:=0.1
        else
          memFee:=0
          disTotal:=0
        end if
end CheckBoxPressed

procedure RefreshPressed
    Draw.FillBox (0, 0, maxx, maxy, GUI.GetBackgroundColour)
    GUI.Refresh
end RefreshPressed


procedure CostCD (text : string) 
   total := strreal (text) + strreal (text) * tax - strreal (text)* disTotal +memFee
   tot := realstr (total, 10) 
   subTotal :=strreal (text) 
   sub := realstr (subTotal, 10) 
   GSTtot :=strreal (text) * gstTax 
   gst := realstr (GSTtot, 10) 
   PSTtot :=strreal (text) * pstTax 
   pst := realstr (PSTtot, 10)
   discount:=strreal (text)*disTotal
   dis:=realstr (discount, 10) 
   membership:=memFee
   mem:=realstr (membership, 10) 
end CostCD 

procedure emptyf (text : string) 
   tot:= "" 
   sub:= "" 
   gst:= "" 
   pst:= "" 
   dis:= ""
   mem:= ""
   pos:= ""
end emptyf 

procedure caculate () 
   draw := true 
end caculate 

GUI.SetBackgroundColor (yellow)
 
%declare fields & labels 
nameTextField := GUI.CreateTextFieldFull (155, 250, 155, "", NameEntered, GUI.INDENT, 0, 0) 
var nameLabel := GUI.CreateLabelFull (145, 250, "Name:", 0, 0, GUI.RIGHT, 0) 

addressTextField := GUI.CreateTextFieldFull (155, 220, 155, "", AddressEntered, GUI.INDENT, 0, 0) 
var addressLabel := GUI.CreateLabelFull (145, 220, "Address:", 0, 0, GUI.RIGHT, 0) 

cityTextField := GUI.CreateTextFieldFull (155, 190, 155, "", CityEntered, GUI.INDENT, 0, 0) 
var cityLabel := GUI.CreateLabelFull (145, 190, "City:", 0, 0, GUI.RIGHT, 0) 

provinceTextField := GUI.CreateTextFieldFull (155, 160, 45, "", ProvinceEntered, GUI.INDENT, 0, 0) 
var provinceLabel := GUI.CreateLabelFull (145, 160, "Province:", 0, 0, GUI.RIGHT, 0) 

postalTextField := GUI.CreateTextFieldFull (265, 160, 45, "", ProvinceEntered, GUI.INDENT, 0, 0) 
var postalLabel := GUI.CreateLabelFull (257, 160, "Zip Code:", 0, 0, GUI.RIGHT, 0)

costTextField := GUI.CreateTextFieldFull (155, 100, 155, "", CostCD, GUI.INDENT, 0, 0)
var costLabel := GUI.CreateLabelFull (145, 100, "Number of CDs:", 0, 0, GUI.RIGHT, 0) 

var taxtf := GUI.CreateTextFieldFull (420, 130, 155, "", emptyf, GUI.INDENT, 0, 0) 
var gtax := GUI.CreateLabelFull (410, 130, "Total: $", 0, 0,GUI.RIGHT, 0)

var subTotalf := GUI.CreateTextFieldFull (420, 250, 155, "", emptyf, GUI.INDENT, 0, 0) 
var gsub := GUI.CreateLabelFull (410, 250, "Subtotal: $", 0, 0,GUI.RIGHT, 0) 

var gstf := GUI.CreateTextFieldFull (420, 160, 55, "", emptyf, GUI.INDENT, 0, 0)
var ggst := GUI.CreateLabelFull (410, 160, "GST: $", 0, 0,GUI.RIGHT, 0) 


var pstf := GUI.CreateTextFieldFull (520, 160, 55, "", emptyf, GUI.INDENT, 0, 0)
var gpst := GUI.CreateLabelFull (515, 160, "PST: $", 0, 0,GUI.RIGHT, 0)

var disf := GUI.CreateTextFieldFull (420, 190, 155, "", emptyf, GUI.INDENT, 0, 0)
var gdis := GUI.CreateLabelFull (410, 190, "Discount: $", 0, 0,GUI.RIGHT, 0)

var memf := GUI.CreateTextFieldFull (420, 220, 155, "", emptyf, GUI.INDENT, 0, 0) 
var gmem := GUI.CreateLabelFull (410, 220, "Mem Fee: $", 0, 0,GUI.RIGHT, 0)

%checkboxes for membership
yes2 := GUI.CreateCheckBox (223, maxy - 177, "Yes?",CheckBoxPressed)
no2 := GUI.CreateCheckBox (270, maxy - 177, "No?",CheckBoxPressed)
var buymember := GUI.CreateLabelFull (210, maxy - 177, "If no, purchase a membership?", 0, 0,GUI.RIGHT, 0)
yes1 := GUI.CreateCheckBox (223, maxy - 157, "Yes?",CheckBoxPressed)
no1 := GUI.CreateCheckBox (270, maxy - 157, "No?",CheckBoxPressed)
var member := GUI.CreateLabelFull (210, maxy - 157, "Do you have a D3 membership card?", 0, 0,GUI.RIGHT, 0)

%line dividing buttons and fields
var line := GUI.CreateLine (0, maxy - 225, maxx, maxy - 225, 0)

%buttons
var quitBtn : int := GUI.CreateButton (150, 40, 100, "Quit", GUI.Quit)
var calcb : int := GUI.CreateButton (260, 40, 100, "Calculate", caculate) 
var clearScrn : int := GUI.CreateButton (370, 40, 100, "Clear Screen", RefreshPressed)

loop 
   if draw then 
       GUI.SetText (taxtf, tot) 
       GUI.SetText (subTotalf, sub) 
       GUI.SetText (gstf, gst) 
       GUI.SetText (pstf, pst) 
       GUI.SetText (disf, dis)
       GUI.SetText (memf, mem)
       draw := false 
   end if 
   exit when GUI.ProcessEvent 
end loop 



-----------------------------------
Tony
Sat Jun 14, 2003 11:43 am


-----------------------------------
:? Well we dont really need to see your source code for those guestions.

To exit the program after pressing quit button, you place quit command after your exit when GUI.ProcessEvent loop.

as for modifing background color of checkboxes... I'm afraid you'd have to go and modify the GUI module.

-----------------------------------
Prince
Sat Jun 14, 2003 11:49 am


-----------------------------------
if u want the window to close after u press the quit button put Window.Close(winID) after the last loop... im not sure about the check boxes but i think they jus go with the back ground colour so if u want thos white ur gonna hafta change the whole back ground to white (dont hold me to that tho)

-----------------------------------
nate
Sat Jun 14, 2003 12:37 pm


-----------------------------------
I know how 2 change the color! 

i think its just 

GUI.SetBackGroundColor (color)
this will only change the check boxes color! (hopefully cause it worked for me!)

-----------------------------------
Bruski
Sat Jun 14, 2003 1:13 pm


-----------------------------------
what do i put for the (winID) thinggy

-----------------------------------
Bruski
Sat Jun 14, 2003 1:14 pm


-----------------------------------
sadly text box color change didnt work...changes whole text to white

-----------------------------------
Prince
Sat Jun 14, 2003 2:55 pm


-----------------------------------
for the Window.Close to work u hafta open a window first so wher u hav View.Set at the top, change it to:


var win1 : int := Window.Open ("graphics:650;300,nobuttonbar")


then at the bottom, after the last loop put Window.Close (win1) and voila, uve just closed ur window 8)

-----------------------------------
Andy
Sat Jun 14, 2003 4:00 pm


-----------------------------------
man ppl, if u have GUI problems, type GUI and press f10

-----------------------------------
Homer_simpson
Sat Jun 14, 2003 5:48 pm


-----------------------------------
Type GUI then press F9 not F10

-----------------------------------
Bruski
Sat Jun 14, 2003 9:34 pm


-----------------------------------
lol thx....but how bout the text box question...ive solved the other one ...i just looked at an example...and the other one thats ticking me off is a clear button...so when the person presses clear, text boxes are cleared...any suggestions thx :D

-----------------------------------
nate
Sat Jun 14, 2003 9:52 pm

it does work
-----------------------------------
here is the code with the red text boxes! 

**give me bits***

import GUI 

View.Set ("graphics:650;300,nobuttonbar") 

%Declare identifiers 
var nameTextField, addressTextField, cityTextField, provinceTextField, postalTextField, costTextField, yes2,no2, yes1,no1, fillClearButton,statusButton, refreshButton, quitButton : int 
var total, tax, cost, subTotal, GSTtot, PSTtot, discount, membership : real 
var tot := "" 
var sub := "" 
var gst := "" 
var pst := "" 
var dis := "" 
var mem := "" 
var pos := "" 
var fill := true 
const gstTax:=0.07 
const pstTax:=0.08 
var draw : boolean := false 
tax := 0.15 
var memFee:=0 
var disTotal:=0.1 

%procedures for fields and buttons 
procedure NameEntered (text : string) 
   GUI.SetSelection (addressTextField, 0, 0) 
   GUI.SetActive (addressTextField) 
end NameEntered 

procedure AddressEntered (text : string) 
   GUI.SetSelection (cityTextField, 0, 0) 
   GUI.SetActive (cityTextField) 
end AddressEntered 

procedure CityEntered (text : string) 
   GUI.SetSelection (provinceTextField, 0, 0) 
   GUI.SetActive (provinceTextField) 
end CityEntered 

procedure ProvinceEntered (text : string) 
   GUI.SetSelection (postalTextField, 0, 0) 
   GUI.SetActive (postalTextField) 
end ProvinceEntered 

procedure PostalEntered (text : string) 
   GUI.SetSelection (costTextField, 0, 0) 
   GUI.SetActive (costTextField) 
end PostalEntered 

procedure CheckBoxPressed (filled : boolean) 
        if yes1= GUI.GetEventWidgetID then 
           memFee:=0 
           disTotal:=0.1 
        elsif yes2= GUI.GetEventWidgetID then 
          memFee:=5 
          disTotal:=0.1 
        else 
          memFee:=0 
          disTotal:=0 
        end if 
end CheckBoxPressed 

procedure RefreshPressed 
    Draw.FillBox (0, 0, maxx, maxy, GUI.GetBackgroundColour) 
    GUI.Refresh 
end RefreshPressed 


procedure CostCD (text : string) 
   total := strreal (text) + strreal (text) * tax - strreal (text)* disTotal +memFee 
   tot := realstr (total, 10) 
   subTotal :=strreal (text) 
   sub := realstr (subTotal, 10) 
   GSTtot :=strreal (text) * gstTax 
   gst := realstr (GSTtot, 10) 
   PSTtot :=strreal (text) * pstTax 
   pst := realstr (PSTtot, 10) 
   discount:=strreal (text)*disTotal 
   dis:=realstr (discount, 10) 
   membership:=memFee 
   mem:=realstr (membership, 10) 
end CostCD 

procedure emptyf (text : string) 
   tot:= "" 
   sub:= "" 
   gst:= "" 
   pst:= "" 
   dis:= "" 
   mem:= "" 
   pos:= "" 
end emptyf 

procedure caculate () 
   draw := true 
end caculate 

colorback (yellow)
GUI.SetBackgroundColor (brightred)
cls

%declare fields & labels 
nameTextField := GUI.CreateTextFieldFull (155, 250, 155, "", NameEntered, GUI.INDENT, 0, 0) 
var nameLabel := GUI.CreateLabelFull (145, 250, "Name:", 0, 0, GUI.RIGHT, 0) 

addressTextField := GUI.CreateTextFieldFull (155, 220, 155, "", AddressEntered, GUI.INDENT, 0, 0) 
var addressLabel := GUI.CreateLabelFull (145, 220, "Address:", 0, 0, GUI.RIGHT, 0) 

cityTextField := GUI.CreateTextFieldFull (155, 190, 155, "", CityEntered, GUI.INDENT, 0, 0) 
var cityLabel := GUI.CreateLabelFull (145, 190, "City:", 0, 0, GUI.RIGHT, 0) 

provinceTextField := GUI.CreateTextFieldFull (155, 160, 45, "", ProvinceEntered, GUI.INDENT, 0, 0) 
var provinceLabel := GUI.CreateLabelFull (145, 160, "Province:", 0, 0, GUI.RIGHT, 0) 

postalTextField := GUI.CreateTextFieldFull (265, 160, 45, "", ProvinceEntered, GUI.INDENT, 0, 0) 
var postalLabel := GUI.CreateLabelFull (257, 160, "Zip Code:", 0, 0, GUI.RIGHT, 0) 

costTextField := GUI.CreateTextFieldFull (155, 100, 155, "", CostCD, GUI.INDENT, 0, 0) 
var costLabel := GUI.CreateLabelFull (145, 100, "Number of CDs:", 0, 0, GUI.RIGHT, 0) 

var taxtf := GUI.CreateTextFieldFull (420, 130, 155, "", emptyf, GUI.INDENT, 0, 0) 
var gtax := GUI.CreateLabelFull (410, 130, "Total: $", 0, 0,GUI.RIGHT, 0) 

var subTotalf := GUI.CreateTextFieldFull (420, 250, 155, "", emptyf, GUI.INDENT, 0, 0) 
var gsub := GUI.CreateLabelFull (410, 250, "Subtotal: $", 0, 0,GUI.RIGHT, 0) 

var gstf := GUI.CreateTextFieldFull (420, 160, 55, "", emptyf, GUI.INDENT, 0, 0) 
var ggst := GUI.CreateLabelFull (410, 160, "GST: $", 0, 0,GUI.RIGHT, 0) 


var pstf := GUI.CreateTextFieldFull (520, 160, 55, "", emptyf, GUI.INDENT, 0, 0) 
var gpst := GUI.CreateLabelFull (515, 160, "PST: $", 0, 0,GUI.RIGHT, 0) 

var disf := GUI.CreateTextFieldFull (420, 190, 155, "", emptyf, GUI.INDENT, 0, 0) 
var gdis := GUI.CreateLabelFull (410, 190, "Discount: $", 0, 0,GUI.RIGHT, 0) 

var memf := GUI.CreateTextFieldFull (420, 220, 155, "", emptyf, GUI.INDENT, 0, 0) 
var gmem := GUI.CreateLabelFull (410, 220, "Mem Fee: $", 0, 0,GUI.RIGHT, 0) 

%checkboxes for membership 

yes2 := GUI.CreateCheckBox (223, maxy - 177, "Yes?",CheckBoxPressed) 
no2 := GUI.CreateCheckBox (270, maxy - 177, "No?",CheckBoxPressed) 
var buymember := GUI.CreateLabelFull (210, maxy - 177, "If no, purchase a membership?", 0, 0,GUI.RIGHT, 0) 
yes1 := GUI.CreateCheckBox (223, maxy - 157, "Yes?",CheckBoxPressed) 
no1 := GUI.CreateCheckBox (270, maxy - 157, "No?",CheckBoxPressed) 
var member := GUI.CreateLabelFull (210, maxy - 157, "Do you have a D3 membership card?", 0, 0,GUI.RIGHT, 0) 

%line dividing buttons and fields 
var line := GUI.CreateLine (0, maxy - 225, maxx, maxy - 225, 0) 

%buttons 
var quitBtn : int := GUI.CreateButton (150, 40, 100, "Quit", GUI.Quit) 
var calcb : int := GUI.CreateButton (260, 40, 100, "Calculate", caculate) 
var clearScrn : int := GUI.CreateButton (370, 40, 100, "Clear Screen", RefreshPressed) 

loop 
   if draw then 
       GUI.SetText (taxtf, tot) 
       GUI.SetText (subTotalf, sub) 
       GUI.SetText (gstf, gst) 
       GUI.SetText (pstf, pst) 
       GUI.SetText (disf, dis) 
       GUI.SetText (memf, mem) 
       draw := false 
   end if 
   exit when GUI.ProcessEvent 
end loop 

-----------------------------------
naoki
Sat Jun 14, 2003 9:54 pm


-----------------------------------
i dunno. u could use the repeat function and repeat blanks constantly but without delay. or you could just draw another box over it and re-locate the position to the beginning of the text box

-----------------------------------
Bruski
Sat Jun 14, 2003 10:56 pm


-----------------------------------
oooo....love you guys...thanks...the clear button is still puzzling me...if i draw each box again...my teacher will say thats redundant code  :cry: ...ima work on it...if anyone can help i would really appreciate it

-----------------------------------
Asok
Sun Jun 15, 2003 1:09 am


-----------------------------------
Locked for having an invalid subject title.

Please read over the rules moderating subjects.

Locked.
