Display Time From Serial In And Output Correctly

rjandsam

Member
Hi,
please could you help me with the following problem, I am trying to output time and date received in two separate variables into single variables and then sertxd out the result.
the following code works but I need it to show the zeros before time and date where needed, I am sure its something simple but I cant seem to figure it out but i am sure you guys can make me out to be the simple in this equation.

b18=b18-48*10+b19-48 let b19=0 'Hours
b20=b20-48*10+b21-48 let b21=0 'Mins
b22=b22-48*10+b23-48 let b23=0 'secs
b16=b16-48*10+b17-48 let b17=0 'Day
b14=b14-48*10+b15-48 let b15=0 'Month
b12=b12-48*10+b13-48 let b13=0 'Year
debug
sertxd ("The Time Is ",#b18,":",#b20,":",#b22," The Date Is ",#b16,"/",#b14,"/",#b12,cr)


Thank You
Rich
 

nick12ab

Senior Member
It looks like you are converting from ASCII in the first part of your code. If you are then send the individual ASCII variables (without using #) in the sertxd command without converting them into binary.

If this is not what you are doing, instead of preceding each variable with # in the sertxd command, use the bintoascii command before the sertxd command. The send the three output variables in the sertxd command without preceding the variable names by #. To reduce the number of variables required, use a separate sertxd command for each variable.
 

rjandsam

Member
Hi nick,
Thanks for the suggestions, I will try them out tomorrow and let you know how I get on.

Thanks again
Rich.
 
Top