Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ARRAY declaration in GOSUB routines.
#1
I have noticed the following.

OPTION _EXPLICIT
[main code]
CALL test
END

SUBROUTINE test
[variable declaration]
[arrays declaration]
[CODE in which arrays are not used]
GOSUB section 1
[CODE]
section 1:
'[variable declaration]
'[arrays declaration]
[CODE in which arrays are used]
RETURN
END SUB

So, OPTION _EXPLICIT requires the declaration. If not, it get error. However, for it, it's the same that:
[variable declaration]
[arrays declaration]
is put at the beginning of the main code of the subroutine, or at the beginning of the GOSUB routine. The important, for it, is that the declaration takes place before the use of varriable and arrays to be declared.

But I noticed that if I put [arrays declaration] in the main code of the subroutine and not at the beginning of the GOSUB routine, then I have an OUT OF RANGE error executing the program with the reference to the lines in which the arrays are used.

Why?

The GOSUB routines, regardless if they are used in the main code or in a suroutine, are not considered as a part, respectively, of the main code/subroutine?
Reply


Messages In This Thread
ARRAY declaration in GOSUB routines. - by bartok - 02-04-2024, 01:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  getting the number of dimensions in an array on the fly? madscijr 7 738 09-16-2025, 12:34 AM
Last Post: madscijr
  Quesiton on Dimensioning an Array Dimster 5 996 02-06-2024, 01:55 PM
Last Post: Dimster
  Array in an array NasaCow 78 15,589 04-12-2023, 10:53 AM
Last Post: TempodiBasic
  Can images be read from a file into an array? PhilOfPerth 11 2,525 02-17-2023, 03:31 AM
Last Post: TerryRitchie
  Swapping array elements PhilOfPerth 24 3,911 11-19-2022, 12:16 AM
Last Post: Pete

Forum Jump:


Users browsing this thread: 1 Guest(s)