Loading ...
Sorry, an error occurred while loading the content.

Two-dimensional Arrays

Expand Messages
  • zbigezone
    Hi Group! Beginning programming for dummies states that Liberty Basic supports one- or two-dimmensional arrays. Yet, one of the two-dimensional array examples
    Message 1 of 6 , Mar 2 6:36 PM
    • 0 Attachment
      Hi Group!

      Beginning programming for dummies states that Liberty Basic supports
      one- or two-dimmensional arrays. Yet, one of the two-dimensional
      array examples provided in the book does not compile. In fact the
      error that occurs in the first line of code is a SYNTAX error. The
      example is presented is identical to the example in the book.

      I am suspicious that maybe LB does not support two-dimensional
      arrays.

      '*********************************************************************
      'This is the example:
      '*********************************************************************

      DIM VictimArray$(2, 3) AS STRING
      FOR I = 1 TO 2
      FOR I = 1 TO 3
      PROMPT "Who do you want to hurt"; Enemy$
      VictimArray$(I, J) = Enemy$
      NEXT J
      NEXT I

      PROMPT "Type X location of the array item that you want to print,
      such as 1"; X
      PROMPT "Type Y location of the array item that you want to print,
      such 1"; Y
      PRINT VictimArray$(X, Y) + " deserves to be hurt the most."
      END
      **********************************************************************

      Can someone offer advice? Thanks in advance.

      Tommy Morris
    • Scott A. Rossell
      Lose the AS STRING after the DIM and change the nexted For loop to J instead of another I. and you ve got a chance. The book is goofy in some places. ...
      Message 2 of 6 , Mar 2 6:52 PM
      • 0 Attachment
        Lose the "AS STRING" after the DIM and change the nexted For loop to J
        instead of another I. and you've got a chance. The book is goofy in some
        places.


        -----Original Message-----
        From: zbigezone [mailto:tommy.lee@...]
        Sent: Saturday, March 02, 2002 6:37 PM
        To: libertybasic@yahoogroups.com
        Subject: [libertybasic] Two-dimensional Arrays


        Hi Group!

        Beginning programming for dummies states that Liberty Basic supports
        one- or two-dimmensional arrays. Yet, one of the two-dimensional
        array examples provided in the book does not compile. In fact the
        error that occurs in the first line of code is a SYNTAX error. The
        example is presented is identical to the example in the book.

        I am suspicious that maybe LB does not support two-dimensional
        arrays.

        '*********************************************************************
        'This is the example:
        '*********************************************************************

        DIM VictimArray$(2, 3) AS STRING
        FOR I = 1 TO 2
        FOR I = 1 TO 3
        PROMPT "Who do you want to hurt"; Enemy$
        VictimArray$(I, J) = Enemy$
        NEXT J
        NEXT I

        PROMPT "Type X location of the array item that you want to print,
        such as 1"; X
        PROMPT "Type Y location of the array item that you want to print,
        such 1"; Y
        PRINT VictimArray$(X, Y) + " deserves to be hurt the most."
        END
        **********************************************************************

        Can someone offer advice? Thanks in advance.

        Tommy Morris



        To unsubscribe from this group, send an email to:
        libertybasic-unsubscribe@egroups.com



        Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
      • Doyle Whisenant
        ... Straight from the LB help file: ******** FILES Description: The FILES statement collects file and directory information from any disk and or directory and
        Message 3 of 6 , Mar 2 6:55 PM
        • 0 Attachment
          zbigezone wrote:
          >
          > Hi Group!
          >
          > Beginning programming for dummies states that Liberty Basic supports
          > one- or two-dimmensional arrays. Yet, one of the two-dimensional
          > array examples provided in the book does not compile. In fact the
          > error that occurs in the first line of code is a SYNTAX error. The
          > example is presented is identical to the example in the book.
          >
          > I am suspicious that maybe LB does not support two-dimensional
          > arrays.

          Straight from the LB help file:

          ********
          FILES

          Description:

          The FILES statement collects file and directory information from any
          disk and or directory and fills a double-dimensioned array with the
          information. Also good for determining if a specific file exists (see
          below).

          Usage:

          'you must predimension info$(, even though FILES will
          'redimension it to fit the information it provides.
          dim info$(10, 10)

          *********

          Notice anything about the last line?

          I think maybe reading the help file provided by LB and relying on it
          would be the best way to go and not with info from a third party book!

          YMMV (Your Mileage May Vary)

          --
          Doyle Whisenant
          mechanic@...
          http://www.mechanic.0catch.com/
        • Chergarj@cs.com
          In a message dated 03/02/2002 6:37:22 PM Pacific Standard Time, ... You could try it without the AS STRING part in the dimension line. As long as you
          Message 4 of 6 , Mar 2 8:01 PM
          • 0 Attachment
            In a message dated 03/02/2002 6:37:22 PM Pacific Standard Time, tommy.lee@... writes:


            DIM VictimArray$(2, 3) AS STRING
            FOR I = 1 TO 2
               FOR I = 1 TO 3
                   PROMPT "Who do you want to hurt"; Enemy$
                   VictimArray$(I, J) = Enemy$
               NEXT J
            NEXT I

            PROMPT "Type X location of the array item that you want to print,
            such as 1"; X
            PROMPT "Type Y location of the array item that you want to print,
            such 1"; Y
            PRINT VictimArray$(X, Y) + " deserves to be hurt the most."
            END
            **********************************************************************


            You could try it without the    AS STRING   part in the dimension line.  As long as you have the    $     at the end of the variable, it will be a string.  

            G C
          • zbigezone
            Scott, Thanks for your response. I should ve caught the J variable. And, you are right, getting rid of the AS STRING does the trick. Again, thanks! And,
            Message 5 of 6 , Mar 2 8:45 PM
            • 0 Attachment
              Scott,

              Thanks for your response. I should've caught the "J" variable. And,
              you are right, getting rid of the "AS STRING" does the trick.

              Again, thanks!

              And, thanks to all the others who took the time to respond.

              Tommy Morris

              --- In libertybasic@y..., "Scott A. Rossell" <sarossell@c...> wrote:
              > Lose the "AS STRING" after the DIM and change the nexted For loop
              to J
              > instead of another I. and you've got a chance. The book is goofy
              in some
              > places.
              >
              >
              > -----Original Message-----
              > From: zbigezone [mailto:tommy.lee@v...]
              > Sent: Saturday, March 02, 2002 6:37 PM
              > To: libertybasic@y...
              > Subject: [libertybasic] Two-dimensional Arrays
              >
              >
              > Hi Group!
              >
              > Beginning programming for dummies states that Liberty Basic supports
              > one- or two-dimmensional arrays. Yet, one of the two-dimensional
              > array examples provided in the book does not compile. In fact the
              > error that occurs in the first line of code is a SYNTAX error. The
              > example is presented is identical to the example in the book.
              >
              > I am suspicious that maybe LB does not support two-dimensional
              > arrays.
              >
              > '*******************************************************************
              **
              > 'This is the example:
              > '*******************************************************************
              **
              >
              > DIM VictimArray$(2, 3) AS STRING
              > FOR I = 1 TO 2
              > FOR I = 1 TO 3
              > PROMPT "Who do you want to hurt"; Enemy$
              > VictimArray$(I, J) = Enemy$
              > NEXT J
              > NEXT I
              >
              > PROMPT "Type X location of the array item that you want to print,
              > such as 1"; X
              > PROMPT "Type Y location of the array item that you want to print,
              > such 1"; Y
              > PRINT VictimArray$(X, Y) + " deserves to be hurt the most."
              > END
              >
              **********************************************************************
              >
              > Can someone offer advice? Thanks in advance.
              >
              > Tommy Morris
              >
              >
              >
              > To unsubscribe from this group, send an email to:
              > libertybasic-unsubscribe@e...
              >
              >
              >
              > Your use of Yahoo! Groups is subject to
              http://docs.yahoo.com/info/terms/
            • watson
              ... Others have answered you, so I won t be redundant. Twice in the past week, I ve posted messages to this group warning people that the Dummies book (and the
              Message 6 of 6 , Mar 3 3:27 AM
              • 0 Attachment
                At 02:36 AM 3/3/02 -0000, you wrote:
                >Hi Group!
                >
                >Beginning programming for dummies states that Liberty Basic supports
                >one- or two-dimmensional arrays. Yet, one of the two-dimensional
                >array examples provided in the book does not compile.

                Others have answered you, so I won't be redundant.

                Twice in the past week, I've posted messages to this group warning people
                that the Dummies book (and the Sams book also, for that matter) contain
                many errors as regards LB syntax. When you run into a problem, always look
                at the Liberty BASIC helpfile. (You might also want to check the ebook on
                the cdrom called "Using Liberty BASIC 2".)

                Both of the books that use LB for examples are very good, but neither of
                the author's was careful enough about reading the LB documentation himself,
                or about actually trying his own examples. The first editions of these
                books used QBasic, and the code is usually a port from QB to LB, and it is
                not always correct.

                Alyce
              Your message has been successfully submitted and would be delivered to recipients shortly.