I know I am a dumb newbie

BlitzMax Forums/BlitzMax Beginners Area/I know I am a dumb newbie

rod54(Posted 2005) [#1]
Why doesnt this work
a = 5
b = 10

print "a + b = " a + b


Muttley(Posted 2005) [#2]
Try:

a=5
b=10

print "a + b = "+(a+b)


+ in a print statement doesn't do maths, just adds stuff to the output.

HTH

Muttley


HappyCat(Posted 2005) [#3]
You need to pass a string to the Print statement. You concatinate (build up) strings with the + operator, so:

Print "a + b = " + a + b

would print

a + b = 510 - because it's concatinating the value of a to the string, then concatinating the value of b to the string.

To add the numbers together before concatinating the result to the string just put the calculation in brackets:

Print "a + b = " + (a + b)

Brackets basically mean, do this first, so this would add the number together and then concatinate the result to the string, printing:

a + b = 15

Does any of that make sense?


rod54(Posted 2005) [#4]
Yes, I know from that post it makes me look totally stupid
but I actually do know a little about programming.

I am a fairly good PERL programmer.

Also used to '.' being used as a concatentation operator

Thanks,


HappyCat(Posted 2005) [#5]
Sorry, I didn't mean "does it make sense to your tiny brain" - was meant more like "does my rambling gibberish actually resemble english?"

And "." as a concatonator(?) ... eek! Being a .Net person that would screw me right up :-)


rod54(Posted 2005) [#6]
Thanks and yes as my age grows my mind goes.

PERl uses the '.' operator for concatention and it makes actually pretty good sense.


HappyCat(Posted 2005) [#7]
I think it's just that I already get confused between .Net's use of '.' as a property seperator (can't think of the proper term, but it's the equivalent of Blitz's '\') and Blitz's use of '.'

Another one would probably send me over the edge completely :-)


Damien Sturdy(Posted 2005) [#8]
Somethnig that screwed my brain last night was when i learned you could do

<stuff>.ADD Name:="moo"


in VB.. I find it cool now, but man, yesterday? eeeek!!!!


HappyCat(Posted 2005) [#9]
POP!




... picks remains of head from floor ...



Is that for adding an element called "Name" with a value of "moo" to a collection? Never seen it before - VB6 or .Net?


Damien Sturdy(Posted 2005) [#10]
6 I beleive. Just used it in Excel97 when generating my DB systems menus. I think it just sets properties. still new to me ;)


Punksmurf(Posted 2005) [#11]
it might come in handy when you have a function, method, sub or anything like, say:

function foobar(foo, bar)
'dostuff
endfunction

you then may use

foobar(something, something_else)

but you can also use the varable names the function uses to assing a value to them:

foobar(foo:=something, bar:=something_else)

this actually sounds really stupid and just adds typing but anyway you are not bound to use the proper order of the variables:

foobar(bar:=something_else, foo:=something)

would actually do the samething where

foobar(something_else, something)

would not :)

if I remember well I used this already in vb5. it's handy if you've got function which expect a load of variables and you only want to use a few. Also handy if you change the order of the variables later on, you don't have to go over all your code to change everything (alltough I find it really good practice).


Damien Sturdy(Posted 2005) [#12]
True. My little excell app is complete now. It automatically finds duplicates in a sheet, colouring in and hiding them so you dont spend an extra 5 mins per duplicate on there... i saved the company weeks of work ^.^ *big headedness* :D

This actually saved me a lot of time coding because i used it instead of "with <object>" statements :/