Help with replacing part of a "string"
Hello all again! I am attempting to modify a DAT variable before it is sent to the server, but I can't seem to get the DATAHERE to replace with a number that is calculated.
I can replace the line in question with :
How can I replace the DATAHERE with a calculated number?
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
CR = $0D
LF = $0A
DAT
DataSeg1 byte "GET /tims/post.php?data=DATAHERE HTTP/1.1", CR, LF, {
} "Host: www.example.com", CR, LF, {
} "User-Agent: Wiz5100", CR, LF, CR, LF, $0
OBJ
str : "STRINGS2"
pst : "Parallax Serial Terminal"
VAR
byte str_test[255]
byte new_str[255]
byte value
PUB Main | strh
pst.Start(115_200)
pause(5000)
value := (12345 + 12345) / 2
strh := @DataSeg1
bytefill(@str_test, 0, 255)
bytemove(@str_test, strh, strsize(strh))
strh := str.StrReplace(@str_test, string("DATAHERE"), value) ' ******* Lost Here????
pst.str(strh)
PRI pause(Duration)
waitcnt(((clkfreq / 1_000 * Duration - 3932) #> 381) + cnt)
return
I can replace the line in question with :
strh := str.StrReplace(@str_test, string("DATAHERE"), string("12345"))
and it works exactly as needed.How can I replace the DATAHERE with a calculated number?

Comments
I have written a library that does what you need. It didn't get a lot of attention but you can find it here:
http://forums.parallax.com/showthread.php/148937-Concept-Test-General-Purpose-String-Output-Formatting
PUB integerToDecimal(number, length) '' 5 Stack Longs '' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// '' // Converts an integer number to the decimal string of that number padded with zeros. '' // '' // Returns a pointer to the converted string. '' // '' // Number - A 32 bit signed integer number to be converted to a string. '' // Length - The length of the converted string, "+" or "-" will be concatenated onto the head of converted string. '' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// length := (10 - ((length <# 10) #> 0)) decimalString := "+" if(number < 0) decimalString := "-" if(number == negx) bytemove(@decimalString, string("-2147483648KA"), 11) else repeat result from 10 to 1 decimalString[result] := ((||(number // 10)) + "0") number /= 10 decimalString[length] := decimalString return @decimalString[length]FDS+ also has a decimal to string function, although you'd have to modify it to write to a buffer instead of the tx() function.
PUB dec(value) | i, x '' Print a decimal number x := value == NEGX 'Check for max negative if value < 0 value := ||(value+x) 'If negative, make positive; adjust for max negative tx("-") 'and output sign i := 1_000_000_000 'Initialize divisor repeat 10 'Loop for 10 digits if value => i tx(value / i + "0" + x*(i == 1)) 'If non-zero digit, output digit; adjust for max negative value //= i 'and digit from value result~~ 'flag non-zero found elseif result or i == 1 tx("0") 'If zero digit (or only digit) output it i /= 10 'Update divisor-Phil