DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Subscript out of range in numeric array

Started by Gymbo, January 24, 2020, 10:12:08 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Gymbo

Hi,

One of my grand kids has asked me to make larger "star puzzles", see "SavesAs acts like Save", below. I've made 8, 9, 11, and 13 point star puzzles without a hitch. Now for the mother of all star puzzles I'm attempting to make a 15 point star puzzle.

The puzzles are easy to make, draw the star in DesignCAD (v23 - 2D), modify the VB program to produce random numbers, and the macro that puts the numbers in the star. This is the macro routine simplified:
dim num(40)
INCLUDE "dcadalias.d3i"
Precision 0
open "I", 1, "N:\Star Puzzles\star15.txt"
for i = 1 to 46
input #1, num(i)
next
close 1
'
'routine to place numbers
'
'then change the letter to the number
a$ = num(i)
i = i + 1
Here:
Change T_Text, a$
update

This is the problem. When 'i' gets to 42 I get a subscript out of range error at "a$ = num(i)". This macro has worked for all the previous puzzles without a hitch. I've attached the drawing and macro.
Regards,

Jim

Gymbo

After further investigation the macro works as it should until i = 41, instead of reading num(i) (which is 52) it sets a$ = i (which is 41), then
it attempts to read num(52) which is out of range, bizarre! I've attached star15.txt.
Regards,

Jim

Gymbo

Regards,

Jim