Yes. Arrays.

by (Login rpgfan3233)

 

The only difference is the fact that BASIC doesn't care about the types as long as they're put into a location that is supposed to have the proper type. For example, you could have a DATA line that contains 1.0, Hello, 3, and as long as you use the READ statement with the appropriate variable type (SINGLE/DOUBLE/INTEGER/LONG, STRING, SINGLE/DOUBLE/INTEGER/LONG), your program will be fine. With C++ you can't do that. You could achieve it using a library such as Boost that allows for a "variant" type. Other than that minor difference of separation of types, it's pretty much the same.

// DIM strArray(2) AS STRING
// DATA "Hello,", "World!"
// FOR i = LBOUND(strArray) TO UBOUND(strArray)
// READ strArray(i)
// NEXT i
const char *str_array[] =
{
"Hello,", "World!"
};

// DIM numArray(5) AS SINGLE
// DATA 1.0, 4.0, 6.0, 4.0, 1.0
// FOR i = LBOUND(numArray) TO UBOUND(numArray)
// READ numArray(i)
// NEXT i
float numArray[] =
{
1.0, 4.0, 6.0, 4.0, 1.0
};

That's pretty much it. If you need an actual string type to work with in C++, change "const char *" to "string" and remember to #include <string>.



    
This message has been edited by rpgfan3233 on Jul 18, 2011 9:58 AM

Posted on Jul 18, 2011, 9:57 AM

Respond to this message   

Return to Index

Response TitleAuthor and Date
Thanks a lot, but...cantide5ga on Jul 18
 Re: Thanks a lot, but... on Jul 18
  Nothing fancy.cantide5ga on Jul 19
   how are you displaying graphics in C?Anonymous on Jul 20
    How I am doing itcantide5ga on Jul 21
     Re: How I am doing itAnonymous on Jul 21
      line endingsAnonymous on Jul 21
    *Something I've been chewing on: tuple and/or structs? What do you folks think?cantide5ga on Jul 21
     * Tuples - why? Structs - would you use TYPE...END TYPE in QB? on Jul 21
      The struct way...cantide5ga on Jul 21
      *err... the code on that response got butchered, get back to yacantide5ga on Jul 21
      The struct way, take 2cantide5ga on Jul 21
       Very nice idea and representation on Jul 21
   Here is a way that allows several types of data. on Jul 25
    Very nice. Some questions...cantide5ga on Jul 26
     * Regarding spaces...Replace All - Find: " ", Replace: "&nbsp;" on Jul 26
     There is an advantage to CG's method, but it's not necessary to be THAT OO. on Jul 26
     Re: questions on Jul 26
      *I'll come back and fix the formatting and characters in a bit. on Jul 26
       *Voila! C'est fini! I fixed it. on Jul 26
      * No empty graphics? Why? ...oh yeah. What would you put in them if they're empty? :P on Jul 26
      posting on Jul 27

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement