Gossamer Forum
Home : Products : DBMan : Installation :

A few short mods

Quote Reply
A few short mods
Hi,

I am trying to set different kinds of Short Mods. I am going to use the technique of JPDeni. This is what I have so far:
Code:
If ( $db_total_hits == 1 ) {
&html_record_long(&array_to_hash($_, @hits));}
elsif { $db_total_hits == med ) {
&html_record_list(&array_to_hash($_, @hits));}
else {
When I try to go to the database homepage it just doesn't want to work. By the way, on the bottom of html_view_success I have only 2 }, is this good or bad.

Please tell me what I am doing wrong.

------------------
JFrost





Quote Reply
Re: A few short mods In reply to
In the line

elsif { $db_total_hits == med ) {

what is "med"? If it's a variable that refers to a certain number, it must be prefaced with a $. So, if you want your html_record_list to be used when there are 10 records returned, define your variable as

$med = 10;

and then use it like

elsif ( $db_total_hits == $med ) {

(There was a little problem with using a curly bracket instead of a parenteses there, too. You must enclose the condition in parentheses--
Code:
if ( condition ) {
action
}
elsif ( condtion ) {
action
}

Sometimes it's hard to see the difference between them.

With regards to how many brackets you have, sometimes that's hard to see, too. The only way I'm able to keep them straight is to indent any lines that are within the brackets:

Code:
if ( condition ) {
action1;
action2;
action3;
if ( other condition ) {
action4;
}
else {
action5;
}
}
elsif (condition) {
another set of actions;
}

You also need to be aware that subroutines begin and end with the brackets, so to be even more sure of where you are, it's not a bad idea to set it up like

Code:
sub subroutine {
do this;
do that;
if ( condition ) {
action1;
}
elsif ( condition ) {
action2;
}
do some other things;
}

If you still seem to be having problems with the number of brackets and parentheses, count them. First count all the { brackets and then all the } brackets. If the numbers aren't the same, you have a problem.

It's "legal" to put your closing brackets on the same line as the action, but until you're really sure of what you're doing, I'd put them on a separate line.


------------------
JPD