Confused.... Help Please!


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    Sep 2010
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    The issue is that a space is equal to the decimal value of 3 as you stated above, since the decimal numbers 0-9 are being used already it will remove any cells filled with 3 if i were to check that.

    When an array is created and all the cells are empty they are literally empty right? filled with nothing? is there a way to empty a cell or delete its contents? I cannot seem to find any information on array manipulation in the manual (im guessing its old)

    This includes shifting values in cells too, all i can find is a section about creating the array.

    It does have ArrayRead and ArrayWrite but those are for strings.
    Last edited by UKIkarus; - 29th September 2010 at 15:57.

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    How do you send a space to the LCD? In fact, How do you send any character to the LCD? keep in mind, I don't think the number 3 is the same as "3". The number 3 is an interger, and "3" is a string. I assume the string is really converted to its UNICODE equal. So I THINK (i am not sure) these would be 2 different arrays:
    Code:
    t(0)=1
    t(1)=3
    t(2)=9
    
    t(0)="1"
    t(1)="3"
    t(2)="9"
    the problem you are facing, is there is NO integer space. there are only numbers 0-infinety. BTW there is also no n. the target after 9. So it should be as big a problem as the space if you are using an array of intergers.

    If you use an array of strings, each element is only 1 charater big, the space is no problem. It sounds to me like you are trying to mix numbers and strings. That is a big NO-NO!

    If you can post some or all of your code, I may understand better. I have no inclination to write it for you (and I don't think you want me to), but I find I am having trouble figuring out how to make sense to you.

    maybe just post the array and the LCD update part. Or get the LCD part number from your dad so I can look at the data sheet and understand how to talk to it. Or better yet, attach the datasheet here.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3
    Join Date
    Sep 2010
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by cncmachineguy View Post
    How do you send a space to the LCD? In fact, How do you send any character to the LCD? keep in mind, I don't think the number 3 is the same as "3". The number 3 is an interger, and "3" is a string. I assume the string is really converted to its UNICODE equal. So I THINK (i am not sure) these would be 2 different arrays:
    Code:
    t(0)=1
    t(1)=3
    t(2)=9
    
    t(0)="1"
    t(1)="3"
    t(2)="9"
    the problem you are facing, is there is NO integer space. there are only numbers 0-infinety. BTW there is also no n. the target after 9. So it should be as big a problem as the space if you are using an array of intergers.

    If you use an array of strings, each element is only 1 charater big, the space is no problem. It sounds to me like you are trying to mix numbers and strings. That is a big NO-NO!

    If you can post some or all of your code, I may understand better. I have no inclination to write it for you (and I don't think you want me to), but I find I am having trouble figuring out how to make sense to you.

    maybe just post the array and the LCD update part. Or get the LCD part number from your dad so I can look at the data sheet and understand how to talk to it. Or better yet, attach the datasheet here.
    You are correct, the code used to fill the array (for testing purposes) is the following

    Code:
      FOR I = 0 TO 29
      RANDOM RAND
      B0 = RAND // 10 ' Gives me numbers 0-9 
      NOS[I] = B0
      NEXT
    And the LCD...

    Code:
     CMCON = 7
     DEFINE OSC 20                               '20MHZ XTAL
     DEFINE LCD_DREG PORTB                      'PORT B LOW 4 BITS
     DEFINE LCD_DBIT 0                          'DATA BITS 0-3
     DEFINE LCD_RSREG PORTA                     'RS REG PORTA
     DEFINE LCD_RSBIT 4                         'RS BIT 4 PORT A
     DEFINE LCD_LINES 4                         '4 LIN LCD SET
     DEFINE LCD_EREG PORTB                      'EREG (ENABLE)
     DEFINE LCD_EBIT 4                          'PORTB BIT 4
     DEFINE LCD_BITS 4                          'LCD IN 4 BIT MODE
     PAUSE 1000                                 'INITIALIZE LCD
    how can I generate a random number as a string? as that would as you say save me alot of problems... as far as the manual goes PBP has limited support for strings, is there a ToString equivalent for PBP?

    To write to the lcd I simply use LCDOUT found on the pbp manual but at the moment since the randomly generated numbers are int's i can only go 0-infinity as you say.

    I need a way to generate random numbers as string values since spaces gave a Unicode value of 3 again as you stated.

    As for shifting the values within the array I cannot find any functions specifically for this in the manual so I will just have to resort to using a for next loop to shift the values around.
    Last edited by UKIkarus; - 29th September 2010 at 21:31.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    how can I generate a random number as a string?
    Not what you want but you could use a LOOKUP table after the random number is generated.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Thanks Dave, Glad someone is watching "me". I am always worried I will misguide him, and no one will be watching.

    Anyway, Go back and look at post 7 I think. Now that you and I both understand you will be using strings, (I assumed this the whole time, my bad), it may make more sense to you. The first part shows the quickest way I know of to shift the array. And at the same time check for losing. in my example, only t(0)-t(4) are displayed. t(5) is the you lose check.

    The second part shows 1 way to check for a hit, then adjust the array.

    I agree with Dave, use a lookup to match a number with a string.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  6. #6
    Join Date
    Sep 2010
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Not what you want but you could use a LOOKUP table after the random number is generated.
    Ahhh good point, I didnt think of that! and I have them in another file =)

  7. #7
    Join Date
    Sep 2010
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    Hey guys, thanks for the support before...

    I was indeed heading down the wrong path with my approaches in the end I just put the Ascii equivilents of the numbers 0-9 and "n" into the array instead of trying to tell the LCD to display the Decimal values...

    MUCH EASIER

    Timing is a bit of a pain, since the main loop counts and GoSub's to other areas (this adds about half a second to the count sometimes) but I'm working on that.

    Guess my main problem is my habit of keep looking at "visual" syntax as a reference, since everything appears to run simultaniously... where as on this its loops in loops all the time hehe.


    EDIT: Now that I have that sorted, once the code is working and bugs ironed out I will rename the variables to something that makes sense to others reading it and upload the source with the hardware layout for those interested.

  8. #8
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    COOL!!!
    I am looking forward to seeing/playing it. could use a little fun!
    Dave
    Always wear safety glasses while programming.

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