BBC BASIC for Windows
« How to calculate length of array? »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:57pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: How to calculate length of array?  (Read 447 times)
Endymion
New Member
Image


member is offline

Avatar

Write spaghetti-code for food!


PM

Gender: Male
Posts: 7
xx 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 » User IP 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
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx 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.
User IP Logged

Endymion
New Member
Image


member is offline

Avatar

Write spaghetti-code for food!


PM

Gender: Male
Posts: 7
xx Re: How to calculate length of array?
« Reply #2 on: May 22nd, 2012, 08:51am »

on May 22nd, 2012, 08:04am, Richard Russell wrote:
This code works:


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.
User IP 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
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls