How to concatenate a HEX BCD value with a string as a new string?


+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default How to concatenate a HEX BCD value with a string as a new string?

    I have a byte sized variable named 'hr' that stores the HEX BCD value of the current hour from reading the time from a real-time-clock.
    I want to concatenate this BCD value with the string "hour" and then concatenate the result with the string ".txt".
    For example, if hr = the BCD value $12 for 12 o-clock, I want to concatenate the HEX2 conversion of hr (which is the value 12) with a string named "hour" so that the results will be a new string = "12hour". Then I intend on concatenating the string "12hour" with the string ".txt" to build a file name for a text file that the code will use to identify a website based file name to which an FTP of data will be directed.

    I thought I might be able to use ARRAYWRITE to do this somewhow, but I can't figure it out.

    Can anyone give me some ideas as to how to do this. I am not well versed on string operations while using PBP.
    John
    Last edited by jellis00; - 3rd December 2011 at 18:03.

  2. #2
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default Re: How to concatenate a HEX BCD value with a string as a new string?

    After more thought, will this do what I want to do??
    Code:
    ARRAYWRITE file1,[HEX2 hr,"hour.txt"]
    I hope that this would result in the file1 array containing the string 12hour.txt when hr = $12 ??

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,329

    Default Re: How to concatenate a HEX BCD value with a string as a new string?

    It should, try it. Just make sure file1 is declared big enough to hold the string.

  4. #4
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default Re: How to concatenate a HEX BCD value with a string as a new string?

    Quote Originally Posted by HenrikOlsson View Post
    It should, try it. Just make sure file1 is declared big enough to hold the string.
    Thanks, Henrik...it looks like it worked. The way I tested it was to write the file1 array elements to EEPROM so I could see each letter after the program ran and whether the result from the ARRAYWRITE statement did what I wanted. It did.
    Now I have a follow on problem that maybe you can advise me on.
    I had to build this text file name so I could use it in a SEROUT2 command over a serial interface to a ConnectOne iWiFi MiniSocket module that is connected to my microcontroller PIC 16F886. The iWiFi module requires AT+i statements to send it FTP commands in a specific format. I think that this command should open the filename "15hour.txt" via this FTP command, however so far I haven't been able to see the FTP'd data show up in the file named by the filename . Any suggestions?
    Code:
    SEROUT2 TX,84,["AT+iFSTO:000,",STR filename\10,$d,$a]

Tags for this Thread

Posting Permissions

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