Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Making Zero Count

Quote Reply
Making Zero Count
Hi:

I am working on a project that involves numbers, and, in this instance, Zero IS a legal number. That is, I want it to count (and show up!) Unfortunately, MySQL and/or Links thinks zero is nothing, and does not "count" it. What I mean is, see the following example of code from my tremplates:


<%if Issue%>
<B>Issue</B> # <%Issue%>
<%endif%>

This will print "Issue # XXX" for all numbers except zero. I am thinking that the "if Issue" statement does not return true for a zero.

Is there any work around anyone knows of?

TIA



dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Making Zero Count In reply to
Are you saying that you have something like 0013, and its being translated to just 13?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Making Zero Count In reply to
Andy:

No... just plain Jane "0"...

There are some Issue "0"'s involved, And I would like to see "Issue # 0"

BTW, I did try an <%if Issue eq 0%>0<%else%><%Issue%>, but that did not work, either...
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Making Zero Count In reply to
mmm... odd. Have you tried something like;

<%ifnot Issue%>0<%else%><%Issue%><%endif%>

?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Making Zero Count In reply to
Andy:

If it were ONLY that easy. There are also non-numbered ones... in which case I DO want nothing to show up!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Making Zero Count In reply to
The problem you are encountering is not a new one - well it is to a point. Ever since the numbering system was invented many thousands of years ago "0" or zero has represented a quantity, not a valid number per se.

'0' is the first in the counting chain, '0' to '9' is the first ten numbers, not '1' to '10' as is taught in schools.

There is the rather interesting oddity that in going in the negative direction '0' to '-9' is also valid - so we have a rather interesting duality of the '0' in the counting chain. The interesting fact about all that is that there is no such thing as '-0'.

The algorithm is I suspect not so difficult if the numbers you require are only in the positive direction. Like everything - what the machines crunch and what is displayed can be two different things. There is no real value in trying to do otherwise. Machines can resond to '0' as a number, they do it all the time. The problem is in the human minds limited capacity to understand all this.

My (ex) wife was a mathematical genius - mensa material. Thats how I came to know all this - I am not bright eough.
Quote Reply
Re: [Gypsypup] Making Zero Count In reply to
The problem as I see it is that I see a difference between Zero and Null. Zero- nothing, no quantity- is still something... NULL is nothing.
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Making Zero Count In reply to
Angelic Yes - and I guess that you want only number ranging, not quantity.

Last edited by:

Gypsypup: Feb 18, 2004, 11:22 AM
Quote Reply
Re: [Gypsypup] Making Zero Count In reply to
On the other hand though, you may want to use 1 and 0 as true/false conditions...i.e;

Code:
<%set Field = '0'%>
<%if Field%>shouldnt show, cos Field=0<%endif%>

Just my 2 cents :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Making Zero Count In reply to
Thats what I am trying to extract at the moment - it what is required is, eg, '0' to say, '9,999' or wahtever instead of '1' to '9,999'.
Quote Reply
Re: [carfac] Making Zero Count In reply to
You could try a global;

Code:
sub {
my $_in = int($_[0]) || "0";
return $_in;
}

...and call with:

<%global_name($Issue)%>

Untested, but i don't see why it shouldn't work :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!