Re: Re: Sync Weather App - syncWXremixsearch query'."
By: KenDB3 to tbirdsradio on Fri Jan 01 2016 08:11 am
Re: Re: Sync Weather App - syncWXremix
By: tbirdsradio to KenDB3 on Thu Dec 31 2015 09:34 am
Once again i got ahead of myself. Dial up user phoned in and
received this error:
"Error in weather.js api.underground.com returned a
'querynotfound' error with this description. 'No cities match your
Do i have the above right?
That's all correct. I just didn't account for dial-up users. Mainly
because I don't have any dial-up access, it didn't really dawn on me.
Can anyone shed some light on how I might test for this scenario? I'm
guessing the user's IP comes up as undefined in this case?
Assuming the BBS is using SEXPOTS, the user's IP address should be the IP address of the BBS computer, or possibly 127.0.0.1 (I forget which). You can programatically detect a SEXPOTS/dial-up connection by checking if user.connection is a number (e.g. "28800") rather than a protocol string (e.g. "Telnet").
Something like this:
var dialup = (parseInt(user.connection) > 0);
At least, I think would work (without actually trying it). Let me know how it works for you,
var dialup = (parseInt(user.connection) > 0);
However, tbird is still seeing an error when the app is launched at Logon and also as a Door/External for his dial-up user.
Re: syncWXremix and Dial-up
By: KenDB3 to Digital Man on Wed Jan 06 2016 22:23:46
var dialup = (parseInt(user.connection) > 0);
However, tbird is still seeing an error when the app is launched at Logon and also as a Door/External for his dial-up user.
parseInt() is probably the wrong thing for this particular case, because it tries to pull a number out of a string that may contain non-digit characters.
parseInt('192.168.1.1'); // returns 192
parseInt('4162737230'); // returns 4162737230
Assuming that phone numbers will always be strings of digits, you could do:
if(user.connection.search(/[^\d]/) < 0) {
// Probably a phone number
} else {
// Probably not a phone number
}
Re: syncWXremix and Dial-up
By: KenDB3 to Digital Man on Wed Jan 06 2016 22:23:46
var dialup = (parseInt(user.connection) > 0);
However, tbird is still seeing an error when the app is launched at
Logon and also as a Door/External for his dial-up user.
parseInt() is probably the wrong thing for this particular case, because it tries to pull a number out of a string that may contain non-digit characters.
parseInt('192.168.1.1'); // returns 192
parseInt('4162737230'); // returns 4162737230
Assuming that phone numbers will always be strings of digits, you could do:
if(user.connection.search(/[^\d]/) < 0) {
// Probably a phone number
} else {
// Probably not a phone number
}
Re: Re: Sync Weather App - syncWXremix
By: KenDB3 to tbirdsradio on Fri Jan 01 2016 08:11 am
Re: Re: Sync Weather App - syncWXremix
By: tbirdsradio to KenDB3 on Thu Dec 31 2015 09:34 am
Once again i got ahead of myself. Dial up user phoned in and
received this error:
search query'.""Error in weather.js api.underground.com returned a
'querynotfound' error with this description. 'No cities match your
Do i have the above right?
That's all correct. I just didn't account for dial-up users. Mainly
because I don't have any dial-up access, it didn't really dawn on me.
Can anyone shed some light on how I might test for this scenario? I'm
guessing the user's IP comes up as undefined in this case?
Assuming the BBS is using SEXPOTS, the user's IP address should be the IP address of the BBS computer, or possibly 127.0.0.1 (I forget which). You can programatically detect a SEXPOTS/dial-up connection by checking if user.connection is a number (e.g. "28800") rather than a protocol string (e.g. "Telnet").
Something like this:
var dialup = (parseInt(user.connection) > 0);
At least, I think would work (without actually trying it). Let me know how it works for you,
DM, I was hoping you might be able to help point me in the right direction on this. tbirdsradio had a chance to try out the new version from GitHub that used
this bit of code (but had no luck):
var dialup = (parseInt(user.connection) > 0);
function getQuerySuffix() {
var qs;
if (dialup === 'true')
{
if (fallback_type == 'nonip') {
qs = fallback + '.json';
} else {
qs = 'autoip.json?geo_ip=' + resolve_ip(system.inet_addr);
}
} else if (user.ip_address.search( /(^127\.)|(^192\.168\.)|(^10\.)|(^172 \.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1] \.)|(^169\.254\.)|(^::1$)|(^[fF][cCdD])/
) > -1
) {
if (fallback_type == 'nonip') {
qs = fallback + '.json';
} else {
if (client.protocol === 'Telnet') {
qs = wstsGetIPAddress();
} else if (bbs.sys_status&SS_RLOGIN) {
qs = wsrsGetIPAddress();
}
if (typeof qs === 'undefined') qs = resolve_ip(system.inet_addr);
qs = 'autoip.json?geo_ip=' + qs;
}
} else {
qs = 'autoip.json?geo_ip=' + user.ip_address;
}
return qs;
}
var wungrndQuery = getQuerySuffix();
**********
However, tbird is still seeing an error when the app is launched at Logon and also as a Door/External for his dial-up user.
DEBUG for weather.js API call looked like this at the time of error: http:// api.wunderground.com/api/XXXXXXXXXXXXXXXX/conditions/forecast/astronomy/ alerts/q/autoip.json?geo_ip=812XXXXXXX
(Blocked out API and last 7 of phone number).
Any thoughts as to why I am missing catching this scenario? It's got me boggled
and I can't really see it.
Thanks for any help you can lend (and sorry for the long post).
Re: syncWXremix and Dial-upme.
By: KenDB3 to Digital Man on Wed Jan 06 2016 10:23 pm
Re: Re: Sync Weather App - syncWXremix
By: KenDB3 to tbirdsradio on Fri Jan 01 2016 08:11 am
Re: Re: Sync Weather App - syncWXremix
By: tbirdsradio to KenDB3 on Thu Dec 31 2015 09:34 am
Once again i got ahead of myself. Dial up user phoned in and
received this error:
search query'.""Error in weather.js api.underground.com returned a
'querynotfound' error with this description. 'No cities match
your
Do i have the above right?
That's all correct. I just didn't account for dial-up users. Mainly
because I don't have any dial-up access, it didn't really dawn on
y/ alerts/q/autoip.json?geo_ip=812XXXXXXXCan anyone shed some light on how I might test for this scenario?
I'm guessing the user's IP comes up as undefined in this case?
Assuming the BBS is using SEXPOTS, the user's IP address should be
the IP address of the BBS computer, or possibly 127.0.0.1 (I
forget which). You can programatically detect a SEXPOTS/dial-up
connection by checking if user.connection is a number (e.g.
"28800") rather than a protocol string (e.g. "Telnet").
Something like this:
var dialup = (parseInt(user.connection) > 0);
At least, I think would work (without actually trying it). Let me
know how it works for you,
DM, I was hoping you might be able to help point me in the right
direction on this. tbirdsradio had a chance to try out the new
version from GitHub that used
this bit of code (but had no luck):
var dialup = (parseInt(user.connection) > 0);
function getQuerySuffix() {
var qs;
if (dialup === 'true')
{
if (fallback_type == 'nonip') {
qs = fallback + '.json';
} else {
qs = 'autoip.json?geo_ip=' + resolve_ip(system.inet_addr);
}
} else if (user.ip_address.search(
/(^127\.)|(^192\.168\.)|(^10\.)|(^172
\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]
\.)|(^169\.254\.)|(^::1$)|(^[fF][cCdD])/ ) > -1
) {
if (fallback_type == 'nonip') {
qs = fallback + '.json';
} else {
if (client.protocol === 'Telnet') {
qs = wstsGetIPAddress();
} else if (bbs.sys_status&SS_RLOGIN) {
qs = wsrsGetIPAddress();
}
if (typeof qs === 'undefined') qs = resolve_ip(system.inet_addr);
qs = 'autoip.json?geo_ip=' + qs;
}
} else {
qs = 'autoip.json?geo_ip=' + user.ip_address;
}
return qs;
}
var wungrndQuery = getQuerySuffix();
**********
However, tbird is still seeing an error when the app is launched at
Logon and also as a Door/External for his dial-up user.
DEBUG for weather.js API call looked like this at the time of error:
http://
api.wunderground.com/api/XXXXXXXXXXXXXXXX/conditions/forecast/astronom
(Blocked out API and last 7 of phone number).
Any thoughts as to why I am missing catching this scenario? It's got
me boggled
and I can't really see it.
Thanks for any help you can lend (and sorry for the long post).
For a dial-up connection (via SEXPOTS), the user.ip_address property could either the caller-ID information (if provided by the modem) or the IP address of the SEXPOTS proxy (e.g. 127.0.0.1).
Is dialup not being set to true (in your code) for the dial-up connection?
Some more debug-level log output could help identify exactly what's happening here.
He's using parseInt() on the user.connection property, which should either be a terminal-protocol string (e.g. "Telnet", "Rlogin", "SSH") or a modem DCE (connect) rate (e.g. "28800"). There should not ever be an IP address or a phone number in the user.connection property.
Or maybe I missed this other use of parseInt()?
According to DM, user.connection should return a connection speed for a dialup user (e.g. "28800") rather than a protocol string (e.g. "Telnet"). So the > 0 made sense. I gave it some mock data, and it returned "true" if I fed it 28800, and "false" if I fed it the word Telnet.
I don't know SEXPOTS (or any dialup to telnet bridge) well enough to know if the Caller ID was going to come back with 10-digit (4162737230), 11-digit (14162737230), +1 format, or even the short 7-digit pattern. So,
I was avoiding testing the user.ip_address field even though the phone number was ending up there. I'm not sure if that behavior is predictable
across the board. If the sysop had dialup but not Caller ID from thier telco, what does SEXPOTS drop into the user.ip_address? Does it work in
var dialup = (parseInt(user.connection) > 0);
function getQuerySuffix() {
var qs;
if (dialup === 'true')
{
if (fallback_type == 'nonip') {
qs = fallback + '.json';
} else {
qs = 'autoip.json?geo_ip=' + resolve_ip(system.inet_addr);
}
} else if (user.ip_address.search(
/(^127\.)|(^192\.168\.)|(^10\.)|(^172
\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]
\.)|(^169\.254\.)|(^::1$)|(^[fF][cCdD])/ ) > -1
) {
if (fallback_type == 'nonip') {
qs = fallback + '.json';
} else {
if (client.protocol === 'Telnet') {
qs = wstsGetIPAddress();
} else if (bbs.sys_status&SS_RLOGIN) {
qs = wsrsGetIPAddress();
}
if (typeof qs === 'undefined') qs = resolve_ip(system.inet_addr);
qs = 'autoip.json?geo_ip=' + qs;
}
} else {
qs = 'autoip.json?geo_ip=' + user.ip_address;
}
return qs;
}
var wungrndQuery = getQuerySuffix();
**********
However, tbird is still seeing an error when the app is launched at
Logon and also as a Door/External for his dial-up user.
y/ alerts/q/autoip.json?geo_ip=812XXXXXXXDEBUG for weather.js API call looked like this at the time of error:
http://
api.wunderground.com/api/XXXXXXXXXXXXXXXX/conditions/forecast/astrono
m
(Blocked out API and last 7 of phone number).
Any thoughts as to why I am missing catching this scenario? It's got
me boggled
and I can't really see it.
Thanks for any help you can lend (and sorry for the long post).
For a dial-up connection (via SEXPOTS), the user.ip_address property
could either the caller-ID information (if provided by the modem) or
the IP address of the SEXPOTS proxy (e.g. 127.0.0.1).
Is dialup not being set to true (in your code) for the dial-up connection?
Some more debug-level log output could help identify exactly what's
happening here.
Good point, I don't know what's happening to "dialup" during this process. I do know that the phone number is being dropped into user.ip_address and that's where the query string is failing. I'm just not catching it. I'll add some DEBUG to grab "dialup" and I think user.connection as well.
var dialup = (parseInt(user.connection) > 0);
if (dialup === 'true')
...should be...
if (dialup === true)
Triple Equals works... At some point I tried Double Equals instead (stil works). Should I stick with Triple? I read up on the difference, but not sure if one might be better than the other in this particular case.
var dialup = (parseInt(user.connection) > 0);
if (dialup === 'true')
...should be...
if (dialup === true)
Triple Equals works... At some point I tried Double Equals instead
(stil works). Should I stick with Triple? I read up on the
difference, but not sure if one might be better than the other in
this particular case.
The difference between == and === can be pretty big in some situations. See here for a lot of info:
http://tinyurl.com/paz96fe
But ultimately you can just do this:
if (dialup) {
// If dialup is true, then this happens
} else {
// Otherwise this happens
}
I'd still recommend reading up on == vs. ===, because using both without knowing the difference would probably lead to much confusion.
I started using some mock data (since I don't have dialup to test with). I think I figured this out.
function getQuerySuffix() {
var qs;
if (dialup === 'true')
...should be...
function getQuerySuffix() {
var qs;
if (dialup === true)
This makes it through the function by grabbing the correct fallback lookup.
Triple Equals works... At some point I tried Double Equals instead (stil works). Should I stick with Triple? I read up on the difference, but not sure if one might be better than the other in this particular case.
I started using some mock data (since I don't have dialup to test
with). I think I figured this out.
function getQuerySuffix() {
var qs;
if (dialup === 'true')
...should be...
function getQuerySuffix() {
var qs;
if (dialup === true)
This makes it through the function by grabbing the correct fallback
lookup.
Triple Equals works... At some point I tried Double Equals instead
(stil works). Should I stick with Triple? I read up on the difference,
but not sure if one might be better than the other in this particular
case.
Isn't the "=== true" redundant? Saying "if (dialup)" should be enough, and it's just as clear as saying "if (dialup === true)", since that has the same meaning.
Isn't the "=== true" redundant? Saying "if (dialup)" should be enough, and it's just as clear as saying "if (dialup === true)", since that has the same meaning.
I started using some mock data (since I don't have dialup to test with). I think I figured this out.
function getQuerySuffix() {
var qs;
if (dialup === 'true')
...should be...
function getQuerySuffix() {
var qs;
if (dialup === true)
This makes it through the function by grabbing the correct fallback lookup.
Triple Equals works... At some point I tried Double Equals instead (stil works). Should I stick with Triple? I read up on the difference, but not sure if one might be better than the other in this particular case.
Isn't the "=== true" redundant? Saying "if (dialup)" should be enough, and it's just as clear as saying "if (dialup === true)", since that has the same meaning.
Isn't the "=== true" redundant? Saying "if (dialup)" should be
enough, and it's just as clear as saying "if (dialup === true)", since
that has the same meaning.
Usually, and in the case of this particular script, if(dialup) and if(dialup == true) and if(dialup === true) are all functionally equivalent.
However, technically if(dialup) is the equivalent of: if(dialup != false), because if dialup = 2, let's say, then if(dialup == true) or if(dialup === true) would not execute the if-block while if(dialup) would still execute the if-block. if(Boolean(dialup) == true) is the equivalent of if(dialup). :-)
This makes it through the function by grabbing the correct fallback lookup.
Triple Equals works... At some point I tried Double Equals instead (stil works). Should I stick with Triple? I read up on the difference, but not sure if one might be better than the other in this particular case.
Isn't the "=== true" redundant? Saying "if (dialup)" should be enough, and it's just as clear as saying "if (dialup === true)", since that has the same meaning.
Usually, and in the case of this particular script, if(dialup) and if(dialup == true) and if(dialup === true) are all functionally equivalent.
However, technically if(dialup) is the equivalent of: if(dialup != false), because if dialup = 2, let's say, then if(dialup == true) or if(dialup === true) would not execute the if-block while if(dialup) would still execute the if-block. if(Boolean(dialup) == true) is the equivalent of if(dialup). :-)
digital man
dialup = "Yes"
if (dialup)
print("Yessir!")
if (dialip===true)
print("Fosho!");
Would only print "Yessir!".
dialup = "Yes"
if (dialup)
print("Yessir!")
if (dialip===true)
print("Fosho!");
Would only print "Yessir!".
The following values evaluate as false in JS:
0, undefined, mull, NaN, false, empty string
Everything else is true.
The following values evaluate as false in JS:
0, undefined, mull, NaN, false, empty string
Everything else is true.
The following values evaluate as false in JS:
0, undefined, mull, NaN, false, empty string
Everything else is true.
Not when testing for equality (and that was the original question). For example: print(2==true), prints 'false'.
Sysop: | fluid |
---|---|
Location: | wickliffe, ohio |
Users: | 4 |
Nodes: | 10 (0 / 10) |
Uptime: | 140:18:46 |
Calls: | 50 |
Files: | 15,838 |
Messages: | 49,859 |