Author |
Topic: How to calculate length of array? (Read 447 times) |
|
Endymion
New Member
member is offline

Write spaghetti-code for food!

Gender: 
Posts: 7
|
 |
How to calculate length of array?
« Thread started on: May 21st, 2012, 1:42pm » |
|
Sometimes I need to pass arrays by value, not by reference. So, I want to create tool for cloning arrays. My code not work:
Code: def proc_CloneArray(Array#(), return ArrayClone#())
local ArrayLength% = len(Array#()) *| just idea illustration
dim ArrayClone#(ArrayLength%)
ArrayClone#() = Array#()
endproc
|
« Last Edit: May 21st, 2012, 1:44pm by Endymion » |
Logged
|
I wanted to do something. I wanted to do something as badly as a genie who's been let out of his bottle for the first time in a thousand years. Anything at all: Raise up castles, lay waste cities, program in Basic, or embroider in cross-stitch. -- Nochnoy Dozor (The Night Watch) By Sergei Lukyanenko
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: How to calculate length of array?
« Reply #1 on: May 22nd, 2012, 08:04am » |
|
on May 21st, 2012, 1:42pm, Endymion wrote:Sometimes I need to pass arrays by value, not by reference. So, I want to create tool for cloning arrays. |
|
This code works:
Code: DEF PROC_CloneArray(Array#(), RETURN ArrayClone#())
LOCAL ArrayLength%
ArrayLength% = DIM(Array#(),1)
DIM ArrayClone#(ArrayLength%)
ArrayClone#() = Array#()
ENDPROC Can I recommend that you don't use the *| style of commenting routinely, since that sort of comment is preserved in a compiled EXE and wastes space:
http://bb4w.wikispaces.com/Alternative+comment+styles
Richard.
|
|
Logged
|
|
|
|
Endymion
New Member
member is offline

Write spaghetti-code for food!

Gender: 
Posts: 7
|
 |
Re: How to calculate length of array?
« Reply #2 on: May 22nd, 2012, 08:51am » |
|
on May 22nd, 2012, 08:04am, Richard Russell wrote:
Thanks!
Quote:Can I recommend that you don't use the *| style of commenting routinely, since that sort of comment is preserved in a compiled EXE and wastes space: |
|
OK.
|
|
Logged
|
I wanted to do something. I wanted to do something as badly as a genie who's been let out of his bottle for the first time in a thousand years. Anything at all: Raise up castles, lay waste cities, program in Basic, or embroider in cross-stitch. -- Nochnoy Dozor (The Night Watch) By Sergei Lukyanenko
|
|
|
|