basicprogramming.org


Welcome, Guest. Please login or register.
Did you miss your activation email?
Forum time; Jul 31. 2010, 02:19
Home Help Search Calendar Login Register
News: Have you got suggestions for BasicProgramming.org? Let's hear them!
Interested in creating your own programming language? Check out the QDepartment group!

+  BASIC programming forum
|-+  Basic Coding
| |-+  General Basic Programming
| | |-+  Q&A
| | | |-+  Yabasic - Arrays
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: 1 [2] Go Down Reply Print
Author Topic: Yabasic - Arrays  (Read 607 times)
E.K.Virtanen
Blah
Hero Member
*****
Offline Offline

Posts: 2441



WWW
« Reply #15 on: Jun 18. 2008, 22:37 » Reply with quote

Sorry just thought of another question.
This forum is build for questions so dont be sorry for using it to that Wink

When creating an array, lets say I have 1000 first names and 1000 last names to store.
why wouldn't I just use a 1 dimensional array just make it bigger e.g: dim names$(2000) instead of:
dim names$(1000,2) ?

Usage of ram is not up to how many dimensions you have in arrays, but it's up to cells you have. So example:
dim array1(1000)
dim array2(500, 2)

both uses same amount of ram since array1 has 1000 cells and array2 has 1000 cells too.

Code:
first = 1
last = 2
age = 3
nation = 4

dim peoples$(5, 4)
peoples$(1, first) = "Kristian"
peoples$(1, last) = "Virtanen"
peoples$(1, age) = "32"
peoples$(1, nation) = "Finland"
peoples$(2, first) = "Stephane"
peoples$(2, last) = "Richards"
peoples$(2, age) = "155"
peoples$(2, nation) = "Canada/Usa"
...
...
...

This way, it is easier to control and solve what and from where to read from array Wink
Thought, you example works too.
Report to moderator   Logged

Mainchip
Guest
« Reply #16 on: Jun 19. 2008, 16:59 » Reply with quote

This is a nice way to put things.  Grin Grin Grin Grin
Report to moderator   Logged
Pages: 1 [2] Go Up Reply Print 
« previous next »
Jump to:  
Atom RDF RSS 0.91 RSS 2.0


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!