legality_export reports as a string, not an integer/number

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
phkb
Commodore
Commodore
Posts: 2434
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

legality_export reports as a string, not an integer/number

Post by phkb » Mon Sep 14, 2015 6:54 am

It appears the legality_export is being referred to as a string. I did a quick run through using this code:

Code: Select all

this.$myFunction = function () {
    var market = player.ship.dockedStation.market;
    for (prop in market) {
        log(this.name, "type " + Object.prototype.toString.call(market[prop].legality_export));
    }
}
and the result was

Code: Select all

type [object String]

User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2161
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: legality_export reports as a string, not an integer/numb

Post by Wildeblood » Mon Sep 14, 2015 10:55 am

This is the problem you've been trying to interest me in, that I've been studiously ignoring? You say because it's a string, not an integer, when used as a boolean "0" tests as true where 0 would test as false?

I ignored your PM the other day because I looked at that function of yours and didn't think it was testing what you think it is testing. OTOH, if your function there is right it implies I've forgotten even more than I thought I had, which is a lot.

So either way I'm not game to change the script in Undocumented Launch until someone spoon feeds me the exact fix necessary. :oops:

User avatar
phkb
Commodore
Commodore
Posts: 2434
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Re: legality_export reports as a string, not an integer/numb

Post by phkb » Mon Sep 14, 2015 11:39 am

I understand if you're not interested. You don't have to be! It just seems like a bug. It might not be (I'm not 100% sure), but if it is, I don't like bugs. Bugs must be squished. With extreme prejudice. (Take that, evil bug).

And yes, doing a boolean test of a string containing "0", "1" or "2" all returns true.

User avatar
Lone_Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 545
Joined: Wed Aug 08, 2007 10:59 pm
Location: Netherlands

Re: legality_export reports as a string, not an integer/numb

Post by Lone_Wolf » Mon Sep 14, 2015 12:04 pm

phkb,

try typeof market[prop].legality_export instead of Object.prototype.toString.call(market[prop].legality_export))
OS : Arch Linux 64-bit - rolling release

OXPs : My user page

I am subscribed to the threads for my oxps, if you need my attention just post in them or send a pm.

User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2161
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: legality_export reports as a string, not an integer/numb

Post by Wildeblood » Mon Sep 14, 2015 12:36 pm

Lone_Wolf wrote:phkb,

try typeof market[prop].legality_export
instead of Object.prototype.toString.call(market[prop].legality_export))
Yes, that's what I thought, too. But as I said, I'm too long out of it to be sure.

User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4018
Joined: Fri Nov 11, 2011 6:19 pm

Re: legality_export reports as a string, not an integer/numb

Post by cim » Mon Sep 14, 2015 4:31 pm

Where there's a very direct translation from plist to core structure to JS structure like that, everything is a string, and you should use parseInt or parseFloat if it needs to be read as a number.

User avatar
phkb
Commodore
Commodore
Posts: 2434
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Re: legality_export reports as a string, not an integer/numb

Post by phkb » Mon Sep 14, 2015 10:47 pm

cim wrote:Where there's a very direct translation from plist to core structure to JS structure like that, everything is a string
Ah! That explains it! Thanks, cim!

Post Reply