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 / Array Problem Please Help

Author
Message
LordDario
21
Years of Service
User Offline
Joined: 26th Apr 2003
Location:
Posted: 10th Apr 2004 21:10
Hi, im new to dark basic and am having a problem declaring an array heres my code, im getting an error immediately on the first dim statement what am i doing wrong?

REMSTART
************************
Title: Array and Print Practice
Project Start Date: April 10, 2004
Project End Date:
Creator: Dario Sousa
************************
REMEND

Rem : Creating Arrays and Setting of Variables

Dim dario's_stats_display$(5)
Dim dario's_stats_values(5)
Dim monster_groups(4,3)
dario's_stats_display$(1)="HP "
dario's_stats_display$(2)="MP "
dario's_stats_display$(3)="Atk "
dario's_stats_display$(4)="Def "
dario's_stats_display$(5)="Agi "
dario's_stats_values(1)=129
dario's_stats_values(2)=25
dario's_stats_values(3)=16
dario's_stats_values(4)=12
dario's_stats_values(5)=8
dario's_cash#=56.40

Rem : Displaying all the stats using Print

Print dario's_stats_display$(1),dario's_stats_values(1)
comando 300
20
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 10th Apr 2004 21:40 Edited at: 10th Apr 2004 21:43
Quote: "Dim dario's_stats_values(5)
Dim monster_groups(4,3)"


For arrays need to use this "#" or this "$" after the name.

Liks this:

Dim dario's_stats_values$(5)
Dim monster_groups$(4,3)

or

Dim dario's_stats_values#(5)
Dim monster_groups#(4,3)

In your case need the second one,because you are using numbers

I hope this helps

CURRENT PROJECT: RETRO PAC-MAN
LordDario
21
Years of Service
User Offline
Joined: 26th Apr 2003
Location:
Posted: 10th Apr 2004 21:54 Edited at: 10th Apr 2004 21:56
hmm but thats what i did.

Dim dario's_stats_display$(5)

I thought it was like an ordinary variable declaring but with dim and the parenthesis,if you want to declare a string array you use the $, if you want to declare a real number array you use # and for regular integer you use nothing right?
Flashing Blade
21
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 10th Apr 2004 22:03
Your problem is the apostrophy

change:
Dim dario's_stats_value(5)
to:
Dim darios_stats_value(5)


LordDario
21
Years of Service
User Offline
Joined: 26th Apr 2003
Location:
Posted: 10th Apr 2004 22:05
thanks, makes sense now, although i had no idea apostraphes werent allowed in variable names i know now, Thanks.
Emperor Baal
20
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 10th Apr 2004 22:42
Quote: "For arrays need to use this "#" or this "$" after the name.

Liks this:

Dim dario's_stats_values$(5)
Dim monster_groups$(4,3)

or

Dim dario's_stats_values#(5)
Dim monster_groups#(4,3)

In your case need the second one,because you are using numbers

I hope this helps"


I hope this forum wont ban you when you're about to laugh your ass off

Quote: "
UPDATED

Amd 2800+ 1024mb pc3200 A7N8X - Deluxe Ati Radeon 9800PRO 256mb
"
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 10th Apr 2004 23:22
These are the different types of arrays and variables in DBC:

variable - this is an integer variable, a whole number (0,1,-2)
variable# - this is a float variable, a decimal (0.0,1.2457,-3.14159)
string$ - this is a string, a text variable ("Word")

All of these can become arrays:

dim variable(10)
dim variable#(10)
dim string$(10)

When you define strings, use quotations, like this:
string$="You put words in strings"

I hope I was of some help...

Xander Moser of Bolt Software
Firewall: Your Computer's First Defense - Real Time Strategy game
[href][/href]

Login to post a reply

Server time is: 2024-09-22 04:28:34
Your offset time is: 2024-09-22 04:28:34