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

    Quote Originally Posted by cncmachineguy View Post
    That's great! Will you be sharing? Just curious cuz I like this application. As someone who played this when it was new, it just seems cool to have.

    Are you willing to share your LCD hookup? And your actual part number for it? I would like to play with LCD's, but never seem to find time to hunt one down. No worries if you don't want to, you ARE NOT obligated to in any way.

    I have had fun helping with this, you are required to share a pic or video though.
    Of course!

    I will be happy to share any information with you regarding the board and my dad can provide you with the part numbers and all.

    I have just gone back over the notes for this program before I began writing it and I have noticed that the array is made up of "Bytes" meaning I cannot enter a space or " " since it sees it as a string or char and converts it to the decimal value any ideas?

    I suppose I could just get the decimal value and check to see if the vallue in the array is equal to that value and just override it for the lcd printing a space, it is just awquard to do it that way and means more code hehe
    Last edited by UKIkarus; - 29th September 2010 at 12:40.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by UKIkarus View Post
    I have just gone back over the notes for this program before I began writing it and I have noticed that the array is made up of "Bytes" meaning I cannot enter a space or " " since it sees it as a string or char and converts it to the decimal value any ideas?
    Always keep this in mind, everything is made up of bytes, strings and things are just converted for our convinence to read. So you are correct, the " " IS repersented by some number, that is the number to check against.

    But I would have thought using PBP, you could have a statement like t(2)=" ". that should be no different then t(3)="3".Of course this is different then T(3)=3 with no quotes. Am I wrong? good chance of that, but either way assuming I am not wrong, will work just fine.t(2)=" " means PBP will convert " " to some byte. then your check would be IF T(2) = " ". the key here may be in the quotes.
    -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

    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.

  4. #4
    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!

  5. #5
    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.

  6. #6
    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.

  7. #7
    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!

  8. #8
    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 =)

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