CONST PI = 3.141592654#

TYPE m3dPoint
x AS DOUBLE
y AS DOUBLE
z AS DOUBLE
END TYPE

TYPE m3dLine
one AS INTEGER
two AS INTEGER
END TYPE

DIM j AS INTEGER

INPUT "a's start, stop, step ", d, e, f
INPUT "b's start, stop, step ", g, h, i
INPUT "radias", r
j = ((e - d + f) / f + 1) * ((h - g + i) / i)
lineCountess = ((e - d + f) / f) * ((h - g + i) / i)
PRINT j
DIM Points(1 TO j) AS m3dPoint
DIM Lines(1 TO lineCountess) AS m3dLine
c = 1
LineCount% = 1
FOR A = d TO e STEP f
 last = 0
 FOR B = g TO h STEP i
  Points(c).x = COS(A * PI / 180) * COS(B * PI / 180) * r
  Points(c).y = SIN(A * PI / 180) * r
  Points(c).z = COS(A * PI / 180) * SIN(B * PI / 180) * r
  IF last = 0 THEN
   last = c
  ELSE
   Lines(LineCount%).one = last
   Lines(LineCount%).two = c
   last = c
   LineCount% = LineCount% + 1
  END IF
  PRINT "roufly " + STR$(INT((c / j) * 100)) + "% of part 1 is done", c; j, A; B
  c = c + 1
 NEXT B
NEXT A
c = c - 1
PRINT LineCount%, lineCountess
PRINT "roufly " + STR$(INT((c / j) * 100)) + "% done", c, j

        INPUT "Enter File Name:", FileName$
        OPEN FileName$ FOR OUTPUT AS 1
        PRINT #1, c
        FOR i = 1 TO c
                PRINT #1, Points(i).x, Points(i).y, Points(i).z
                PRINT STR$(INT((i / (c)) * 100)) + "% done", i, c
        NEXT i
        PRINT #1, LineCount%
'        PRINT #1, 0
        FOR i = 1 TO LineCount%
                PRINT #1, Lines(i).one, Lines(i).two
        NEXT i
'        PRINT #1, SquareCount%
        PRINT #1, 0
'        FOR i = 1 TO SquareCount%
'                s = Squares(i)
'                PRINT #1, s.p1, s.p2, s.p3, s.p4, s.colour
'        NEXT i
        CLOSE 1

