Attribute VB_Name = "vbdraw"
Global cadarry$(200, 17)
Global hpan, vpan
Global hlandpos, vlandpos, chrx, chry
Global targetchrx, targetchry
Global score
Global grpause ' rem used to shut off the 3d grapphix engein
Global lastzet ' rem used as a place holder for the current graphic element being adressed in the cad databse
Global grkeyascii$ ' rem used for keyboard input on GR
Global target1sent
Global GRTARGET1BUTTON
Public Sub COLORBOX(frmn)

'r = Form2.text5
'G = Form2.text6
'B = Form2.text7

C = RGB(r, G, B)

H = GR.ScaleWidth  '
V = GR.ScaleHeight ' REM CENTER SHAPE


vbcad.Line (H, V)-(H - 800, V - 800), C, BF

H = cad.ScaleWidth  '
V = cad.ScaleHeight ' REM CENTER SHAPE


'Form13.Line (h, v)-(h - 800, v - 800), C, BF

'h = Form14.ScaleWidth  '
'v = Form14.ScaleHeight ' REM CENTER SHAPE


'Form14.Line (h, v)-(h - 800, v - 800), C, BF'

'h = Form15.ScaleWidth  '
'v = Form15.ScaleHeight ' REM CENTER SHAPE


'Form15.Line (h, v)-(h - 800, v - 800), C, BF

End Sub
Public Sub Cclear()


End Sub
Public Sub PRTEXT(TXT$, H, V, s, C, niv, frmn)
Frm = 1
If niv = 0 Then

If H < GR.ScaleWidth And V < GR.ScaleHeight And H > 0 And V > 0 Then
hh = H: vv = V
SZ = s
vvv = 0
hh = hh + SZ
For ct = 1 To Len(TXT$)
ch$ = Mid$(TXT$, ct, 1)
If ch$ = Chr$(32) Then
hh = hh + (SZ * 6)
End If

If ch$ = "1" Then
Call VBCH("R;R;U;U;U;U;U;U;F;R;D;D;D;D;D;R;R;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
If ch$ = "2" Then
Call VBCH(" U;E;R;E;U;H;L;F;B;D;D;D;D;V;R;R;R;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If

If ch$ = "3" Then
Call VBCH("R;R;E;U;H;L;L;R;R;E;U;H;L;L;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
If ch$ = "#" Then
hh = H
vvv = vvv + (SZ * 8)
End If
If ch$ = "A" Then
Call VBCH("U;U;U;U;U;E;R;G;D;D;L;L;L;R;R;R;D;D;D;D;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
If ch$ = "B" Then
Call VBCH("U;U;U;U;U;U;R;R;G;D;F;L;R;G;D;F;L;L;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
If ch$ = "C" Then
Call VBCH("R;R;R;R;L;L;L;L;U;U;U;U;U;U;R;R;R;R;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
If ch$ = "D" Then
Call VBCH("R;R;R;L;L;L;U;U;U;U;U;U;R;R;R;G;D;D;D;D;F;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
If ch$ = "E" Then
Call VBCH("R;R;R;R;L;L;L;L;U;U;U;R;R;R;L;L;L;U;U;U;R;R;R;R;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
If ch$ = "F" Then
Call VBCH("U;U;U;R;R;R;L;L;L;U;U;U;R;R;R;R;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
If ch$ = "G" Then
Call VBCH("R;R;R;U;U;L;L;R;R;D;D;L;L;L;U;U;U;U;U;E;R;G;D;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If

If ch$ = "H" Then
Call VBCH("U;U;U;U;U;U;D;D;D;R;R;R;U;U;U;D;D;D;D;D;D;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If

If ch$ = "I" Then
Call VBCH("R;R;R;L;U;U;U;U;U;U;L;R;R;R;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
If ch$ = "J" Then
Call VBCH("U;D;R;R;R;U;U;U;U;U;U;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
If ch$ = "K" Then
Call VBCH("U;U;U;U;U;U;D;D;DR;E;E;E;F;F;F;G;G;G;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
If ch$ = "L" Then
Call VBCH("R;R;R;R;L;L;L;L;U;U;U;U;U;U;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
If ch$ = "M" Then
Call VBCH("U;U;U;U;U;U;G;G;G;E;E;E;D;D;D;D;D;D;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
If ch$ = "N" Then
Call VBCH("U;U;U;U;U;U;G;G;G;U;U;U;D;D;D;D;D;D;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If

If ch$ = "O" Then
Call VBCH("U;U;U;U;U;U;R;R;R;R;D;D;D;D;D;D;L;L;L;L;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
If ch$ = "P" Then
Call VBCH("U;U;U;U;U;U;R;R;R;R;D;D;D;D;L;L;L;L;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If

If ch$ = "Q" Then
Call VBCH("U;U;U;U;U;U;R;R;R;R;D;D;D;D;D;D;H;G;G;H;L;L;L;L;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
If ch$ = "R" Then
Call VBCH("U;U;U;U;U;U;R;R;R;G;D;F;L;L;R;R;G;D;D;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If

If ch$ = "S" Then
Call VBCH("R;R;R;E;U;H;L;H;U;E;R;R;R;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If

If ch$ = "T" Then
hh = hh + (SZ * 2)
Call VBCH("U;U;U;U;U;U;R;R;L;L;L;L;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 4)
End If
If ch$ = "U" Then
Call VBCH("U;U;U;U;U;U;D;D;D;D;D;D;R;R;R;R;U;U;U;U;U;U;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
If ch$ = "V" Then
vv = vv - (SZ * 6)
Call VBCH("D;D;D;G;G;G;E;E;E;U;U;U;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
If ch$ = "W" Then
vv = vv - (SZ * 6)
Call VBCH("D;D;D;D;G;G;E;E;U;D;G;G;E;E;U;U;U;U;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 12)
End If
If ch$ = "X" Then
vv = vv - (SZ * 6)
Call VBCH("G;G;G;G;G;G;H;H;H;E;E;E;F;F;F;F;F;F;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If


If ch$ = "Y" Then
vv = vv - (SZ * 6)
Call VBCH("G;G;G;E;E;E;F;F;F;D;D;D;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If

If ch$ = "Z" Then
vv = vv - (SZ * 6)
Call VBCH("R;R;R;R;R;R;F;F;F;F;F;F;R;R;R;R;R;R;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 6)
End If
vv = V + vvv
Next ct
End If
End If
End Sub



Public Sub grdraw(AG, QA, TA, DTA$, H, V, BB, frmn, scal)
'If Right$(DTA$, 1) = ";" Then
'Debug.Print "RECIVED "; DTA$
 'Debug.Print " ### "; ag; ","; qa; ","; ta; ","
' NIV STANDS FOR NOT IN VEIW USED TO CUT DOWN ON WASTED CPU TIME
' AND TO REDUCE SCREEN ERROR

'pagex = Form3.Text1
'pagey = Form3.Text2
'xx = Form2.Text14
'yy = Form2.Text13

VR = QA
CANGLE = TA
N = 0
bl = 0
niv = 0
SIZE = scal
SA = 0
SA = SA * 3.142857 / 180
If B = 1 Then C = 0
 ANGLE = CANGLE * 3.142857 / 180
 'EA = EA * 3.142857 / 180
  AI = 1
  AI = AI * 3.142857 / 180
  cl = 1
  If B = 1 Then cl = &H0
Select Case frmn
Case 1

'Call getvar("GRDRAWH", retval$): h = Val(retval$)
'Call getvar("GRDRAWV", retval$): v = Val(retval$) ' REM SET SHAPE'S X,Y
HLIM = GR.ScaleWidth
VLIM = GR.ScaleHeight
Case 2

H = cad.ScaleWidth / 2 '
V = cad.ScaleHeight / 2 ' REM CENTER SHAPE
HLIM = cad.ScaleWidth
VLIM = cad.ScaleHeight
End Select


x = H
y = V
Rem BUILD DATA
ll = Len(DTA$)

Rem START OF MAIN LOOP
For ct = 1 To (ll)

ch$ = Mid$(DTA$, ct, 1)
 ch$ = UCase$(ch$)
 If ch$ = "C" And BB = 0 Then
  'Debug.Print "C ";
  Call GETVL(DTA$, ct, SZ)
  'Debug.Print "< "; SZ; " >"
  C = SZ
End If

 chh$ = ""
 BUCK = 0
 If ct + 2 < (ll) Then
 C1$ = Mid$(DTA$, ct, 1)
  If C1$ = "V" Or C1$ = "^" Then
      ch$ = ""
      chh$ = Mid$(DTA$, ct, 2)
      chh$ = UCase$(chh$)
     Call GETVL(DTA$, ct + 1, SZ)
     ct = ct + 2
     BUCK = 1
  End If
 End If ' END CHECK FOR <V> <^>

 If ct + 3 < (ll) Then
  CFS$ = Mid$(DTA$, ct, 3)
  End If
 
 If ct + 4 < (ll) Then
  Cfcal$ = Mid$(DTA$, ct, 4)
   Cfcal$ = UCase$(Cfcal$)
  End If
 
 If CFS$ = "SUB" Then
  Do
  ch$ = Mid$(DTA$, ct, 1)
  ct = ct + 1
  Loop Until ch$ = "#" Or ct >= (ll)
 ch$ = ""
 End If
 
 If Cfcal$ = "CALL" Then
  ct = ct + 4
  Do
  ch$ = Mid$(DTA$, ct, 1)
  ct = ct + 1
  nm$ = nm$ + ch$
  Loop Until ch$ = "#" Or ct >= (ll)
 ch$ = ""
 NL = Len(nm$)
 CNM$ = Left$(nm$, NL - 1)
 'Debug.Print CNM$; " -CALL"
 NTC = Val(CNM$)
 
 Call GETSB(CDTA$, nm$)
 'Debug.Print "getting.."; NTC; ">"
 CDL = Len(CDTA$)
 CDTA$ = Right$(CDTA$, CDL - 5)
 'Debug.Print CDTA$; " - dATA FOR CALL"
Call vdcall(AG, QA, TA, CDTA$, H, V, B, SIZE, C, x, y)
 nm$ = ""
 End If
 
 If ch$ = "M" Then
    te = 0
    ct = ct + 1
    Do
    te = te + 1
    TTE$ = Mid$(DTA$, ct + te, 1)
    Loop Until TTE$ = ","
    H = Val(Mid$(DTA$, ct, te))
    ct = te + ct
    te = 0
    ct = ct + 1
    Do
    te = te + 1
    TTE$ = Mid$(DTA$, ct + te, 1)
    Loop Until TTE$ = ";"
    V = Val(Mid$(DTA$, ct, te))
    'Debug.Print "M ,"; H; " "; V
    ct = te + ct
    x = H
    y = V
    End If

 Rem ACTUALLY DRAWLING SHAPE
If ch$ = "~" Then
  Call GETTX(DTA$, ct, TXT$, s)
  Call PRTEXT(TXT$, H, V, s, C, niv, frmn)
End If

If ch$ = "S" Then
Call GETVL(DTA$, ct, SZ)
  SIZE = scal + SZ
   'Debug.Print "C "; C
    End If


If ch$ = "B" Then
    bl = 1
    End If
If ch$ = "N" Then
    N = 1
    'CT = CT + 1
End If
 If ch$ = "T" Then
   ct = ct + 1
Call GETVL(DTA$, ct, SZ)
  'Debug.Print "SZ "; SZ
  ANGLE = SZ
  ANGLE = ANGLE * 3.142857 / 180
  ANGLE = ANGLE + CANGLE * 3.142857 / 180
  End If
If BUCK = 0 Then
If ch$ = "X" Then
Call GETVL(DTA$, ct, SZ)
    'rem move 3d forward
   DMO = SZ
  Call DLINE(AG, VR, EA, DMO, H, V, x, y, C, bl, N, SIZE, niv, frmn)
End If
If ch$ = "Z" Then
Call GETVL(DTA$, ct, SZ)
    'rem move 3d backward
       DMO = 0 - SZ
  Call DLINE(AG, VR, EA, DMO, H, V, x, y, C, bl, N, SIZE, niv, frmn)
End If

If ch$ = "U" Then
Call GETVL(DTA$, ct, SZ)
  EA = 270 + ANGLE
      Call SGLINE(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, bl, N, niv, frmn)
End If
 If ch$ = "R" Then
Call GETVL(DTA$, ct, SZ)
    EA = 360 + ANGLE
   Call SGLINE(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, bl, N, niv, frmn)
End If
If ch$ = "D" Then
Call GETVL(DTA$, ct, SZ)
  EA = 90 + ANGLE
    Call SGLINE(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, bl, N, niv, frmn)
End If
If ch$ = "L" Then
Call GETVL(DTA$, ct, SZ)
  EA = 180 + ANGLE
  Call SGLINE(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, bl, N, niv, frmn)
 End If
Rem *******************
Rem *** Flat Angles ***
Rem *******************
 
 fx = SZ / 3

bll = bl

If ch$ = "H" Or ch$ = "F" Or ch$ = "E" Or ch$ = "G" Then

h2 = H: v2 = V
End If

If ch$ = "F" Then
Call GETVL(DTA$, ct, SZ)

  EA = 360 + ANGLE
    Call pline(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, SWTH, SHHT, frmn)
  EA = 90 + ANGLE
    Call pline(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, SWTH, SHHT, frmn)
    
End If
If ch$ = "H" Then
Call GETVL(DTA$, ct, SZ)
 
  EA = 270 + ANGLE
    Call pline(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, SWTH, SHHT, frmn)
  EA = 180 + ANGLE
    Call pline(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, SWTH, SHHT, frmn)
     
End If

If ch$ = "E" Then
Call GETVL(DTA$, ct, SZ)

  EA = 270 + ANGLE
    Call pline(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, SWTH, SHHT, frmn)
  EA = 360 + ANGLE
    Call pline(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, SWTH, SHHT, frmn)
    
End If

If ch$ = "G" Then
Call GETVL(DTA$, ct, SZ)

  EA = 180 + ANGLE
    Call pline(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, SWTH, SHHT, frmn)
  EA = 90 + ANGLE
    Call pline(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, SWTH, SHHT, frmn)
    
End If

If ch$ = "H" Or ch$ = "F" Or ch$ = "E" Or ch$ = "G" Then

If bll = 0 And H > 0 And H < (HLIM) And V > 0 And V < (VLIM) Then
 

 Call fLine(h2, v2, x, y, C, frmn)
 
End If

If N = 1 Then


H = h2: V = v2
Else

H = x: V = y
End If
End If
End If

bl = bll
SUPERANGLE:

Rem SZ IS SPEACIAL TO SUPERANGLE ONLY!

Rem FOWARDS ANGLES

If chh$ = "^U" Then
    Rem U UP/FORWARD
    'rem move 3d forward
     DMO = 0 - SZ
     EA = 270 + ANGLE
    GoTo EXTRA
End If

If chh$ = "^R" Then
    Rem ^R RIGHT/FORWARD
    'rem move 3d forward
     DMO = 0 - SZ
     EA = 360 + ANGLE
    GoTo EXTRA
End If

If chh$ = "^D" Then
    Rem ^D DOWN/FORWARD
    'rem move 3d forward
     DMO = 0 - SZ
     EA = 90 + ANGLE
     GoTo EXTRA
End If

If chh$ = "^L" Then
    Rem ^L DOWN/FORWARD
    'rem move 3d forward
     DMO = 0 - SZ
     EA = 180 + ANGLE
     GoTo EXTRA
End If

Rem BACKWARDS ANGLES
 
If chh$ = "VU" Then
    Rem VU UP/BACKWARD
    'rem move 3d forward
     DMO = SZ
     EA = 270 + ANGLE
    GoTo EXTRA
End If

If chh$ = "VR" Then
    Rem VR RIGHT/BACKWARD
    'rem move 3d forward
     DMO = SZ
     EA = 360 + ANGLE
    GoTo EXTRA
End If

If chh$ = "VD" Then
    Rem ^D DOWN/BACKWARD
    'rem move 3d forward
     DMO = SZ
     EA = 90 + ANGLE
     GoTo EXTRA
End If

If chh$ = "VL" Then
    Rem VL DOWN/BACKWARD
    'rem move 3d forward
     DMO = SZ
     EA = 180 + ANGLE
     GoTo EXTRA
End If


Rem FORWARD ANGLES
Rem CTRL ^
If chh$ = "^E" Then
    'rem move 3d forward
     DMO = 0 - SZ
     EA = 360 + ANGLE
     EA1 = 270 + ANGLE
     GoTo EXTRA
End If

If chh$ = "^F" Then
    'rem move 3d forward
     DMO = 0 - SZ
     EA = 360 + ANGLE
     EA1 = 90 + ANGLE
     GoTo EXTRA
End If

If chh$ = "^G" Then
    'rem move 3d forward
     DMO = 0 - SZ
     EA = 180 + ANGLE
     EA1 = 90 + ANGLE
     GoTo EXTRA
End If

If chh$ = "^H" Then
    'rem move 3d forward
     DMO = 0 - SZ
     EA = 180 + ANGLE
     EA1 = 270 + ANGLE
     GoTo EXTRA
End If

Rem BACKWARD ANGLES
Rem ALT V
If chh$ = "VE" Then
    'rem move 3d forward
     DMO = SZ
     EA = 360 + ANGLE
     EA1 = 270 + ANGLE
     GoTo EXTRA
End If

If chh$ = "VF" Then
    'rem move 3d forward
     DMO = SZ
     EA = 360 + ANGLE
     EA1 = 90 + ANGLE
     GoTo EXTRA
End If

If chh$ = "VG" Then
    'rem move 3d forward
     DMO = SZ
     EA = 180 + ANGLE
     EA1 = 90 + ANGLE
     GoTo EXTRA
End If

If chh$ = "VH" Then
    'rem move 3d forward
     DMO = SZ
     EA = 180 + ANGLE
     EA1 = 270 + ANGLE
     GoTo EXTRA
End If



If N = 0 Then ' REM CHECK FOR NO UPDATE
If x <> (H) Then
H = x
End If
If y <> (V) Then
V = y
End If
End If


Rem BLOCK THIS CODE



Next ct
GoTo ET

EXTRA:
 X1 = x: Y1 = y
    TBL = bl
     bl = 1
         'SGLINE(ag, VR, EA, ANGLE, SZ, X, Y, H, V, C, size, bl, N, NIV)
     Call DLINE(AG, VR, EA, DMO, H, V, x, y, C, bl, N, SIZE, niv, frmn)
         H = x: V = y
     bl = 1
     Call SGLINE(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, bl, N, niv, frmn)
         H = x: V = y
     If EA1 <> 0 Then
     bl = 1
     EA = EA1
     Call SGLINE(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, bl, N, niv, frmn)
     End If
    
     bl = TBL
    
    
    If bl = 0 Then
    
   Call fLine(X1, Y1, x, y, C, frmn)
    
    
    End If
     chh$ = ""
   
    If N = 1 Then

    H = X1: V = Y1
    End If
    EA1 = 0
    GoTo SUPERANGLE
  
ET:


' REM CHECK FOR BORDER ERROR#


 If x > 2000000000# Then
 'rem right
 x = 0
 xx = xx + 1
 End If
  If x < -2000000000# Then
 ' rem left
 x = 0
 xx = xx - 1
 End If
  If y > 2000000000# Then
 'rem down
 y = 0
 yy = yy + 1
 End If
  If y < -2000000000# Then
 ' rem up
 y = 0
 yy = yy + 1
 End If
 ch$ = ""
If xx <> (pagex) Or yy <> (pagey) Then
niv = 1
End If
 
 
 
'Form2.Text14 = xx
'Form2.Text13 = yy
'sch = Form2.Text9 ' rem get from tool box
'scv = Form2.Text11
C = &HFF&
Call fLine(xx, yy, xx + 20, yy, C, frmn)
Call fLine(xx, yy + 20, xx + 20, yy + 20, C, frmn)
Call fLine(xx, yy, xx, yy + 20, C, frmn)
Call fLine(xx + 20, yy, xx + 20, yy + 20, C, frmn)

Call gridinfo(sch, scv, pagex, pagey, AG, QA, TA, frmn)
'End If
End Sub
Public Sub gridinfo(xx, yy, pagex, pagey, AG, QA, TA, frmn)
Rem
Rem tells the user where he she is
Rem on the world scale
Rem

'vbcad.Label1 = "Hgrid " + Str$(xx) + " Vgrid " + Str$(yy) + " pg H " + Str$(pagex) + " pg V " + Str$(pagey)

'Form13.Label1 = "Hgrid " + Str$(xx) + " Vgrid " + Str$(yy) + " pg H " + Str$(pagex) + " pg V " + Str$(pagey)

'Form14.Label1 = "Hgrid " + Str$(xx) + " Vgrid " + Str$(yy) + " pg H " + Str$(pagex) + " pg V " + Str$(pagey)

'Form15.Label1 = "Hgrid " + Str$(xx) + " Vgrid " + Str$(yy) + " pg H " + Str$(pagex) + " pg V " + Str$(pagey)


End Sub


Public Sub fLine(H, V, x, y, C, frmn)

Select Case frmn

Case 1
vv = GR.ScaleHeight
hh = GR.ScaleWidth
Case 2
vv = cad.ScaleHeight
hh = cad.ScaleWidth
End Select


If H > 0 And H < (hh) And V > 0 And V < (vv) And x > 0 And x < (hh) And y > 0 And y < (vv) Then

Select Case frmn
Case 1
GR.Line (H, V)-(x, y), C
Case 2
cad.Line (H, V)-(x, y), C
Case 3
prompt2.Line (H, V)-(x, y), C
End Select
End If

End Sub

Sub pline(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, SWTH, SHHT, frmn)

'REM EA IS VERTICAL ANGLE
'VR IS HOROZONTAL ANGLE
' AG IF FRONTAL ANGLE
'If AG = 0 Then AG = 1
If VR = 0 Then VR = 1
  cl = 0
  AI = 5
  AI = AI * 3.142857 / 180
   EA = EA * 3.142857 / 180
   For TR = (ANGLE) To (ANGLE + EA) Step AI
Next TR
'agc = AG * 3.142857 / 180

For ATR = (AI) To (AI + agc) Step AI
Next ATR

Do
  'AGD = AG * 3.142857 / 180
  cl = cl + SZ
  x = H + (cl * SIZE) * Cos(TR)
  y = V + (cl * SIZE) * Sin(TR) / VR '* ATR

Loop Until (cl) >= (SZ * scle)



H = x: V = y
End Sub

Public Sub SGLINE(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, bl, N, niv, frmn)
Rem SHOW DATA

'Debug.Print "ag "; ag; " VR "; VR; " EA "; EA; " ANGLE "; ANGLE; " SZ "; SZ; " X "; X; " Y "; Y; " H "; H; " V "; V; " C "; C; " size "; size; " bl "; bl; " N "; N; " NIV"; NIV

'REM EA IS VERTICAL ANGLE
'VR IS HOROZONTAL ANGLE
' AG IF FRONTAL ANGLE
'If AG = 0 Then AG = 1
If VR = 0 Then VR = 1
  cl = 0
  AI = 5
  AI = AI * 3.142857 / 180
   EA = EA * 3.142857 / 180
   For TR = (ANGLE) To (ANGLE + EA) Step AI
Next TR
'agc = AG * 3.142857 / 180
 
For ATR = (AI) To (AI + agc) Step AI
Next ATR
 
Do
  'AGD = AG * 3.142857 / 180
  cl = cl + SZ
  x = H + (cl * SIZE) * Cos(TR)
  y = V + (cl * SIZE) * Sin(TR) / VR '* ATR
  If bl = 0 Then
  
   Call fLine(H, V, x, y, C, frmn)
  
  End If
Loop Until (cl) >= (SZ)

bl = 0
If N = 1 Then
x = H
y = V
N = 0
End If

End Sub



Public Sub DLINE(AG, VR, EA, DMO, H, V, x, y, C, bl, N, SIZE, niv, frmn)
AI = 1
'ADG = AG * 3.142857 / 180
AI = AI * 3.142857 / 180
For AAG = 1 To (ADG) Step (AI)
Next AAG
V1 = V + ((DMO * (VR)) / 6) * SIZE
H1 = H


If bl = 0 Then

If niv = 0 Then

Call fLine(H, V, H1, V1, C, frmn)

End If
End If
x = H1
y = V1
bl = 0
If N = 1 Then
x = H
y = V
N = 0
End If
'Debug.Print DMO; " - DMO "
End Sub





Public Sub VBCH(DAT$, H, V, SZ, C, px, py, Frm, frmn)
dr = 0
x = H
y = V
X1 = H
Y1 = y
Rem BUILD DATA
ll = Len(DAT$)
For ct = 1 To (ll)
ch$ = Mid$(DAT$, ct, 1)
 ch$ = UCase$(ch$)
 
 Rem ACTUALLY DRAWLING SHAPE
If ch$ = "B" Then dr = 1
If ch$ = "V" Then dr = 0
If ch$ = "L" Then x = x - SZ
If ch$ = "D" Then y = y + SZ
If ch$ = "R" Then x = x + SZ
If ch$ = "U" Then y = y - SZ
If ch$ = "F" Then x = x - SZ: y = y + SZ
If ch$ = "G" Then x = x + SZ: y = y + SZ
If ch$ = "H" Then x = x - SZ: y = y - SZ
If ch$ = "E" Then x = x + SZ: y = y - SZ


If dr = 0 And niv = 0 Then
If Frm = 1 Then
Call fLine(X1, Y1, x, y, C, frmn)
End If
If Frm = 4 Then
Call fLine(X1, Y1, x, y, C, frmn)
End If
End If
X1 = x: Y1 = y
Next ct
px = x: py = y
End Sub




Public Sub vdcall(AG, QA, TA, DTA$, H, V, B, SIZE, C, x, y)
'Debug.Print DTA$; " RECIVED vdcall..."
niv = 0
' NIV STANDS FOR NOT IN VEIW USED TO CUT DOWN ON WASTED CPU TIME
' AND TO REDUCE SCREEN ERROR
'pagex = Form3.text1
'pagey = Form3.text2
'xx = Form2.Text14
'yy = Form2.Text13

VR = QA
CANGLE = TA
N = 0
bl = 0
  SA = 0
  SA = SA * 3.142857 / 180
 
 ANGLE = CANGLE * 3.142857 / 180
 'EA = EA * 3.142857 / 180
  AI = 1
  AI = AI * 3.142857 / 180
  cl = 1
  If B = 1 Then cl = &H0
'H = gr.ScaleWidth / 2 + Form2.Text9 '
'V = gr.ScaleHeight / 2 + Form2.Text11 ' REM CENTER SHAPE
x = H
y = V
Rem BUILD DATA

ll = Len(DTA$)
For ct = 1 To (ll)
ch$ = Mid$(DTA$, ct, 1)
 ch$ = UCase$(ch$)
 
 If ct + 3 < ll Then
  CFS$ = Mid$(DTA$, ct, 3)
  End If
 If CFS$ = "SUB" Then
  Do
  ch$ = Mid$(DTA$, ct, 1)
  ct = ct + 1
  Loop Until ch$ = "#" Or ct >= (ll)
 ch$ = ""
 End If
 If ch$ = "M" Then
    te = 0
    ct = ct + 1
    Do
    te = te + 1
    TTE$ = Mid$(DTA$, ct + te, 1)
    Loop Until TTE$ = ","
    H = Val(Mid$(DTA$, ct, te))
    ct = te + ct
    te = 0
    ct = ct + 1
    Do
    te = te + 1
    TTE$ = Mid$(DTA$, ct + te, 1)
    Loop Until TTE$ = ";"
    V = Val(Mid$(DTA$, ct, te))
    'Debug.Print "M ,"; H; " "; V
    ct = te + ct
    x = H
    y = V
    End If
 Rem ACTUALLY DRAWLING SHAPE
If ch$ = "~" Then
Call GETTX(DTA$, ct, TXT$, s)
'Call PRTEXT(TXT$, h, v, S, C, NIV)
End If
If ch$ = "B" Then
    bl = 1
    End If
If ch$ = "N" Then
    N = 1
    'CT = CT + 1
End If
 If ch$ = "T" Then
   ct = ct + 1
Call GETVL(DTA$, ct, SZ)
  'Debug.Print "SZ "; SZ
  ANGLE = SZ
  ANGLE = ANGLE * 3.142857 / 180
  ANGLE = ANGLE + CANGLE * 3.142857 / 180
  End If
  
If ch$ = "X" Then
Call GETVL(DTA$, ct, SZ)
    'rem move 3d forward
   DMO = SZ
  Call DLINE(AG, VR, EA, DMO, H, V, x, y, C, bl, N, SIZE, niv, frmn)

End If
If ch$ = "Z" Then
Call GETVL(DTA$, ct, SZ)
    'rem move 3d backward
       DMO = 0 - SZ
  Call DLINE(AG, VR, EA, DMO, H, V, x, y, C, bl, N, SIZE, niv, frmn)
End If
If ch$ = "U" Then
Call GETVL(DTA$, ct, SZ)
  EA = 270 + ANGLE
      Call SGLINE(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, bl, N, niv, frmn)
End If
 If ch$ = "R" Then
Call GETVL(DTA$, ct, SZ)
    EA = 360 + ANGLE
   Call SGLINE(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, bl, N, niv, frmn)
End If
If ch$ = "D" Then
Call GETVL(DTA$, ct, SZ)
  EA = 90 + ANGLE
    Call SGLINE(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, bl, N, niv, frmn)
End If
If ch$ = "L" Then
Call GETVL(DTA$, ct, SZ)
  EA = 180 + ANGLE
  
  Call SGLINE(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, bl, N, niv, frmn)
End If
If ch$ = "H" Then
Call GETVL(DTA$, ct, SZ)
  EA = 225 + ANGLE
    Call SGLINE(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, bl, N, niv, frmn)
End If
If ch$ = "F" Then
Call GETVL(DTA$, ct, SZ)
  EA = 45 + ANGLE
  
  Call SGLINE(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, bl, N, niv, frmn)
End If
If ch$ = "G" Then
Call GETVL(DTA$, ct, SZ)
  EA = 135 + ANGLE
  Call SGLINE(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, bl, N, niv, frmn)
End If
If ch$ = "E" Then
Call GETVL(DTA$, ct, SZ)
    EA = 315 + ANGLE
  Call SGLINE(AG, VR, EA, ANGLE, SZ, x, y, H, V, C, SIZE, bl, N, niv, frmn)
End If

If B = 0 And ch$ = "C" Then
Call GETVL(DTA$, ct, SZ)
  C = SZ
 bl = 0
     End If
 
If ch$ = "S" Then
Call GETVL(DTA$, ct, SZ)
  SIZE = SZ
   'Debug.Print "C "; C
    End If
 
If N = 0 Then ' REM CHECK FOR NO UPDATE
If x <> (H) Then
H = x
End If
If y <> (V) Then
V = y
End If
' NIV PROP

' REM CHECK FOR BORDER ERROR#

End If
 If x > 2000000000# Then
 'rem right
 x = 0
 xx = xx + 1
 End If
  If x < -2000000000# Then
 ' rem left
 x = 0
 xx = xx - 1
 End If
  If y > 2000000000# Then
 'rem down
 y = 0
 yy = yy + 1
 End If
  If y < -2000000000# Then
 ' rem up
 y = 0
 yy = yy + 1
 End If
 ch$ = ""
If xx <> (pagex) Or yy <> (pagey) Then
niv = 1
End If
 
 ch$ = ""
 Next ct '
'Form2.Text14 = xx
'Form2.Text13 = yy
End Sub

Public Sub GETTX(DTA$, ct, TXT$, s)
te = 0
Do
    TTE$ = Mid$(DTA$, ct + te, 1)
    te = te + 1
    Loop Until TTE$ = ","
    TXT$ = Mid$(DTA$, ct + 1, te - 2)
    
    ts = ct + te
    tt = 0
    Do
       tt = tt + 1
    TTE$ = Mid$(DTA$, ts + tt, 1)
    Loop Until TTE$ = ";"
     
    s = Mid$(DTA$, ts, tt)
  
ct = ct + (tt)
End Sub


Public Sub GETSB(CDTA$, nm$)
' REM GET SUB FOR CALL
nm$ = UCase$(nm$)
ct = 0
Do
svar$ = cadarry$(ct, 0)
svar$ = UCase$(svar$)
If svar$ <> (nm$) Then ct = ct + 1
Loop Until ct >= 200 Or svar$ = nm$



CDTA$ = cadarry$(ct, 1)
'MsgBox (CDTA$)
'cad.text1 = CDTA$
End Sub









Public Sub PASTE(frmn)


'ag = Form2.TEXT8
'qa = Form2.TEXT4
'ta = Form2.text2
'DTA$ = Form5.text1



vbcad.Cls
frmn = 1
Call CDRAW(AG, QA, TA, DTA$, B, frmn)
Call COLORBOX(frmn)


'Form13.Cls
'qa = qa + Val(Form13.text1)
'ta = ta + Val(Form13.text2)
'frmn = 13
'Call CDRAW(ag, qa, ta, DTA$, B, frmn)
'Call COLORBOX(frmn)
'ag = Form2.TEXT8
'qa = Form2.TEXT4
'ta = Form2.text2

'Form14.Cls
'qa = qa + Val(Form14.text1)
'ta = ta + Val(Form14.text2)
'frmn = 14
'Call CDRAW(ag, qa, ta, DTA$, B, frmn)
'Call COLORBOX(frmn)
'ag = Form2.TEXT8
'qa = Form2.TEXT4
'ta = Form2.text2

'Form15.Cls
'qa = qa + Val(Form15.text1)
'ta = ta + Val(Form15.text2)
'frmn = 15
'Call CDRAW(ag, qa, ta, DTA$, B, frmn)
'Call COLORBOX(frmn)


End Sub


Public Sub CDRAW(AG, QA, TA, DTA$, B, frmn)
'If AG = 0 Then AG = Text8
'dta$ = "QA" + Str$(QA) + ";" + "TA" + Str$(TA) + ";" + dta$
Call grdraw(AG, QA, TA, DTA$, H, V, B, frmn, scal)
'REM PLOT POINTER
Call fLine(H, V, H + 50, V + 50, &HFF, frmn)

End Sub


Public Sub rotate()
DTA$ = Form5.text1
AN = Form2.TEXT8
QA = Val(Form2.TEXT4)
STA = Val(Form2.text2)
TA = STA
T1 = STA
vbcad.Cls
Form13.Cls
Form14.Cls
Form15.Cls

For RT = 1 To (355 / 5)
'dta$ = "TA" + Str$(STA) + ";" + "QA" + Str$(QA) + ";" + Text1
T1 = TA
If TA > 360 Then TA = 1
TA = TA + 5
BB = 0
frmn = 1
Call CDRAW(AG, QA, TA, DTA$, BB, frmn)
 
frmn = 13

qa1 = Val(Form13.text1)
ta1 = Val(Form13.text2)
Call CDRAW(AG, QA + qa1, TA + ta1, DTA$, BB, frmn)
QA = Form2.TEXT4

frmn = 14
qa2 = Val(Form14.text1)
ta2 = Val(Form14.text2)
Call CDRAW(AG, QA + qa2, TA + ta2, DTA$, BB, frmn)
QA = Form2.TEXT4

frmn = 15
qa3 = Val(Form15.text1)
ta3 = Val(Form15.text2)
Call CDRAW(AG, QA + qa3, TA + ta3, DTA$, BB, frmn)
QA = Form2.TEXT4


BB = 1
frmn = 1
Call EDRAW(AG, QA, T1, DTA$, BB, frmn)

frmn = 13

t11 = Val(Form13.text2)
Call EDRAW(AG, QA + qa1, T1 + t11, DTA$, BB, frmn)

frmn = 14

t12 = Val(Form14.text2)
Call EDRAW(AG, QA + qa2, T1 + t12, DTA$, BB, frmn)

frmn = 15

t13 = Val(Form15.text2)
Call EDRAW(AG, QA + qa3, T1 + t13, DTA$, BB, frmn)

Next RT

BB = 0
Call PASTE(frmn)

text2 = TA
Call COLORBOX(frmn)
End Sub

Public Sub EDRAW(AG, QA, TA, DTA$, B, frmn)

'If AG = 0 Then AG = Text8
'dta$ = "QA" + Str$(QA) + ";" + "TA" + Str$(TA) + ";" + dta$
Call grdraw(AG, QA, TA, DTA$, H, V, B, frmn, scal)
'REM PLOT POINTER
Call fLine(H, V, H + 50, V + 50, &H0&, frmn)

End Sub

Public Sub GETVL(DTA$, ct, SZ)
te = 0

ll = Len(DTA$)
Do
    TTE$ = Mid$(DTA$, ct + te, 1)
    te = te + 1
    WD$ = WD$ + TTE$
    Loop Until TTE$ = ";" Or ct + te > (ll)
    ll = Len(WD$)
    WD$ = Left$(WD$, ll - 1)
    ll = Len(WD$)
    nn$ = Mid$(WD$, 2, ll)
   ' Debug.Print WD$; " - "; NN$
    SZ = Val(nn$)
     
End Sub


