Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
define argument types in subs
#41
hmm... *goes and makes a test program*

Nope, it defitely doesnt work.

It highlights the period and says "Parameter type mismatch"

this is the test I used:
Code:
DECLARE SUB blah (i!, a!)
TYPE bler
  z AS INTEGER
END TYPE
DIM array(10) AS bler

blah i, array(x).z

SUB blah (i, a)
print "hello"
END SUB
Reply
#42
Quote:hmm... *goes and makes a test program*

Nope, it defitely doesnt work.

It highlights the period and says "Parameter type mismatch"

this is the test I used:
Code:
DECLARE SUB blah (i!, a!)
TYPE bler
  z AS INTEGER
END TYPE
DIM array(10) AS bler

blah i, array(x).z

SUB blah (i, a)
print "hello"
END SUB

Of course it does not work. You are declaring your parameters as SINGLE and you are attempting to pass INTEGER parameters.

Change the code to:

Code:
DECLARE SUB blah (i%, a%)
TYPE bler
  z AS INTEGER
END TYPE
DIM array(10) AS bler

blah i%, array(x%).z

SUB blah (i%, a%)
print "hello"
END SUB
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#43
...

duh!! I cant believe I didnt see that! Even the error was telling me what was wrong! yeesh. I am too tired to realise these things... sorry nath.
Reply
#44
Dark you can pass a whole array as well:

Code:
TYPE mytype
   ab  as integer
   cd   as string * 10
END TYPE

SUB mysub(foo() as mytype, n%)
   for i% =  1 to n%
      print foo(i%).ab
      print foo(i%).cd
   next
END SUB

DIM myarr(1 to 20) as mytype

FOR m% = 1 to 20
   myarr(m%).ab = m% + 5
   myarr(m%).cd = CHR$(m% + 5)
NEXT

mysub(myarr(), 20)

Havent tested it but it should work =).
Reply
#45
Cool, i see how. ok, thanks.
Reply
#46
Did my example work? I've to still test it =P.
Reply
#47
Quote:I don't comment my code, and I don't think I code sloppy (anymore)... Big Grin I only use comments where I'm approaching a difficult task and need it broken down into steps. I delete the comments afterwards. Tongue

Why do you do that? If I may ask?

:???:
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#48
Isnt it obvious? He doesnt want anyone to understand what he has written =P.
Reply
#49
Well , he can just didtribute w/o the source. :*)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#50
no, he will distribut the source.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)