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

Username:   Password: 
 RegisterRegister   
 ERROR help, probably pretty simple 2 fix
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
glp




PostPosted: Sat Jul 30, 2005 2:22 pm   Post subject: ERROR help, probably pretty simple 2 fix

code:

import GUI

var winID := Window.Open ("graphics:700;500")
var font1 := Font.New ("serif:20:bold")
var font2 := Font.New ("serif:14:bold")
var font3 := Font.New ("lucida console:8")
var key : string (1)
var money : int := 1000
var priceCD : int
var priceCD2 : string
var priceWEED : int
var priceWEED2 : string
var priceCAR : int
var priceCAR2 : string
var priceSTER : int
var priceSTER2 : string
var weed, car, steroid, cd := 0
var winbuy : int
var jacket := 20
var health := 100
var debt := 3500
var SteroidsBuy:int

%--------------------------Procedures-----------------------------------------

procedure Steroidsbought (text : string)
    GUI.SetSelection (SteroidsBuy, 0, 0)
    GUI.SetActive (SteroidsBuy)
    money := money - steroid * priceSTER
    GUI.CloseWindow (winbuy)
end Steroidsbought

procedure cancel
    GUI.CloseWindow (winbuy)
end cancel

procedure BuySteroids
    winbuy := Window.Open ("position:top;center,graphics:300;100")
    put "   How Many?"
    var SteroidsBuy : int := GUI.CreateTextField (30, 50, 100, "",
        Steroidsbought)
    var buy := GUI.CreateButton (52, 5, 100, "Buy", GUI.Quit)
    var cancelbtn : int := GUI.CreateButton (200, 20, 0, "Cancel", cancel)
end BuySteroids

procedure SellSteroids
    winbuy := Window.Open ("position:top;center,graphics:300;200")
    put "   How Many?"
    var cancelbtn : int := GUI.CreateButton (200, 20, 0, "Cancel", cancel)
end SellSteroids

procedure BuyCD
    winbuy := Window.Open ("position:top;center,graphics:300;200")
    put "   How Many?"
    var cancelbtn : int := GUI.CreateButton (200, 20, 0, "Cancel", cancel)
end BuyCD

procedure SellCD
    winbuy := Window.Open ("position:top;center,graphics:300;200")
    put "   How Many?"
    var cancelbtn : int := GUI.CreateButton (200, 20, 0, "Cancel", cancel)
end SellCD

procedure BuyCAR
    winbuy := Window.Open ("position:top;center,graphics:300;200")
    put "   How Many?"
    var cancelbtn : int := GUI.CreateButton (200, 20, 0, "Cancel", cancel)
end BuyCAR

procedure SellCAR
    winbuy := Window.Open ("position:top;center,graphics:300;200")
    put "   How Many?"
    var cancelbtn : int := GUI.CreateButton (200, 20, 0, "Cancel", cancel)
end SellCAR

procedure Buyweed
    winbuy := Window.Open ("position:top;center,graphics:300;200")
    put "   How Many?"
    var cancelbtn : int := GUI.CreateButton (200, 20, 0, "Cancel", cancel)
end Buyweed

procedure Sellweed
    winbuy := Window.Open ("position:top;center,graphics:300;200")
    put "   How Many?"
    var cancelbtn : int := GUI.CreateButton (200, 20, 0, "Cancel", cancel)
end Sellweed


%----------------------------------------Intro-------------------------------------------------------------------

View.Set ("nocursor")
View.Set ("noecho")
assert font1 > 0
assert font2 > 0
assert font3 > 0
Font.Draw ("BLACKMARKET v0.9", 210, 250, font1, black)
Font.Draw ("PRESS ANY KEY", 280, 220, font2, black)
getch (key)
cls

%---------------------------------------Set Prices--------------------------------------------------------------

loop
    randint (priceCD, 3, 10)
    priceCD2 := intstr (priceCD)

    randint (priceWEED, 20, 40)
    priceWEED2 := intstr (priceWEED)

    randint (priceCAR, 80, 120)
    priceCAR2 := intstr (priceCAR)

    randint (priceSTER, 140, 180)
    priceSTER2 := intstr (priceSTER)

    %----------------------------Draw Screen-----------------------------------------------------

    locatexy (85, 440)
    put "Your Jacket (", jacket, ")"

    locatexy (20, 410)
    put "Steroids:         ", steroid

    locatexy (20, 380)
    put "Car Parts:        ", car

    locatexy (20, 340)
    put "Marijuana:        ", weed

    locatexy (20, 310)
    put "CDs:              ", cd

    Draw.Box (10, 467, 275, 287, black)

    locatexy (65, 150)
    put "What's for Sale"

    locatexy (20, 20)
    put "Compact Discs"
    Font.Draw ("$" + priceCD2, 200, 24, font2, black)

    locatexy (20, 60)
    put "Marijuana"
    Font.Draw ("$" + priceWEED2, 200, 62, font2, black)

    locatexy (20, 100)
    put "Car Parts"
    Font.Draw ("$" + priceCAR2, 200, 96, font2, black)

    locatexy (20, 140)
    put "Steroids"
    Font.Draw ("$" + priceSTER2, 200, 129, font2, black)
    Draw.Box (10, 10, 275, 190, black)

    locatexy (440, 140)
    put "Money:           $", money

    locatexy (440, 100)
    put "Health:          ", health, "%"

    locatexy (440, 60)
    put "Debt:            $", debt

    Draw.Box (690, 10, 425, 190, black)

    %-------------------------Buttons------------------------------------

    var buy2 : int := GUI.CreateButton (290, 55, 20, "Buy",
        Buyweed)

    var sell2 : int := GUI.CreateButton (358, 55, 20, "Sell",
        Sellweed)

    var buy3 : int := GUI.CreateButton (290, 125, 20, "Buy",
        BuySteroids)

    var sell3 : int := GUI.CreateButton (358, 125, 20, "Sell",
        SellSteroids)

    var buy4 : int := GUI.CreateButton (290, 20, 20, "Buy",
        BuyCD)

    var sell4 : int := GUI.CreateButton (358, 20, 20, "Sell",
        SellCD)

    var buy5 : int := GUI.CreateButton (290, 90, 20, "Buy",
        BuyCAR)

    var sell5 : int := GUI.CreateButton (358, 90, 20, "Sell",
        SellCAR)

    loop
        exit when GUI.ProcessEvent
    end loop
end loop



This is a buy/sell business game i've been making for fun.Thing is I'm getting this error "Row of -19 is less than 1" when you click "Buy" "steroids" and then press "buy" again. Normally I can fix this but I don't see a "-19". Pls help

I apologize if this is a stupid little error that's easy to fix and I should know better. It's been awhile!
Sponsor
Sponsor
Sponsor
sponsor
MysticVegeta




PostPosted: Sat Jul 30, 2005 3:36 pm   Post subject: (No subject)

It happens because when the new window opens up, the x and y coordinates are no longer max by max. They decrease so locating a pixel location of 440 will give an error since the height of the window is not maxy anymore.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: