PDA

View Full Version : How to concatenate a HEX BCD value with a string as a new string?



jellis00
- 3rd December 2011, 17:58
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

jellis00
- 3rd December 2011, 18:23
After more thought, will this do what I want to do??


ARRAYWRITE file1,[HEX2 hr,"hour.txt"]

I hope that this would result in the file1 array containing the string 12hour.txt when hr = $12 ??

HenrikOlsson
- 3rd December 2011, 18:39
It should, try it. Just make sure file1 is declared big enough to hold the string.

jellis00
- 3rd December 2011, 22:48
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?


SEROUT2 TX,84,["AT+iFSTO:000,",STR filename\10,$d,$a]