HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Strings != ""

05-21-2009, 10:22 PM#1
Toadcop
aka strings ALLWAYS should be null and not "". and never do comparisions like this
Collapse JASS:
if str!="" then
endif

cause after map is saved and loaded (game save) this comparision will fail. and only null will succeed. i mean
Collapse JASS:
if str!=null then
endif

maybe it's obvious. but i bet someone have such checks ;P (including me well i had.)
It may lead to malfunctions or even to game crash (if operationg with gamecache or ExecuteFunc or similar).


and other "news" are what on bnet (now after the update) all maps with code returns will be unable to be hosted.
Collapse JASS:
function xxx takes nothing returns code
    return null
endfunction
// as example
will cripple the map. but in most cases no one need code ^_^ but it's just for info.
05-21-2009, 10:31 PM#2
Silvenon
Well, doesn't everybody do both?

Collapse JASS:
if str!="" and str!=null then
endif

At least I do. Except for crashes when using gamecache or ExecuteFunc (etc.) there are no problems with that then, right?
05-22-2009, 01:59 AM#3
MaD[Lion]
why use both when u can use null
05-22-2009, 04:42 AM#4
grim001
Quote:
Originally Posted by Toadcop
and other "news" are what on bnet (now after the update) all maps with code returns will be unable to be hosted.

If this is true, maybe jasshelper should give a compile warning about it, at least in debug mode.
05-22-2009, 05:49 AM#5
Ammorth
Does null still work if you pass "" as a string argument? At one point I didn't think it would (and that "" and null are two different values).
05-22-2009, 10:15 AM#6
Toadcop
Quote:
At least I do. Except for crashes when using gamecache or ExecuteFunc (etc.) there are no problems with that then, right?
Quote:
It may lead to malfunctions
aka depends on your algorithms...

Quote:
Does null still work if you pass "" as a string argument? At one point I didn't think it would (and that "" and null are two different values).
yes they are different. BUT no function (afaik) does return "" until you write one or something =)

Quote:
If this is true, maybe jasshelper should give a compile warning about it, at least in debug mode.
yes maybe. i don't have bnet. so if someone could check it ? (my friend told me what it fail well and i belive him...)
05-22-2009, 02:30 PM#7
Vexorian
Quote:
Originally Posted by Silvenon
Well, doesn't everybody do both?

Collapse JASS:
if str!="" and str!=null then
endif

At least I do. Except for crashes when using gamecache or ExecuteFunc (etc.) there are no problems with that then, right?
I do.

Alternatively (StringLength(s) > 0)

Actually I think this was known ever since the first Jass vault's times. Hence the reason I always compared with both "" and null.
05-22-2009, 02:31 PM#8
Vexorian
Quote:
and other "news" are what on bnet (now after the update) all maps with code returns will be unable to be hosted.
I wonder if this is related with some odd optimizer bug reports I've been getting.