How to use Arrays Using Pic Basic Pro(need help)


Closed Thread
Results 1 to 27 of 27

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    while not Finished ;; is not part of PBP? in my book it does not even suggest anything of this nature
    Really?
    You must have a very old version.
    While:Wend has been there for as long as I can remember.

    In case it's just an old manual mixup ...
    Try looking here.
    http://www.melabs.com/resources/index.htm#Manuals

    LOOKUP key,[" ABCDEFGHIJ"],Char

    how does this work I have seen this before but I could never wrap my hands around it and get the feel for it.
    There needs to be a space before the "A", just because your keypad routine only returns values starting at 1, and Lookup starts at 0.

    LOOKUP is pretty straight forward.
    It returns the value from the "List" of items that corresponds to the "key" value.

    If key = 1 then after the statement, Char will be "A". And ...
    key = 2, char = "B"
    key = 3, char = "C"
    etc. etc.

    Finished VAR BIT : Finished = 0 ;;I'm a little confused here are you commenting it or is it part of the declaration?( : Finished = 0 )
    Ummm, we'll call that the "skimask initialization syntax".
    You might get that later. Inside Joke.

    But no, it's not commented. The colon ":", separates two statements, as if they were on separate lines. I.E...
    Code:
    Finished VAR BIT : Finished = 0
    
    ; is the same as
    
    Finished VAR BIT
    Finished = 0
    StrLen = StrLen + 1 ;;Does this increment to next position?
    Yes it does.

    I know there's more questions, but let's see where this get's you?
    <br>
    DT

  2. #2
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Ummm, we'll call that the "skimask initialization syntax".
    You might get that later. Inside Joke.

    But no, it's not commented. The colon ":", separates two statements, as if they were on separate lines.
    Standard BASIC syntax from "In the beginning...."

    Anybody remember Beagle Bros. Two-Liners? What could you do with 2 lines of code, packed as tightly as possible? I think it was 64 characters max per line, but can't remember.

    I have actually picked up the technique again, for the same reason Skimask mentioned: Less scrolling, more compact code listings, keeps related code elements together. Once I got used to it again, I found it easier to read (as long as it wasn't used excessively). Thanks Skimask!

    SteveB

    Edit: A little research yields "less than approximately 150 characters" per line of Apple II code. Page 23 (26th pdf page) of this reproduction 1978 Apple II reference Manual
    Last edited by SteveB; - 30th June 2007 at 18:49.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    I agree, in general it's a good idea, but like beer, when used with moderation

    Not bad...
    Code:
    PORTB=0 : LATB=0 : TRISB=0
        '    OR
    SELECT CASE Pouet
        CASE 1 : Gosub MarryHadALittleBoy
        CASE 2 : Gosub DoSomethingElse
        '
        END SELECT
    But erm...
    Code:
    CounterA=0 : CounterB = 1234 : TRISB = 0 : OPTION_REG=%10101010 : LCDOUT $FE,1,"Hello dear!" : Gosub KindaLongLine : IF A=0 then : V=1234 : ELSE : q=908 : ENDIF : GOSUB ItsReallyReallyLongNow : PORTA=128 : PORTC=144 : PAUSE 150 : I2CREAD SDA, SCL, ControlByte, Address, [$FF,$EA, 1,2,3,4,5,6,7,8,9,CounterA, CounterB,0,0,0] : LCDOUT $FE,$C0,"Ok i think you see the picture now" : Gosub OKImDone ' Startup thingy :o)
    that's a bit too much, not sure if it compile anyway

    I don't remind if that syntax was available on that one... ;o}


    That's the whole kit with the speech synthesizer module, but without the tape deck... nostalgic now :-(

    Last edited by mister_e; - 30th June 2007 at 19:09.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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


    Did you find this post helpful? Yes | No

    Default Re: TRS80

    Quote Originally Posted by mister_e View Post
    I agree, in general it's a good idea, but like beer, when used with moderation

    [/img]
    I never could get one of those to work . . . could't find the ANY Key
    EDIT: DOH TI90 either
    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.

  5. #5
    MrSafe's Avatar
    MrSafe Guest


    Did you find this post helpful? Yes | No

    Default

    I still can not get the arrays to work. Look at my program to see what I am doing wrong I haven't tried the other suggestions yet but I will get started on those as soon as i figure out the arrays.
    Attached Files Attached Files

  6. #6
    MrSafe's Avatar
    MrSafe Guest


    Did you find this post helpful? Yes | No

    Default

    In the program when i do

    lcdout #key it shoots out the key correctly on the lcd however

    when i use

    htxt(x) = #key

    it says bad expression when i try to compile

    also when i use

    htxt(x) = key

    it works fine however it displays a blank spot on the lcd

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by MrSafe View Post
    In the program when i do
    lcdout #key it shoots out the key correctly on the lcd however
    when i use
    htxt(x) = #key
    it says bad expression when i try to compile
    also when i use
    htxt(x) = key
    it works fine however it displays a blank spot on the lcd
    htxt(x) = key ------>>>>> lookup key , [ "0123456789ABCDEF" ] , htxt[x]
    ^get rid of^---------------^^^^^^ replace with ^^^^^^^^^^^

    Your turn to figure out why assigning the variable 'key' to htxt(x) and trying to get the LCD to display what is effectively variable 'key' doesn't work.
    What is the ASCII character equivalent to 'key', if 'key' = 1? if 'key' = 2? if 'key' = 65?
    Last edited by skimask; - 3rd July 2007 at 02:08.

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Ummm, we'll call that the "skimask initialization syntax".
    HEY...I resemble that remark!

  9. #9
    MrSafe's Avatar
    MrSafe Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Really?
    You must have a very old version.
    While:Wend has been there for as long as I can remember.

    In case it's just an old manual mixup ...
    Try looking here.
    http://www.melabs.com/resources/index.htm#Manuals

    There needs to be a space before the "A", just because your keypad routine only returns values starting at 1, and Lookup starts at 0.

    LOOKUP is pretty straight forward.
    It returns the value from the "List" of items that corresponds to the "key" value.

    If key = 1 then after the statement, Char will be "A". And ...
    key = 2, char = "B"
    key = 3, char = "C"
    etc. etc.


    Ummm, we'll call that the "skimask initialization syntax".
    You might get that later. Inside Joke.

    But no, it's not commented. The colon ":", separates two statements, as if they were on separate lines. I.E...
    Code:
    Finished VAR BIT : Finished = 0
    
    ; is the same as
    
    Finished VAR BIT
    Finished = 0


    Yes it does.

    I know there's more questions, but let's see where this get's you?
    <br>
    Thank You I will go and test this out I will be gone for a few days but I will return with the result. Thank You again

    I know understand a little bit im still confused on how to use arrays specifically but this portion I understand to a great degree.

    I understand how to declare my array but thats about it however I will tr first with this knowledge and see if that works. I hope this thread isnt closed :-) If you dont mind I will beback with a few more questions thank you again.

  10. #10
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Was getting pretty tired during that last post, so cut it off a little short. But, now that I've had a good Day's sleep, let's see if I can tackle the rest.

    You're probably out of town by now, but that's ok. It'll still be here when you get back.

    Also why do you have 2 endif statements?
    Good catch, the first one was supposed to be an ELSE.(DOH!) I modified the original post.

    SEROUT2 PORTD.0, 813, [STR htxt\StrLen,13,10] ;; May I still use SEROUT or Must I use SEROUT2. ( [STR htxt\StrLen,13,10] I do not full Understand this portion could you explain to me what this is doing?)
    No, you don't have to use SEROUT2. It just makes it a little easier, so I tend to use it more often.

    The STR-ing function can send the entire contents of an array with one easy statement. In the case of STR htxt\StrLen, it will send the number of bytes specified in the StrLen variable from the htxt array.

    It's pretty much the same as ...
    Code:
    For X = 0 to StrLen
        SEROUT PORTD.0, T1200,[htxt(X)]
    NEXT X
    It's up to you which one you prefer. But STR isn't avaialable with SEROUT.

    And ..., oh I guess that's all there was. Must have been really tired.
    <br>
    DT

  11. #11
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default Coding styles

    There's big upsides in producing clean, readable and well commented code. Namely for mainly for maintainability. When you type out large programs without comments and go back to them 6 months down the track to revise them, you'll find that you'll spend some considerable time in recalling what's what. Comments also make your program much more legible to anyone else who reads them. Some languages are case sensitive, Java's one of them, I think this in someways encourages the programmer to adhere to acceptable standards. Indenting your code also improves readability, in my opinion, a fine example of well formated code would be Melanie's, Darrel's & Mister_e's. In the long run, you'll save time and probably end up producing much better algorithms if you go the extra mile to properly format & document your work. Most often, programs written in BASIC that make use of many colons are quite quickly dismissed as "spaghetti code"

Similar Threads

  1. Sending Commands from Visual Basic about IR to Pic
    By tne_de in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th April 2009, 06:09
  2. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  3. using AND as an IF statement
    By dw_pic in forum mel PIC BASIC
    Replies: 27
    Last Post: - 8th June 2006, 18:05
  4. vb6 to pic basic
    By Darrenmac in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 19th December 2005, 01:56
  5. The Ultimate PIC Basic
    By picnaut in forum PBP Wish List
    Replies: 4
    Last Post: - 9th November 2004, 22:10

Members who have read this thread : 2

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