Plural procedure for text
Posted: Thu Mar 16, 2006 12:04 pm
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:
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."