Just starting out? Need help? Post your questions and find answers here.
Thorn
New User
Posts: 6 Joined: Sun Oct 23, 2005 9:35 am
Location: Italy (Tuscany)
Post
by Thorn » Tue Oct 25, 2005 7:57 pm
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
Posts: 701 Joined: Wed Apr 13, 2005 10:45 pm
Location: Idaho, USA
Post
by Straker » Tue Oct 25, 2005 8:02 pm
Try
Print(Str(age.w))
Droopy
Enthusiast
Posts: 658 Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:
Post
by Droopy » Tue Oct 25, 2005 8:05 pm
Print can only display Strings
Use STR to convert a value to String
netmaestro
PureBasic Bullfrog
Posts: 8451 Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada
Post
by netmaestro » Tue Oct 25, 2005 8:11 pm
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
Posts: 6 Joined: Sun Oct 23, 2005 9:35 am
Location: Italy (Tuscany)
Post
by Thorn » Tue Oct 25, 2005 9:03 pm
Thanks folks!
Once i used Qbasic language, now i'm trying to convert Qb examples in to PureBasic code, and i have some problems.
blueznl
PureBasic Expert
Posts: 6166 Joined: Sat May 17, 2003 11:31 am
Contact:
Post
by blueznl » Tue Oct 25, 2005 9:33 pm
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 ... )
netmaestro
PureBasic Bullfrog
Posts: 8451 Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada
Post
by netmaestro » Tue Oct 25, 2005 9:39 pm
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
Posts: 2736 Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA
Post
by rsts » Wed Oct 26, 2005 12:21 am
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.