PDA

View Full Version : Iffy if-ness


Spudhead
10-07-2002, 05:07 PM
God, this is sooo humiliating. I can't even get an "if" statement to work. I may as well admit that I like to be called "Brenda". Or something.

Anyway, this gets a little tricky cos I'm using a third-party component (PDFlib, if anyone knows it) to generate PDFs on the fly. But I'm just doing some debugging and found that it's not returning true on an "if" statement, and I've no idea why.

So - some code:

strTest="spot not set"

Do While Not rs.EOF

colorSpot=Cstr(rs.Fields("color_spot").value)

If colorSpot<>"null" Then
colorSpace="spot"
mySpotColor=oPDF.makespotcolor(colorSpot)
oPDF.setcolor colorType, colorSpace, mySpotColor, 0.9, 0, 0
strTest="spot set"
End If

oPDF.show_boxed colorSpot, fieldX, fieldY, fieldWidth, fieldHeight, "justify", ""

strTest="spot not set"
rs.MoveNext
Loop


I should add that you're only getting a snippet of code there, but the rest works fine. It's just that "if" statement.

Basically, I grab the spot color name; parse it as a string. If that string doesn't equal "null", set my little debugging string to "spot set".

The "oPDF.show_boxed" writes output to the PDF page - ordinarily I'd have a text field from the database in there. In the example above, I'm putting the debug output - the spot color. This variable is definitely getting set; I write colorSpot back to the page and it's not "null". But if I change the debug output so it writes the value of strTest, it ALWAYS writes "spot not set".

So what's that "if" statement doing?

allida77
10-07-2002, 06:41 PM
Are you looking for the string "null" or trying to see if it is just null?

If <> "null"

is different than

If <> null

If you already knew that than instead of comparing to a null try

If Len(colorSpot) > 0 Then

Did any of this help?
Who is Brenda?

whammy
10-07-2002, 09:47 PM
Or you can use

If IsNull(colorSpot) = False Then

JackFruit3D
10-07-2002, 09:59 PM
Or you can use

If not colorSpot = nul Then

or

If not colorSpot = "nul" Then

or

If isEmpty(colorSpot) Then

i'd prolly bet on the first or last one as the middle option checks for a text string i think... but don't quote me...


hope that helps

whammy
10-08-2002, 04:48 AM
<%
myString = ""
Response.Write(Len(myString) & "<br />" & vbCrLf)
Response.Write(IsNull(myString) & "<br />" & vbCrLf)
Response.Write(IsEmpty(myString) & "<br />" & vbCrLf)

myNewString = Null
Response.Write(Len(myNewString) & "<br />" & vbCrLf)
Response.Write(IsNull(myNewString) & "<br />" & vbCrLf)
Response.Write(IsEmpty(myNewString) & "<br />" & vbCrLf)
%>