Help bad parameter

Just starting out? Need help? Post your questions and find answers here.
Thorn
New User
New User
Posts: 6
Joined: Sun Oct 23, 2005 9:35 am
Location: Italy (Tuscany)

Help bad parameter

Post by Thorn »

Hi! I'm PureBasic's newbie

I'm writing an easy example for calculate the age, but i have an error when try to compiling.

"Line 10:bad parameter type: a string is expected"

Code: Select all

OpenConsole()

Print("Your birth date: ")
birthday.s= Input()

age.w=Val("Right(Date() ,4)") - Val("Right(birthday.s ,4)")

Print("This year you have: ")
Print (age.w)
Print("years.")

End
CloseConsole()
Straker
Enthusiast
Enthusiast
Posts: 701
Joined: Wed Apr 13, 2005 10:45 pm
Location: Idaho, USA

Post by Straker »

Try

Print(Str(age.w))
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

Print can only display Strings
Use STR to convert a value to String

Code: Select all

Print (Str(age.w)) 
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Thorn, you have many many problems with this code. I rewrote it so it actually works, now compare mine with yours:

Code: Select all

OpenConsole() 

Print("Your birth date: ") 
birthday.s= Input() 

age.l=Val(Right(Str(Year(Date())) ,4)) - Val(Right(birthday.s ,4)) 

Print(" This year you have: ") 
Print (Str(age)) 
Print(" years.") 
Input()

CloseConsole() 
End
BERESHEIT
Thorn
New User
New User
Posts: 6
Joined: Sun Oct 23, 2005 9:35 am
Location: Italy (Tuscany)

Post by Thorn »

Thanks folks!
Once i used Qbasic language, now i'm trying to convert Qb examples in to PureBasic code, and i have some problems.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

gotta' promote myself a little :-) did you check the survival guide?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

This code reminds me of a scene from "Support your local Sheriff" where James Garner looks at a Sheriff's badge with a huge dent in it and says,

"It sure looks to have saved the life of whoever was wearing it!",

and Harry Morgan's reply was,

"Well it sure would've if it weren't for all them other bullets coming in from everywhere."

Welcome to the forum, Thorn and best of luck with your new language. I know you'll come to love it!
BERESHEIT
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

netmaestro wrote:This code reminds me of a scene from "Support your local Sheriff" where James Garner looks at a Sheriff's badge with a huge dent in it and says,

"It sure looks to have saved the life of whoever was wearing it!",

and Harry Morgan's reply was,

"Well it sure would've if it weren't for all them other bullets coming in from everywhere."

Welcome to the forum, Thorn and best of luck with your new language. I know you'll come to love it!
Wonderfully appropriate quote from a very funny movie.
Post Reply