Page 1 of 1

Plural procedure for text

Posted: Thu Mar 16, 2006 12:04 pm
by PB
Code updated For 5.20+

I needed this for describing the number of items with the correct plural, as
I was tired of always testing if the item count was 1 or not, and I also hate
how apps say 1 item(s) with the (s) part for only 1 item. :roll:

Code: Select all

; Plural by PB.

Procedure.s Plural(num,text$)
  a$=Str(num)+" "+text$ : If num<>1 : a$+"s" : EndIf
  ProcedureReturn a$
EndProcedure

a=Random(2) : b=Random(2) : Debug "I ate "+Plural(a,"apple")+" and "+Plural(b,"banana")+"."
f=Random(2) : Debug "You have "+Plural(f,"file")+" selected."

Posted: Thu Mar 16, 2006 1:42 pm
by Num3
Eheheh doesn't work in portuguese ;)

But it's a linguistic problem, not a code problem!

LOL

Posted: Thu Mar 16, 2006 2:04 pm
by Fred
Also in french, you will have to do a bunch of exceptions ;).

Posted: Thu Mar 16, 2006 3:23 pm
by Nik
Hmm you should fix this Fred, I will give you 8 hours then I will hav to write a classtest on it and I hate that french is not like pb^^

Posted: Thu Mar 16, 2006 3:29 pm
by Num3
Hey, don't feel bad, once you get it working in French, Portuguese is easy!

Our grammar is alike!