Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Testing for TRUE

Status
Not open for further replies.

crabgrass

Technical User
Aug 29, 2007
111
US
The following code uses oServer to create an output file which returns a logical true if successful. The code executes and produces the file, the response.write prints True on the form but the if statement evaluates to false. I have tried about a dozen variations on this code but can't seem to get it right. Can someone help?

Thanks

Code:
'	-- Create the output file and create a link if successful  --
   if response.write(oServer.TryMERE(cReportName,cOutputFile,sql)) then
      response.write("<a href='\contactmanager\output\" & session("username") & ".pdf'>Export file generated. Click here to download.</a>")
   else
      response.write("File could not be processed.")
	  response.end
   end if
 
You don't want to test the output of the response.write do you? No. So... remove that and add = True. Strictly speaking, you don't need the = True part, but I prefer to have it there. Your choice, really.

Code:
'    -- Create the output file and create a link if successful  --
   if oServer.TryMERE(cReportName,cOutputFile,sql) [!]= True [/!] then
      response.write("<a href='\contactmanager\output\" & session("username") & ".pdf'>Export file generated. Click here to download.</a>")
   else
      response.write("File could not be processed.")
      response.end
   end if

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
You also might like to do it like this:
Code:
'    -- Create the output file and create a link if successful  --
   bFileOK = oServer.TryMERE(cReportName,cOutputFile,sql)

   if bFileOK then
      response.write "<a href='\contactmanager\output\" & session("username") & ".pdf'>" _
                   & "Export file generated. Click here to download." _
                   & "</a>"
   else
      response.write "File could not be processed."
      response.end
   end if

... really it is just style so whatever strikes your fancy unless you're working in an organization with strict standards for this sort of thing.
 
AAARGHH....

I had tried both of those without success BUT . . . now it works. I must have had something goofy with a typo.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top