In what case would a variable that displays as nothing still cause the statements (!v), (v == null), and (v == "") to be false? This variable was created with, essentially, var/v = copytext(msg,x,y) where msg is a regular old text string and both x and y turn out to be the same number. Or something like that. It's driving me nuts because I can't seem to screen it out afterwards by checking to see if it's null. And I could just check x and y before doing the copytext(), but I still want to know why all my checks with v are coming out false.
Z
ID:150095
Dec 13 2001, 5:18 pm
|
|
Zilal wrote:
In what case would a variable that displays as nothing still cause the statements (!v), (v == null), and (v == "") to be false? This variable was created with, essentially, var/v = copytext(msg,x,y) where msg is a regular old text string and both x and y turn out to be the same number. Or something like that. It's driving me nuts because I can't seem to screen it out afterwards by checking to see if it's null. And I could just check x and y before doing the copytext(), but I still want to know why all my checks with v are coming out false. Is it possible that v==" " or else v contains an HTML tag that doesn't display? The way I'd debug this would be something like: if(v) world << "v=\"[v]\" (length=[length(v)])" Lummox JR |
In response to Lummox JR
|
|
Lummox JR wrote:
Is it possible that v==" " or else v contains an HTML tag that doesn't display? The way I'd debug this would be something like: if(v) world << "v=\"[v]\" (length=[length(v)])" That had come to mind... I took your length debugging advice, and the length of v showed up as 0. The mystery survives... Z |
In response to Tom
|
|
Tom wrote:
Zilal wrote: No! Here's, like, what I did: if (v==null) usr << "V is nothing!" Upon running it, I found that v prints out as nothing, and has no length, so I changed the check to "if (v=="")", which had the same result, so I changed the check to "if (v==0)", which had the same result. It's like, somehow, v is a type of nothing other than null, "" and 0. Z |
In response to Zilal
|
|
Zilal wrote:
No! Here's, like, what I did: Can you get us a snippet? It's possible that I'm misunderstanding the situation in my late-night stupor, but it sure sounds like a bug to me. |
In response to Tom
|
|
Tom wrote:
Can you get us a snippet? It's possible that I'm misunderstanding the situation in my late-night stupor, but it sure sounds like a bug to me. mob verb test(msg as text) msg = Listall(msg) for (var/v in msg) usr << "'[v]', length = [length(v)]" proc Listall(options) var/list/outlist = new /list var/colonplace var/searchat = 1 do colonplace = findtext(options,":",searchat,lentext(options)+1) if (!colonplace || colonplace == 1) //only one choice to vote on... silly people! outlist += options return outlist outlist += copytext(options,searchat,colonplace) searchat = colonplace+1 if (searchat >= lentext(options)+1) return outlist while (findtext(options,":",searchat,lentext(options)+1)) for (var/v in outlist) if (!v) outlist -= v //supposed to remove null members return outlist Type in "test a:b:c::" to test. Z |
In response to Zilal
|
|
The problem is that your proc is returning before it reaches the part where you filter out the null entries. Might I suggest an alternative?
proc |
In response to Tom
|
|
Tom wrote:
The problem is that your proc is returning before it reaches the part where you filter out the null entries. I have no explanation for why I didn't think of that myself. Might I suggest an alternative? > proc I will in fact be able to take out the extra code I had in there to deal with situations in which text containing no colons was submitted... this whole thing is because one of the variables you have to submit in BYONDPoll had to not end in a colon, but people would forget and end it in a colon, so I'm trying to make it so you can do either... What does an argumentless for() statement do? Z |
!v is equivalent to: (v==null || v=="" || v==0)
The check (v==null && v=="") should never be true, since null and "" are two distinct values.
Does that answer the question?