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
Global cadrotatevar ' used to turn on cad rotation
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 * 7)
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 * 7)
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 * 7)
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 * 7)
End If
If ch$ = "4" Then
Call VBCH("B;R;R;V;U;U;U;L;L;U;U;D;D;R;R;U;U;D;D;R;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 7)
End If
If ch$ = "5" Then
Call VBCH("B;U;U;U;U;U;U;R;R;R;R;R;V;L;L;L;L;L;D;D;D;R;R;R;R;G;D;F;L;L;L;L;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 7)
End If

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

If ch$ = "7" Then
Call VBCH("B;U;U;U;U;U;U;V;R;R;R;R;D;F;F;F;D;D;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 7)
End If
If ch$ = "8" Then
Call VBCH("U;U;U;U;U;U;R;R;R;R;R;D;D;D;L;L;L;L;L;R;R;R;R;R;D;D;D;L;L;L;L;L;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 7)
End If
If ch$ = "9" Then
Call VBCH("R;R;R;R;U;U;U;U;U;U;L;L;L;L;D;D;D;R;R;R;R;", hh, vv, SZ, C, px, py, Frm, frmn)
hh = hh + (SZ * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
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 * 7)
End If

If ch$ = "." Then
Call VBCH("B;R;V;R;B;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)
Dim v1 As Integer
Dim v2 As Integer
Dim v3 As Integer
Dim v4 As Integer
Dim v5 As Integer
G$ = UCase$(groutputdevice$)
Select Case frmn

'Case 1
'vv = GR.ScaleHeight
'hh = GR.ScaleWidth

'Case 2
'vv = cad.ScaleHeight
'hh = cad.ScaleWidth
Case Is = 3
vv = Form2.Picture1.Height
hh = Form2.Picture1.Width
Case Is = 5
vv = Form1.Picture1.Height
hh = Form1.Picture1.Width
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


If G$ = "GR" Then
   GR.Line (H, V)-(X, Y), C
Else
v1 = H
v2 = V
v3 = X
v4 = Y7
v5 = Int(C)

'Call grline(v1, v2, v3, v4, v5)

End If

Case 2
cad.Line (H, V)-(X, Y), C
Case 3
prompt2.Line (H, V)-(X, Y), C
Case Is = 3
Form2.Picture1.Line (H, V)-(X, Y), C
Case Is = 5
Form1.Picture1.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 = 3 Then
Form2.Picture1.Line (X1, Y1)-(X, Y), C
End If
If Frm = 4 Then
Call fLine(X1, Y1, X, Y, C, frmn)
End If

If Frm = 5 Then
 Form1.Picture1.Line (X1, Y1)-(X, Y), C
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 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


