Help on WGET$ - solved

If doesn't fit into any other category ....
Post Reply
gerdF
Posts: 10
Joined: Sun Mar 28, 2021 10:33 am
Has thanked: 6 times

Help on WGET$ - solved

Post by gerdF »

Hello, I use Annex WiFi RDS 1.43
with esp8266 (D1 Mini Pro)
and have the following WGET$ problem:

This line works

Code: [Local Link Removed for Guests]

wlog WGET$("193.168.2.90/red.exe?answer=dom.GetObject('_temp').State('123')", 80)
wlog Message: User-Agent: Annex</httpUserAgent><answer>true</answer>

If i use a variable instead of static '123'

Code: [Local Link Removed for Guests]

a=123
wlog WGET$("193.168.2.90/red.exe?answer=dom.GetObject('_temp').State('a')", 80)
I get this wlog Message: User-Agent: Annex</httpUserAgent><answer>false]</answer>

Can someone help me there please?
Last edited by gerdF on Sun Apr 04, 2021 3:27 pm, edited 1 time in total.
User avatar
PeterN
Posts: 375
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 176 times
Been thanked: 212 times
Contact:

Re: Help on WGET$

Post by PeterN »

Hi GerdF

I think it will helpful to built the string for the wget by concatenating the different parts - one of them is your variable number 123.

Code: [Local Link Removed for Guests]

x = 123
a$ = |193.168.2.90/red.exe?answer=dom.GetObject('_temp').State('| + str$(x) + |')|
wlog a$
wlog wget$(a$,80)
Happy Easter
Peter
User avatar
PeterN
Posts: 375
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 176 times
Been thanked: 212 times
Contact:

Re: Help on WGET$

Post by PeterN »

PS: You took the IP-Address 193.168.2.90 by intention - not 192.168.2.90 ?
User avatar
Electroguard
Posts: 846
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 272 times
Been thanked: 320 times

Re: Help on WGET$

Post by Electroguard »

Code: [Local Link Removed for Guests]

myvar$ = wlog WGET$("193.168.2.90/red.exe?answer=dom.GetObject('_temp').State('a')", 80)
Everything withing the pairs of double-quotes is a string, eg:
tempvar$ = "193.168.2.90/red.exe?answer=dom.GetObject('_temp').State('a')"
So to insert a variable, you need to break the string at the insertion point and close the string, eg:
tempvar$ = "193.168.2.90/red.exe?answer=dom.GetObject('_temp').State('"
insert your variable as a string, eg:
tempvar$ = tempvar$ + str$(a)
then add back the remaining part of the original string '), eg:
tempvar$ = tempvar$ + "')"

That's generally how to insert variables into html strings etc.
gerdF
Posts: 10
Joined: Sun Mar 28, 2021 10:33 am
Has thanked: 6 times

Re: Help on WGET$ - solved

Post by gerdF »

Thank you at all, Problem solved.

first my copy&paste mistake
Var a is a$ and a$="123"

I found my error it was a string problem, not a WGET$ error
wlog WGET$("193.168.2.90/red.exe?answer=dom.GetObject('_temp').('"+a$+"')", 80)

But i'm also looking at the other suggestions, thank you.

Gerd
Post Reply