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 Discussion / assigning values to arrays in loop

Author
Message
CALL ME B3AST
13
Years of Service
User Offline
Joined: 18th Oct 2010
Location: UNITED STATES
Posted: 18th Oct 2010 18:06 Edited at: 18th Oct 2010 19:12
Pardon my poor posting abilities, this is the first time I think I have ever posted on a forum...I have tried every possible way to assign a numeric value to an array variable like this. I don't know if I can correctly make a code snippet but here goes nothing.



It runs and compiles but the input line doesn't grab the input!?

Forgive me for sometimes I am such a noob.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 18th Oct 2010 23:36 Edited at: 18th Oct 2010 23:42
Hello CALL ME B3AST,

That is a strange problem. I ran a few tests with different arrays and it seems like input won't assign a value to an array. This is either a bug or INPUT in DBC was designed this way for some reason.

There is a simple work around, assign the input to another variable first, then to the array:



Rereading your post, you say you can't "assign" a numeric value to an array. I am assuming you mean by using the INPUT command, right?

Otherwise, you assign a value to an array just like any other value by using the assignment operator (equals =).



Enjoy your day.
CALL ME B3AST
13
Years of Service
User Offline
Joined: 18th Oct 2010
Location: UNITED STATES
Posted: 19th Oct 2010 06:33
I discovered your first solution nearly immediately after I posted...it's really odd that it doesn't work for you either. Thanks for your help!

Forgive me for sometimes I am such a noob.
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 19th Oct 2010 18:23
Hmmm I'll make a note that you can't directly write input to arrays. DB has a lot of design flaws like this but it's quick and dirty!


Do oranges know what colour they are?
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 20th Oct 2010 09:56
Yeah, this problem was really annoying when I wrote my first save files for my game... This code didn't work at all:



so I had to do what Latch said in the above post:



You'd think they'd fix this problem in DBP, but they didn't...

TheComet

BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 20th Oct 2010 19:56
Quote: ". DB has a lot of design flaws like this"


They aren't bugs, they're features

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Drakkheim
13
Years of Service
User Offline
Joined: 7th Oct 2010
Location: TX
Posted: 21st Oct 2010 18:38
and to really blow your mind, wrapping the input and assignment into its own function makes it work.
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 14th Jan 2011 01:51
Yikes. It's good to know of all this stuff! I wish these issues were documented better in the DBPro help file, or that these forums were improved/upgraded so that finding this sort of information wasn't governed by pure luck.

Login to post a reply

Server time is: 2024-04-19 08:12:23
Your offset time is: 2024-04-19 08:12:23