02-12-2004, 08:34 PM
Is there a way to define the types of arg in a sub? For exemple, set them all to integer? DEFINT doesn't work here.
define a(integer1, integer2)
define a(integer1, integer2)
define argument types in subs
|
02-12-2004, 08:34 PM
Is there a way to define the types of arg in a sub? For exemple, set them all to integer? DEFINT doesn't work here.
define a(integer1, integer2)
02-12-2004, 08:36 PM
Here are the only two ways I know of:
SUB a (integer1 AS INTEGER, integer2 AS INTEGER) SUB a (integer1%, integer2%)
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
02-12-2004, 09:11 PM
This works for me. It outputs "5 7" instead of "5 6.54871" which proves beyond doubt that both the arguments are integers =).
Code: DEFINT A-Z
02-13-2004, 03:14 AM
The data types are assigned based on the symbol at the end of their names. Like in Aga's example, the % sign told QBasic that the variable was an integer.
For a list of the different kinds of variables and their symbols: http://qbasicnews.com/qboho/qckadvr.dtp.shtml
02-13-2004, 12:39 PM
I forgot to mention, you need to put DEFINT before the sub begins =P.
02-13-2004, 02:44 PM
When using in the QB IDE, QB might sneekily put a DEFSNG A-Z on top of your sub
So, add DEFINT A-Z when necessary. Or use % or AS INTEGER (I prefer the latter in the sub itself, but the % in the DECLARE, like this: Code: DECLARE SUB mysub (a%, b%, c!, d#, e$, f&)
02-13-2004, 02:46 PM
For me QB doesnt sneekily put a DEFSNG A-Z but a DEFINT A-Z.
I wonder why :o
02-13-2004, 02:48 PM
I think it's strange. Every QB45 version I've tried does it sometimes. :-?
02-13-2004, 02:50 PM
Its prolly a built in safeguard or something.
BTW What do you mean by every QB45 version? IMO QB45 is only one version .
02-13-2004, 02:53 PM
I tried The Geekery's QB45 archive, QBNZ's archive, HAR-SoftWare's archive, and more. That's what I mean with versions
|
« Next Oldest | Next Newest »
|