Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 GUI culminating activity
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Bruski




PostPosted: Wed Jun 11, 2003 7:37 pm   Post subject: GUI culminating activity

Hello everyone, im just having some problems with this GUI thing, i wanted to use the GUI. commands because it seem easier than writting all the code that my teacher gave me. I just had some problems....i want to put a cost of a cd in a field and then press a button and calc the total with tax....anyone got any ideas here is what i have soo far...

code:

import GUI
 
View.Set ("graphics:600;300,nobuttonbar")

var nameTextField, addressTextField, cityTextField, provinceTextField, costTextField : int
var total, tax, cost : real

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(costTextField, 0, 0)
        GUI.SetActive (costTextField)
end ProvinceEntered

procedure CostCD (text: string)
        locatexy(
        get cost
end CostCD




GUI.SetBackgroundColor (yellow)
%declare fields & labels
nameTextField := GUI.CreateTextFieldFull (65, 250, 100, "",
        NameEntered, GUI.INDENT, 0, 0)
var nameLabel := GUI.CreateLabelFull (55, 250, "Name:", 0, 0,
        GUI.RIGHT, 0)
       
addressTextField := GUI.CreateTextFieldFull (65, 220, 100, "",
        AddressEntered, GUI.INDENT, 0, 0)
var addressLabel := GUI.CreateLabelFull (55, 220, "Address:", 0, 0,
        GUI.RIGHT, 0)
       
cityTextField := GUI.CreateTextFieldFull (65, 190, 100, "",
        CityEntered, GUI.INDENT, 0, 0)
var cityLabel := GUI.CreateLabelFull (55, 190, "City:", 0, 0,
        GUI.RIGHT, 0)
       
provinceTextField := GUI.CreateTextFieldFull (65, 160, 100, "",
        ProvinceEntered, GUI.INDENT, 0, 0)
var provinceLabel := GUI.CreateLabelFull (55, 160, "Province:", 0, 0,
        GUI.RIGHT, 0)
       
cost := GUI.CreateTextFieldFull (65, 130, 100, "",
        CostCD, GUI.INDENT, 0, 0)
var costLabel := GUI.CreateLabelFull (55, 130, "CD Cost:", 0, 0,
        GUI.RIGHT, 0)       

var quitBtn : int := GUI.CreateButton (200, 10, 0, "Quit", GUI.Quit)
loop
    exit when GUI.ProcessEvent
end loop




anything would be appreciated thanks alot

alex Crying or Very sad
Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Wed Jun 11, 2003 7:53 pm   Post subject: (No subject)

why do u want the cost in a text field? do u mean text box?
Bruski




PostPosted: Wed Jun 11, 2003 7:56 pm   Post subject: (No subject)

i want to enter the cost of a cd in one field...then press calculate and it takes the cost of the cd and calcualtes the subtotal total gst pst etc Razz
Andy




PostPosted: Wed Jun 11, 2003 7:59 pm   Post subject: (No subject)

ooo sry i mis read
Bruski




PostPosted: Wed Jun 11, 2003 8:03 pm   Post subject: (No subject)

anyway to help me?
Andy




PostPosted: Wed Jun 11, 2003 8:05 pm   Post subject: (No subject)

it think this is what u want


code:

import GUI

View.Set ("graphics:600;300,nobuttonbar")

var nameTextField, addressTextField, cityTextField, provinceTextField, costTextField : int
var total, tax, cost : real
tax:=0.15
colorback(yellow)

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 (costTextField, 0, 0)
    GUI.SetActive (costTextField)
end ProvinceEntered

procedure CostCD (text : string)
total:= strreal(text)+strreal(text)*tax
locate(12,1)
put "total is",total
end CostCD




GUI.SetBackgroundColor (yellow)
%declare fields & labels
nameTextField := GUI.CreateTextFieldFull (65, 250, 100, "",
    NameEntered, GUI.INDENT, 0, 0)
var nameLabel := GUI.CreateLabelFull (55, 250, "Name:", 0, 0,
    GUI.RIGHT, 0)

addressTextField := GUI.CreateTextFieldFull (65, 220, 100, "",
    AddressEntered, GUI.INDENT, 0, 0)
var addressLabel := GUI.CreateLabelFull (55, 220, "Address:", 0, 0,
    GUI.RIGHT, 0)

cityTextField := GUI.CreateTextFieldFull (65, 190, 100, "",
    CityEntered, GUI.INDENT, 0, 0)
var cityLabel := GUI.CreateLabelFull (55, 190, "City:", 0, 0,
    GUI.RIGHT, 0)

provinceTextField := GUI.CreateTextFieldFull (65, 160, 100, "",
    ProvinceEntered, GUI.INDENT, 0, 0)
var provinceLabel := GUI.CreateLabelFull (55, 160, "Province:", 0, 0,
    GUI.RIGHT, 0)

costTextField := GUI.CreateTextFieldFull (65, 130, 100, "",
    CostCD, GUI.INDENT, 0, 0)
var costLabel := GUI.CreateLabelFull (55, 130, "CD Cost:", 0, 0,
    GUI.RIGHT, 0)

var quitBtn : int := GUI.CreateButton (200, 10, 0, "Quit", GUI.Quit)
loop
    exit when GUI.ProcessEvent
end loop

Bruski




PostPosted: Wed Jun 11, 2003 8:12 pm   Post subject: (No subject)

man your way too cool...thx alot..ima check it
Bruski




PostPosted: Wed Jun 11, 2003 8:13 pm   Post subject: (No subject)

hmm is there anyway to put that in a text field like the others and have it calc by a button? Embarassed
Andy




PostPosted: Wed Jun 11, 2003 8:13 pm   Post subject: (No subject)

haha, np, anytime although cause of exams, i'm not gonna be on very often next week
Bruski




PostPosted: Wed Jun 11, 2003 8:16 pm   Post subject: (No subject)

yea i just need it by fri cuz its due monday...i just need a simple example and ill get the rest...thx again
Homer_simpson




PostPosted: Wed Jun 11, 2003 10:25 pm   Post subject: (No subject)

code:
import GUI

View.Set ("graphics:600;300,nobuttonbar")

var nameTextField, addressTextField, cityTextField, provinceTextField, costTextField : int
var total, tax, cost : real
var output := ""
var draw : boolean := false
tax := 0.15
colorback (black)

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 (costTextField, 0, 0)
    GUI.SetActive (costTextField)
end ProvinceEntered

procedure emptyf (text : string)
    output := ""
end emptyf

procedure CostCD (text : string)
    total := strreal (text) + strreal (text) * tax
    output := realstr (total, 10)
end CostCD

procedure caculate ()
    draw := true
end caculate

GUI.SetBackgroundColor (yellow)
%declare fields & labels
nameTextField := GUI.CreateTextFieldFull (65, 250, 100, "", NameEntered, GUI.INDENT, 0, 0)
var nameLabel := GUI.CreateLabelFull (55, 250, "Name:", 0, 0, GUI.RIGHT, 0)

addressTextField := GUI.CreateTextFieldFull (65, 220, 100, "", AddressEntered, GUI.INDENT, 0, 0)
var addressLabel := GUI.CreateLabelFull (55, 220, "Address:", 0, 0, GUI.RIGHT, 0)

cityTextField := GUI.CreateTextFieldFull (65, 190, 100, "", CityEntered, GUI.INDENT, 0, 0)
var cityLabel := GUI.CreateLabelFull (55, 190, "City:", 0, 0, GUI.RIGHT, 0)

provinceTextField := GUI.CreateTextFieldFull (65, 160, 100, "", ProvinceEntered, GUI.INDENT, 0, 0)
var provinceLabel := GUI.CreateLabelFull (55, 160, "Province:", 0, 0, GUI.RIGHT, 0)

var taxtf := GUI.CreateTextFieldFull (65, 90, 100, "", emptyf, GUI.INDENT, 0, 0)


costTextField := GUI.CreateTextFieldFull (65, 130, 100, "", CostCD, GUI.INDENT, 0, 0)
var gtax := GUI.CreateLabelFull (55, 90, "tax:", 0, 0,
    GUI.RIGHT, 0)

var costLabel := GUI.CreateLabelFull (55, 130, "CD Cost:", 0, 0, GUI.RIGHT, 0)
var quitBtn : int := GUI.CreateButton (200, 10, 0, "Quit", GUI.Quit)

var calcb : int := GUI.CreateButton (260, 10, 0, "Caclulate", caculate)
loop
    if draw then
        GUI.SetText (taxtf, output)
        draw := false
    end if
    exit when GUI.ProcessEvent
end loop

this isn't a very clean code(cuz i made it fast) but it does the job...
Bruski




PostPosted: Thu Jun 12, 2003 6:22 am   Post subject: (No subject)

thank you thank you thank you....you guys are too good.... Very Happy
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: