Gossamer Forum
Home : Products : DBMan : Customization :

What is wrong with eq?

Quote Reply
What is wrong with eq?
I have the following code, dying a horribly ugly death. Basically, it falls through to the else portion and assigns that value to $vehicle. But when I call $rec{'equipment'}, it shows the value I'm testing for. I've put print statements into the various loops, and it boils down to eq not working. Has anyone been confronted with this? I can't find any other way to test these values.

Code:
if ($rec{'equipment'} eq "F") { $vehicle = "Flatbed"; }
elsif ($rec{'equipment'} eq "R") { $vehicle = "Reefer"; }
elsif ($rec{'equipment'} eq "V") { $vehicle = "Van"; }
elsif ($rec{'equipment'} eq "F/R/V") { $vehicle = "Flatbed/Reefer/Van"; }
elsif ($rec{'equipment'} eq "R/V") { $vehicle = "Reefer/Van"; }
elsif ($rec{'equipment'} eq "F/V") { $vehicle = "Flatbed/Van"; }
elsif ($rec{'equipment'} eq "SD") { $vehicle = "Step Deck"; }
elsif ($rec{'equipment'} eq "DD") { $vehicle = "Double Deck"; }
elsif ($rec{'equipment'} eq "LB") { $vehicle = "Low Boy"; }
elsif ($rec{'equipment'} eq "HS") { $vehicle = "Hot Shot"; }
elsif ($rec{'equipment'} eq "AC") { $vehicle = "Auto Carrier"; }
elsif ($rec{'equipment'} eq "CV") { $vehicle = "Curtain Van"; }
elsif ($rec{'equipment'} eq "T") { $vehicle = "Tanker"; }
elsif ($rec{'equipment'} eq "DB") { $vehicle = "Dry Bulk"; }
elsif ($rec{'equipment'} eq "HB") { $vehicle = "Hopper Bottom"; }
elsif ($rec{'equipment'} eq "ALL") { $vehicle = "All Trucks"; }
else { $vehicle = "Truck Not Specified"; }
Quote Reply
Re: What is wrong with eq? In reply to
Where are you putting these codes?

Also, you might try using single quotes rather than double quotes, like the following:

Code:
if ($rec{'equipment'} eq 'F') { $vehicle = "Flatbed"; }

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------









Quote Reply
Re: What is wrong with eq? In reply to
I've tried the single quotes already. No luck there either. I've also tried replacing $rec{'equipment'} with $somevariable to see if it was causing problems but no luck there either. This bit of code is near the beginning of html_record. I'm using it to set up headings on my output. On a search for *, it should print out:

$vehicle
---all entries with that vehicle---
$vehicle
---all entries of the next vehicle---

What is weird is that it works fine if I don't specify a Type of Equipment. If you want to see it in action, login as admin/admin at http://support.wcc.net/cgi-bin/bigtruck/db.cgi. The database isn't up for public consumption, so feel free to play around. This one has me baffled.

Thanks,
KipT
Quote Reply
Re: What is wrong with eq? In reply to
I understand what you are trying to do...But thanks for the visual...

Quote:
replacing $rec{'equipment'} with
$somevariable

This will not work...you need to call the variable in the db_def hash into a record hash in the sub html_record routine.

You do want these values printed in the search results screen, right? And not in the add, modify, or delete screens, right?

Regards,



------------------
Eliot Lee
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------











Quote Reply
Re: What is wrong with eq? In reply to
Actually, it was
Code:
$somevar=$rec{'equipment'};
if ($somevar eq "F") { etc.

Yes, I want this on Search Results, but don't care if the same header comes up for any Result page. Those will only be one so it's no big deal. I ran the following tests yesterday:

Code:
$f = "F";
if ($f eq "F") failed

if ($f eq $f) passed

if ($f eq F) failed

if (F eq F) passed

if ('$rec{'equipment'}' eq 'F') failed

if ("$rec{'equipment'}" eq F) failed

$f = lc($rec{'equipment'};

if ($f eq "f") failed
etc. I couldn't come up with any other ways to test. But it seems like eq just works when it wants to. For some reason, it never actually tested the contents of any $var. I still can't figure out why it would work perfectly if I don't select a Type of Equipment to search for.

Baffled,

KipT