View previous topic :: View next topic |
Author |
Message |
Beke
Joined: 14 Feb 2008 Posts: 45
|
Posted: Mon Mar 31, 2008 8:25 pm Post subject: |
|
|
Hi,
the point of my code example was to show that Bascom treats the Chr(0) as an exception. It does not take into consideration when computing the length of a string, nor stops printing when arriving it. The output of the code is (in simulation):
ABCD
4
I don't know whether other language idioms implement the Chr(0) with strings and Print in another way. Maybe. An oscilloscope would show, whether the Chr(0) "comes out" or not. I guess it doesn't, for already the string is shorter than 5. |
|
Back to top |
|
|
Beke
Joined: 14 Feb 2008 Posts: 45
|
Posted: Mon Mar 31, 2008 8:30 pm Post subject: |
|
|
Hi,
the point of my code example was to show that Bascom treats the Chr(0) as an exception. It does not take into consideration when computing the length of a string, nor stops printing when arriving it. The output of the code is (in simulation):
ABCD
4
I don't know whether other language idioms implement the Chr(0) with strings and Print in another way. Maybe. An oscilloscope would show, whether the Chr(0) "comes out" or not. I guess it doesn't, for already the string is shorter than 5. |
|
Back to top |
|
|
Pixelfrank
Joined: 10 Dec 2005 Posts: 15 Location: Oranienburg
|
Posted: Tue Apr 01, 2008 10:17 am Post subject: |
|
|
Hi Beke,
i try your example in real.
The results are the same as in simulation.
The Null in the middle is not visible (ignored) on the Output.
Code: | Dim A As String * 5
A = Chr(65) + Chr(66) + Chr(67) + Chr(0) + Chr(68)
Print A
Print Len(a)
Wait 1
End
|
Important is the "wait" or "do : loop" just before the "end". Otherwise the CPU ending work also on the Uart and only "ABC" are seen on the output @ 9600 Baud.
Hi DToolan,
i found out, that the "Printbin" is usefull for my application.
I use it as follow:
Code: | Printbin 0 ; 0 ; 0 ; 0 ; 0 ; 1 ; 70 ; 70 ; 48 ; 48 ; 2; |
In this form it is a bit more "eyefriendly"
Thanks for your support!
Regards
Frank |
|
Back to top |
|
|
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Tue Apr 01, 2008 10:48 am Post subject: |
|
|
Hi,
in order to send/receive DATA (not Strings) it is useful NOT to mess around with strings, but with arrays. I have a ISM-Band transmission working with this code:
(only transmission-part is shown)
dim message(8) as byte
Sub Send_message
Message(1) = High(ident_nr) 'assign the message byte with data
Message(2) = Ident_nr
Message(3) = Adresse
Message(4) = Unit_status
Message(5) = G_sensor_alarm_cnt
Message(6) = Mk_lf_alarm_cnt
Message(7) = Tamper_alarm_cnt
Message(8) = Crc8(message(1) , 7) 'create checksum
Printbin &H0F 'Startbyte, triggers the receiver
For N = 1 To 8
Printbin Message(n) ; 1 'watch the "1": without it the hohle array is beeing send '
While Ucsra.txc = 0 : Wend 'wait until print is done
Ucsra.txc = 1
Waitms 1 'Pause for my receiver
Next N
End Sub
Itīs no problem to send data with the value "0". |
|
Back to top |
|
|
DToolan
Joined: 14 Aug 2004 Posts: 1384 Location: Dallas / Fort Worth, Texas (USA)
|
Posted: Tue Apr 01, 2008 11:15 am Post subject: |
|
|
Finally someone who understands the non-importance of strings! |
|
Back to top |
|
|
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Tue Apr 01, 2008 11:40 am Post subject: |
|
|
Hi D!
I just joined the Anti-String Coalition. After having done the first 10 steps in your cool programm, can I be graded an officer? Or do I really have to climb the last two steps? Maybe inreasing my (already high) donation can help....
_________________
Just say NO to Strings! Join the Anti-String Coalition and do the 12 step program.
Visit www.justsayno2strings.com today (donations accepted) |
|
Back to top |
|
|
|