Gossamer Forum
Home : Products : DBMan : Customization :

a question of syntax

Quote Reply
a question of syntax
I guess maybe I should just break down and buy a Perl book, but I will ask here...all I have learned about Perl I have gotten from studying scripts like DBMan, Links and other scripts available on the net.
From what I see in DBMan, the way to change a page layout based on the user is with the

if ($per_admin){
}else{
}"

type statement. Can this also work with variables, like can "if ($db_uid = "default"){" be used to or is it like JavaScript "if ($db_uid == "default"){" or "if ($db_uid != "default"){".
On that same train of thought, can a field be skipped entirely if it is empty like this

if($rec{'blah'} != null){
print qq|<TR><TD>Blah</TD><TD>$rec{'blah'}</TD></TR>|;
}

any suggestions on syntax...I am coming from fluent JavaScript land, which seems very similar in ways...but not in other.

Thanks for any advice.
dB Masters

Quote Reply
Re: a question of syntax In reply to
First, I don't see why "if($db_uid eq "default")" should not work as a condition. As far as I know, though, when evaluating strings in perl, you should use "eq", and not "=", which is reserved for or restricted to numbers.
Second, if you want to skip empty fields and use autogenerate display, simply add the following code to the config file:
$db_skip_blank = 1;
If you don't use autogenerate display, the code you suggested works fine. Though, not being very versatile in perl, I don't know whether this is the most efficient way to code this.

Best,




kellner
Quote Reply
Re: a question of syntax In reply to
Please visit the FAQ noted below under both "syntax" and "Working with Fields" and you will find the answers to your questions.

Look under "Working with Fields" first Smile

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: a question of syntax In reply to
Whoa, quite the website ya got there...I just bookmarked it...Thanks a bunch, I am a Hypermart user myself:-)

Quote Reply
Re: a question of syntax In reply to
OK, I followed the directions for making an empty record not print at all, but now I get errors...here is the code i dropped in the html_record:

|;
if ($rec{'Ing3'}) { printqq| $rec{'Ing3'}<BR> |; }
if ($rec{'Ing4'}) { printqq| $rec{'Ing4'}<BR> |; }
if ($rec{'Ing5'}) { printqq| $rec{'Ing5'}<BR> |; }
if ($rec{'Ing6'}) { printqq| $rec{'Ing6'}<BR> |; }
if ($rec{'Ing7'}) { printqq| $rec{'Ing7'}<BR> |; }
if ($rec{'Ing8'}) { printqq| $rec{'Ing8'}<BR> |; }
if ($rec{'Ing9'}) { printqq| $rec{'Ing9'}<BR> |; }
if ($rec{'Ing10'}) { printqq| $rec{'Ing10'}<BR> |; }
if ($rec{'Ing11'}) { printqq| $rec{'Ing11'}<BR> |; }
if ($rec{'Ing12'}) { printqq| $rec{'Ing12'}<BR> |; }
if ($rec{'Ing13'}) { printqq| $rec{'Ing13'}<BR> |; }
if ($rec{'Ing14'}) { printqq| $rec{'Ing14'}<BR> |; }
if ($rec{'Ing15'}) { printqq| $rec{'Ing15'} |; }
print qq|

This is a recipe database for a non-profit MOMS Club thing I donated my time to, so if all 15 "ingredients" fields aren't used, I am trying to make it so a bunch of line breaks don't print.

It doesn't even tell me which line has the error like usual, it just says "Too many error on page."

Any advice?

Quote Reply
Re: a question of syntax In reply to
In Reply To:
OK, I followed the directions for making an empty record not print at all, but now I get errors...here is the code i dropped in the html_record:
|;
if ($rec{'Ing3'}) { printqq| $rec{'Ing3'}<BR> |; }
Your print statements should be like this:
print qq|something to print goes here|;

*Note the space between print and qq


easy does it
Quote Reply
Re: a question of syntax In reply to
Aargh...talk about the STUPID mistakes always being the problem....thanks for making me feel dumb :-)

Really tho...thanks for the help.

Quote Reply
Re: a question of syntax In reply to
In Reply To:
Aargh...talk about the STUPID mistakes always being the problem....thanks for making me feel dumb :-)
If you've seen some of the mistakes I've made, you wouldn't feel nearly as dumb. :)

In Reply To:
Really tho...thanks for the help.
You're welcome.


easy does it