Gossamer Forum
Home : Products : DBMan : Customization :

Skip blank fields

Quote Reply
Skip blank fields
Hi!

I know, it has been discussed many time before:
How do I skip blank fields in a record?
i have the following code:
<$font>$rec{'Author1'}; $rec{'Author2'}; $rec{'Author3'}; $rec{'Author4'} ($rec{'Year'}): </Font>
If only one author is recorded I don't want the blank
fields with the ';'s to show up on the screen?

Can anyone help me out with the necessary coding?
Thanks
lastdrop

Quote Reply
Re: Skip blank fields In reply to
<$font>$rec{'Author1'}
|;
if $rec{'Author2'} {
print qq|
; $rec{'Author2'}
|;
}
if $rec{'Author3'} {
print qq|
; $rec{'Author3'}
|;
}
if $rec{'Author4'} {
print qq|
; $rec{'Author4'}
|;
}
print qq|
($rec{'Year'}): </Font>


Quote Reply
Re: Skip blank fields In reply to
Thanks Karen,

but it's not working. I think the problem is that I have a ';' between the fields and in the script the ';' comes straight after the '|'.

Isn't it?
lastdrop

Quote Reply
Re: Skip blank fields In reply to
Yes Karens code is wrong......because you are using ; perl thinks you are ending the string so you will need to escape each ;

...like.....

\;


Try.....

if $rec{'Author2'} {
print qq|\; $rec{'Author2'}|;
}
if $rec{'Author3'} {
print qq|\; $rec{'Author3'}|;
}
if $rec{'Author4'} {
print qq|\; $rec{'Author4'}|;
}











Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: Skip blank fields In reply to
Sorry I hadn't caught that. Had even taken the extra effort to include the ; only if there was another author following instead of having it hang out there on its own. Crazy

Quote Reply
Re: [Karen] Skip blank fields In reply to
I had to add parentheses to get this to work. Like this:

Code:

if ($rec{'Author2'}) {
print qq|\; $rec{'Author2'}|;
}
if ($rec{'Author3'}) {
print qq|\; $rec{'Author3'}|;
}
if ($rec{'Author4'}) {
print qq|\; $rec{'Author4'}|;
}

Sigrid
Quote Reply
Re: [sigrid] Skip blank fields In reply to
Hehe the good old days. That post of mine was a year old when I knew nothing :)