Page 1 of 1
UDP.WRITE with String and Variable
Posted: Sat Oct 14, 2023 8:14 pm
by Helmut_number_one
I want split the UDP String
Code: [Local Link Removed for Guests]
udp.write "192.168.0.44", 20057, "OSV17=1" ' this is ok
with a Variable i
Code: [Local Link Removed for Guests]
for i=17 to 22
udp.write "192.168.0.44", 20057, "OSV",i,"=1" ' i try this
NEXT i
but it isn't run ( Syntax error by udp.write)
Can a user explane the syntax?
Best regards
Re: UDP.WRITE with String and Variable
Posted: Sat Oct 14, 2023 8:50 pm
by Electroguard
Don't mix string variables and numeric variables in the same instruction, convert numbers to string and append them, eg:
a$= "number="
n=99
wlog a$ + " " + str$(n)
Then you can extract later using val()
Re: UDP.WRITE with String and Variable
Posted: Sat Oct 14, 2023 9:08 pm
by Helmut_number_one
Thankyou, very helpfull !!
Edit
I found in the help-file this example by
onUDP Event:
Code: [Local Link Removed for Guests]
udp.begin 5001 'set the UDP commmunication using port 5001
onudp goudp
'Write several messages to the port
for i = 0 to 100
udp.write "192.168.1.44", 5001, "Hello " + str$(i)
next i
wait
goudp:
v$ = udp.read$ 'receive the UDP data
print v$
return
the i write this cmd and it run
Code: [Local Link Removed for Guests]
udp.write "192.168.0.44", 20057, "OSV" + str$(i) +"=1"