May 01, 2024, 06:51:30 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Array parameters must be in form 'array[] as int'

Started by Steve, November 25, 2009, 03:41:56 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Steve

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?   



Steve
Melbourne, Australia.

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Steve

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.


Steve
Melbourne, Australia.

Doc

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-

Steve

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.
Steve
Melbourne, Australia.

Ionic Wind Support Team

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
Ionic Wind Support Team

Steve

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.
Steve
Melbourne, Australia.

Steve

Now off-topic but I've just noticed I've got negative karma.   I'm wondering if it was anything I said (or typed).   
Steve
Melbourne, Australia.

Copex

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......
-
I really should learn how to use a spell checker! though im not sure how it will help someone who can not spell?
-
Except where otherwise noted, content Posted By Copex is
licensed under a Creative Commons Attribution 3.0 License

http://creativecommons.org/licenses/by/3.0/

mrainey

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.
Software For Metalworking
http://closetolerancesoftware.com

REDEBOLT

Regards,
Bob

Steve

Steve
Melbourne, Australia.