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 / Error with array must have at least one subscript

Author
Message
SH4773R
14
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 4th Aug 2010 09:52
Im having a error with my arrays; arrays must have at least one subscript
im using a string variable with a operation stored like + or * and using it to operate on two values in an array (variable is operation$) it will let me if i type just the * but not with the vairable any help?


sync on
sync rate 30
print "Enter Amount of variable values"
input values
varcounter2 = 0
dim vars(values)
counter = values
Print "Enter operation to be exacuted (in computer symbol form)"
input operation$
varcounter = 0
repeat
print "Enter a value to" + operation$
input vars(varcounter)
varcounter = varcounter + 1
counter = counter - 1
until counter = 0 or varcounter = values
repeat
print vars(varcounter2)
varcounter2 = varcounter2 + 1
until varcounter2 = values
varcounter3 = 0
r = 0
r = vars(varcounter3) operation$ vars(varcounter3 + 1)
varcounter3 = 1
repeat
r = r operation$ vars(varcounter3)
values = values - 1
until values = 0
print r
wait key

Who the hell is General Failure? And why is he trying to read my hard disk?

My software never has bugs. It just develops random features.
wyrleywolves
21
Years of Service
User Offline
Joined: 6th May 2003
Location:
Posted: 4th Aug 2010 11:26
its not your array that is going wrong but your use of operation$ as a command.Here is some code for you to look at.Rem Project: Dark Basic Pro Project
Rem Created: Wednesday, August 04, 2010

Rem ***** Main Source File *****
sync on
sync rate 30
print "Enter Amount of variable values"
input values
varcounter2 = 0
dim vars(values)
counter = values
Print "Enter operation to be exacuted (in computer symbol form)"
input operation$
varcounter = 0
repeat
print "Enter a value to" + operation$
input vars(varcounter)
varcounter = varcounter + 1
counter = counter - 1
until counter = 0 or varcounter = values
repeat
print vars(varcounter2)
varcounter2 = varcounter2 + 1
until varcounter2 = values
varcounter3 = 0
r = 0
if operation$="+"
r = vars(varcounter3) + vars(varcounter3 + 1)
endif
if operation$="*"
r = vars(varcounter3) * vars(varcounter3 + 1)
endif
if operation$="-"
r = vars(varcounter3) - vars(varcounter3 + 1)
endif
if operation$="/"
r = vars(varcounter3) / vars(varcounter3 + 1)
endif
varcounter3 = 1
repeat
if operation$="+"
r = r + vars(varcounter3)
endif
if operation$="*"
r = r * vars(varcounter3)
endif
if operation$="-"
r = r - vars(varcounter3)
endif
if operation$="/"
r = r / vars(varcounter3)
endif
`r = r operation$ vars(varcounter3)
values = values - 1
until values = 0
print r
wait key
SH4773R
14
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 4th Aug 2010 18:25
Thanks I figured I'd have to do something like that

Who the hell is General Failure? And why is he trying to read my hard disk?

My software never has bugs. It just develops random features.
SH4773R
14
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 4th Aug 2010 18:55
now it has no build errors but at the end it just shoots out 3 0s

Who the hell is General Failure? And why is he trying to read my hard disk?

My software never has bugs. It just develops random features.

Login to post a reply

Server time is: 2024-11-16 15:54:53
Your offset time is: 2024-11-16 15:54:53