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.

DarkBASIC Professional Discussion / a little help with the " dim"

Author
Message
sinkler20
23
Years of Service
User Offline
Joined: 12th Mar 2003
Location: United States
Posted: 4th Jul 2003 00:28
Just learning and trying to store info.
I'm just playing around and i'm trying to store a batting average and continue to add to it by adding new at bats and hits. i'll put in my source code, but do not laugh.... I tryed and errored many things( more errors than anything). I did manage to " dim " a name$. so i'm getting close.



rem batting average
rem center text 25
rem RGB(255,255,0)1
set text to bolditalic
set text size 16
ink 5000,20

circle 300,250,100

x = 100
y = 100
rem text x,y, 100
rem return dword = RGB(255,0,255)
dim name$()
name$= Z$
print " what is your name?"
input Z$
rem print name$
do
wait 3000
cls
set text size 16
ink 5000,20
print z$
print " number of at bats"
dim battingavg()
battingavg = c#
input a#
print " number of hits"
input b#
c# = b# / a#
print " batting average"
set text size 35
print c#
print battingavg
set text size 16
if c# >= .220
print "welcome aboard,", Z

else
print "go back to the minors ,", Z$
endif
loop
wait key
philippians 4:13
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 4th Jul 2003 01:40
With DIM you need to specify the number of elements you want to allocate - dim battingavg() - should be something like dim battingavg(12). Same with dim name$()

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins and other exciting things - oh my, yes!
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 4th Jul 2003 05:32
Is it possible to reallocate the size of an existing array? Something like REDIM in VB? Thanks!

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 4th Jul 2003 06:22
not as such... you can only add stacks and delete stacks - its essentially the same thing only you don't loose all of your data & it is setup in a linear fashion (the current add stack at element and such have bugs apparently which are fixxed for U5)



hopefully thats a good example

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Jul 2003 10:06
You can resize an array quite easily.

Here's a piece of code for you to work your way through

Login to post a reply

Server time is: 2026-07-17 13:57:42
Your offset time is: 2026-07-17 13:57:42