General area when it fits no where else

Moderator: Mmiscool

User avatar
By robert badiduwitz
#59548 I found somewhere on this forum a way to scan the available networks, but I think it was written before V3 was available. I went over it as much as I could to try and convert it to work using V3.65 but for the life of me can't seem to get the dropdown list to work properly. I added a serialprint to see what the list should have in it, and it seems like good data, but I can't seem to get them to list in the dropdown. Can you take a look and recommend where I am not getting it? Thanks in advance!!!!

Code: Select allmemclear
cls

button "Set Wifi Settings", [WifiSettings]
button "End Program", [endprog]
wprint "<br> <br>"
wait

[WifiSettings]
listWifis$ = ""
n = wifi.scan()
n = n - 1
wprint "Number of network found = "
wprint n

for x = 1 to n
listWifis$ = listWifis$ & wifi.ssid(x)
listWifis$ = listWifis$ & ","
next x
serialprint listWifis$


wprint "<br>Select SSID: "
dropdown listWifis$, selectedWifi
wprint "<br>Password: "
passwordbox networkPW
wprint "<br>"
button "Connect To Wifi", [connectWifi]
wprint "<br> <br>"
wprint "Standalone Access Point (AP) without connecting to your wifi use this! <br> <br> Enter AP Name: "
textbox networkSSID
wprint "<br>Enter AP Password: "
passwordbox networkPWap
wprint "<br>"
button "Start AP", [StartAP]
wprint "<br>"
wait

[StartAP]
WiFioff
bla = wifi.ap(networkSSID,networkPWap)
wait

[connectWifi]
WiFioff
bla2 = wifi.connect(selectedWifi,networkPW)
wait

[endprog]
end
User avatar
By Edi
#59553 I didn't try out your code, but at a first glance, this looks like a bug for me:

Code: Select allfor x = 1 to n
listWifis$ = listWifis$ & wifi.ssid(x)
listWifis$ = listWifis$ & ","
next x


The problem is in Line 3.
The result of the growing string would contain the sign "," at the end.
The "," should separate the items between. But you have also such a character at the end, not followed by an item.
User avatar
By robert badiduwitz
#59557 Working now. Added code to get rid of last comma and also had the list and variable reversed in the dropdown command. Here is new working code...

Thanks for the help Edi!


Code: Select allmemclear
cls

button "Set Wifi Settings", [WifiSettings]
button "End Program", [endprog]
wprint "<br> <br>"
wait

[WifiSettings]
listWifis = ""
n = wifi.scan()
n = n - 1
wprint "Number of network found = "
wprint n

for x = 1 to n
listWifis = listWifis & wifi.ssid(x)
listWifis = listWifis & ","
next x
testn = len(listWifis)
testn = testn - 1
listWifis = left(listWifis,testn)
serialprint listWifis


wprint "<br>Select SSID: "
dropdown selectedWifi,listWifis
wprint "<br>Password: "
passwordbox networkPW
wprint "<br>"
button "Connect To Wifi", [connectWifi]
wprint "<br> <br>"
wprint "Standalone Access Point (AP) without connecting to your wifi use this! <br> <br> Enter AP Name: "
textbox networkSSID
wprint "<br>Enter AP Password: "
passwordbox networkPWap
wprint "<br>"
button "Start AP", [StartAP]
wprint "<br>"
wait

[StartAP]
WiFioff
bla = wifi.ap(networkSSID,networkPWap)
wait

[connectWifi]
WiFioff
bla2 = wifi.connect(selectedWifi,networkPW)
wait

[endprog]
end