IonicWind Software

IWBasic => General Questions => Topic started by: Steve on November 25, 2009, 03:41:56 AM

Title: Array parameters must be in form 'array[] as int'
Post by: Steve on November 25, 2009, 03:41:56 AM
Coming to grips with the basics.   I like the reverse way of defining variables as I'm comfortable with that way from C++/Java way of doing things (not that I'm a C++ expert).    So early on I've decided that will be my style or way of handling that aspect.   Even passing parameters to functions I could write a sub as "function(int x, int y)".   Then came a gotcha, I couldn't write it that way for arrays and kept getting a heap of compiler error messages along the lines of an undeclared function.

Sub FunctionName(int array[]) wouldn't work but Sub FunctionName(array[] as int) does work.   

I'm wondering if this is a bug or some valid reason why it can't be implemented in the reverse way?   



Title: Re: Array parameters must be in form 'array[] as int'
Post by: LarryMc on November 25, 2009, 12:49:01 PM
The subject has been touched on several times in the forums as well as in the help file.

In the forums search using passing and arrays

Larry
Title: Re: Array parameters must be in form 'array[] as int'
Post by: Steve on November 26, 2009, 03:56:12 AM
Quote from: Larry McCaughn on November 25, 2009, 12:49:01 PM
The subject has been touched on several times in the forums as well as in the help file.

In the forums search using passing and arrays

Larry

Unfortunately searching on passing and arrays did not lead to any clues or suggestions re - my original question.   From the help manual (User Guide - Language/Variables) it clearly explains the two ways of defining variables.   Taking that further, defining the parameters for subroutines also works either way, except for arrays.   Granted in the User Guide (Language/Subroutines) the examples cited all refer to defining parameters this way,
SUB MySecondSub( num as INT)I'm merely seeking some clarification.


Title: Re: Array parameters must be in form 'array[] as int'
Post by: Doc on November 27, 2009, 08:45:00 PM
Just in case you overlooked it, here ya go pardner:

http://www.ionicwind.com/forums/index.php/topic,1329.msg12517/topicseen.html#msg12517


QuoteYou have to tell it the size of the array.

SUB PrintVector( Title AS STRING, B[5,5] AS DOUBLE )

Paul.

HTH,
-Doc-
Title: Re: Array parameters must be in form 'array[] as int'
Post by: Steve on November 27, 2009, 09:14:49 PM
Quote from: Doc on November 27, 2009, 08:45:00 PM
Just in case you overlooked it, here ya go pardner:

http://www.ionicwind.com/forums/index.php/topic,1329.msg12517/topicseen.html#msg12517


QuoteYou have to tell it the size of the array.

SUB PrintVector( Title AS STRING, B[5,5] AS DOUBLE )

Paul.

HTH,

-Doc-

Thanks Doc and yes I did peruse that post, even before my original post.   Unfortunately, that doesn't address the issue I raised.   The referred post is referring to the issue that the indices must be included if multi-dimensioned arrays are passed.   I'm merely wanting to know why can't an array parameter to a subroutine be written in this form SUB SomeFunction(int MyArray[]).   If written in that form at compilation an error is returned, along the lines of an undeclared function.   When changing the header of the subroutine definition to SUB SomeFunction(MyArray[] as int) it works.   To me it seems a little inconsistent since it's possible to define non-array variables either way.
Title: Re: Array parameters must be in form 'array[] as int'
Post by: Ionic Wind Support Team on November 27, 2009, 09:31:16 PM
Steve,
It is the way the syntax is currently designed, get over it.

I added the prefix way of defining variables as an addition, because many asked for it as Aurora supported it and Emergence didn't.  Before the addition you had to define variables using the postfix methods:

def i as int

The fact that you can specify parameters as "int i" was a side effect of that addition, not an intention.  A useful side affect yes, but it wasn't the original intention.  And no, I can't force the parser to accept a prefix array parameter currently without doing a major redesign. So it is what it is.

Regards,
Paul Turley
Creator of Emergence BASIC
Title: Re: Array parameters must be in form 'array[] as int'
Post by: Steve on November 27, 2009, 09:53:16 PM
Quote from: Paul Turley on November 27, 2009, 09:31:16 PM
Steve,
It is the way the syntax is currently designed, get over it.

I added the prefix way of defining variables as an addition, because many asked for it as Aurora supported it and Emergence didn't.  Before the addition you had to define variables using the postfix methods:

def i as int

The fact that you can specify parameters as "int i" was a side effect of that addition, not an intention.  A useful side affect yes, but it wasn't the original intention.  And no, I can't force the parser to accept a prefix array parameter currently without doing a major redesign. So it is what it is.

Regards,
Paul Turley
Creator of Emergence BASIC

Thanks Paul, that clearly answers my question.   I can live with that, it's just knowing that that's the way it is.
Title: Re: Array parameters must be in form 'array[] as int'
Post by: Steve on November 28, 2009, 04:30:06 AM
Now off-topic but I've just noticed I've got negative karma.   I'm wondering if it was anything I said (or typed).   
Title: Re: Array parameters must be in form 'array[] as int'
Post by: Copex on November 28, 2009, 05:17:36 AM
Quote from: Steve on November 28, 2009, 04:30:06 AM
Now off-topic but I've just noticed I've got negative karma.   I'm wondering if it was anything I said (or typed).   

No... I would not worrie about kamea people dont use it correctly, reading the thread paul answered your question, before that people where trying to be helpfull, the problem with any fourm is the way other people read what you have writen and the the way they interpert it...... so you probbly got neg k for banging on about the same question

++ from me .....

Note to any one going to waist 5 minuts of the life rplying to the above dont bother......
Title: Re: Array parameters must be in form 'array[] as int'
Post by: mrainey on November 28, 2009, 06:24:42 AM
QuoteI've just noticed I've got negative karma

Clicking on "smite" is a poor substitute for making a reasoned, critical comment.  I wouldn't pay any attention to it.
Title: Re: Array parameters must be in form 'array[] as int'
Post by: REDEBOLT on November 28, 2009, 03:11:19 PM
Steve,

I applaud you for being a nice guy.

:D
Title: Re: Array parameters must be in form 'array[] as int'
Post by: Steve on November 28, 2009, 04:27:34 PM
Thanks everyone.......