replace a variable and DAT sections
Tumbler
Posts: 323
Hello
I want to replace a byte, word or long value into a dat section.
example:
is there a way to do this in a simple way?
I want to replace a byte, word or long value into a dat section.
example:
DAT temp_in byte "Inside temp : ---",0 temp_out byte "Outside temp: ---",0 VAR byte in byte out PUB Main in := 22 out := 16 ' replace --- in temp_in with variable in ' and --- in temp_out with variable out
is there a way to do this in a simple way?

Comments
You may want to take a look at JonnyMac's "jm-strings" object. There are a lot of very handy string and conversion routines in there. Binary number to ascii numeric string like you need here is only one of them.
pub put_dec3(value, p_str) '' Insert 3-column decimal value into string at p_str '' -- suppresses leading zeros if (value => 100) byte[p_str][0] := value / 100 + "0" else byte[p_str][0] := " " if (value => 10) byte[p_str][1] := (value // 100) / 10 + "0" else byte[p_str][1] := " " byte[p_str][2] := value // 10 + "0"Thanks all
fdx.str(string("Inside Temp: ")) Fdx.dec(temp)Have testing Ariba, JonnyMac's (without a h) code: works perfect.
Thx Tracy for the link for the Peter's format object. (have to test this one)
cluso: the fullduplexserial object only accepts 16 bytes for the buffer. I need more (Gsm/cellphone modem needs 264 bytes)
At the moment i use the FullDuplexSerial4port object. But not testing for receive sms messages.
You would need a few more mods to make it larger.
i tried some objects, but all not working like i want. (incomplete or missing parts in data)
char *Short2Str(n) short n; { short tmp, tmp2, t; static char str[6]; tmp = 10000; for ( ; (n / tmp) ; tmp = tmp / 10); /* C standard tells us that the n/tmp will be integer math, and thus false if under 1. remove leading 0's. */ for(tmp2 = 0; tmp ; tmp = tmp / 10) /* convert integer to string representation. */ str[tmp2] = (n / tmp) + 0x30; str[tmp2+1] = 0; return str; }Convert to what ever language you use, easy as can be. I chose to give the example in C to assure understandability, I did not use any short hand operators to keep it readable.printf("Inside temp : %3.3d", in); printf("Outside temp: %3.3d", out);You can do a similar thing in Spin using the CLIB object.