Simple Array Demo


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default A For-Next Loop

    Hi,

    "A,B,C..." all have an ASCII value. For example "A"=65 so an iteration like this can help

    Code:
    For I = 0 to 25
    char[I] = I + 65
    Next I
    P.S. PBP Manual has the ascii chart
    Attached Images Attached Images  
    Regards

    Sougata

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sougata View Post
    Hi,

    "A,B,C..." all have an ASCII value. For example "A"=65 so an iteration like this can help

    Code:
    For I = 0 to 25
    char[I] = I + 65
    Next I
    P.S. PBP Manual has the ascii chart
    As I look at this a year later, I now understand what this snippet does.
    "I realise there are likely easier ways to load the ARRAY . . .Baby Steps"
    It loads the variable CHAR with the Alphabet,<font color = BLUE> A Belated Thanks, Sougata .</font color>
    This response is to point that fact out to anyone new to arrays. Attention Newbies
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Joe,

    Did you know you can do this?

    Code:
    Dat VAR BYTE
    Alphabet VAR BYTE[26]
    
    Main:
        FOR Dat = "A" to "Z"
         Alphabet[Dat-65]=Dat ' load Alphabet array 0-25 with A-Z
         HSEROUT [Alphabet[Dat-65],13,10]
         PAUSE 50
        NEXT Dat
        PAUSE 5000
        GOTO Main
        
        END
    Last edited by Bruce; - 14th February 2010 at 19:56. Reason: Better example
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Nope !

    Quote Originally Posted by Bruce View Post
    Joe,

    Did you know you can do this?

    Code:
    Dat VAR BYTE
    Alphabet VAR BYTE[26]
    
    Main:
        FOR Dat = "A" to "Z"
         Alphabet[Dat-65]=Dat ' load Alphabet array 0-25 with A-Z
         HSEROUT [Alphabet[Dat-65],13,10]
         PAUSE 50
        NEXT Dat
        PAUSE 5000
        GOTO Main
        
        END
    Woo Hoo, another tidbit of knowledge! I did not know that.
    Thank You Bruce.
    JS
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 08:55
  2. 16f887 44 pin demo board code problem?
    By jessey in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 7th December 2008, 15:17
  3. Schematic for simple demo
    By iandonahue in forum USB
    Replies: 7
    Last Post: - 4th March 2008, 16:18
  4. RS232 receive an array (packet)
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th February 2008, 06:02
  5. Array to simple Variable converting
    By mrx23 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd September 2006, 17:44

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts