Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / New to DarkBASIC kinda...

Author
Message
DarkBASIC Programmer Help
17
Years of Service
User Offline
Joined: 13th Feb 2007
Location:
Posted: 13th Feb 2007 21:39
I need some help with my program. It's right below. It continues to say (Runtime error on line 38. Object already exists.) I use DarkEdit, just to let you know.

------
remstart
This is a test for me to see how well I am with DarkBASIC. I
am going to make a working calculator that is 3D. It won't be too
great, so don't expect alot. I am expecting the following from my
program:

- To be able to multiply
- To be able to subtract
- To be able to add
- To be able to divide
- To be able to have program calculate it for me
- To use variables correctly
- To have working buttons
- To be able to close the program without the use of the
escapekey

Hopefully I will accomplish all these tasks.
remend


rem I should load all sounds, bitmaps, and music before the program begins to run.
load sound "C:\Documents and Settings\Owner\My Documents\wavs\menuUpDown.wav", 1
load sound "C:\Documents and Settings\Owner\My Documents\Sound Recorder\SC Mission 1 Sounds\ComBeep0.wav", 2

rem Now that all sounds are loaded, I need to begin my main loop.
do

rem I need to reset all variables before the program ends.
m = 0
d = 0
a = 0
s = 0

rem I need to create my multiply, divide, subtract, addition, and equal buttons.
Make object cube 1, 2
Make object cube 2, 2
Make object cube 3, 2
Make object cube 4, 2
Make object cube 5, 2

rem Now that's completed, I need to recolor and move these to their proper locations.
position object 1, 12, 0, 0
position object 2, 15, 0, 0
position object 3, 12, 12, 0
position object 4, 15, 15, 0
position object 5, 13.5, 13.5, 0

rem Now, I need to color my objects so I know which one is which.
color object 1, rgb(100, 0, 0): rem This one will be my addition.
color object 2, rgb(0, 100, 0): rem This one will be my subtraction.
color object 3, rgb(0, 0, 100): rem This one will be my multiplication.
color object 4, rgb(100, 100, 100): rem This one will be my division.
color object 5, rgb(0, 0, 0): rem This one will be my equal button.

rem I got to let the user know which button does which.
text 0, 0, add$
text 0, 10, sub$
text 0, 20, mul$
text 0, 30, div$

rem This will end my loop.
loop
----------
DarkBASIC Programmer Help
17
Years of Service
User Offline
Joined: 13th Feb 2007
Location:
Posted: 13th Feb 2007 21:45
I need some help with my program. It's right below. It continues to say (Runtime error on line 38. Object already exists.) I use DarkEdit, just to let you know.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 13th Feb 2007 23:43
It's because you create objects in a do/loop. The first time it loops it works because the objects don't exits... the second time it loops it tries to re-create the objects that already exist causing the error. If you move the "do" down to a line after the object creation it'll work without error.

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK

Login to post a reply

Server time is: 2024-11-26 22:33:10
Your offset time is: 2024-11-26 22:33:10