Define xMax, yMax, MenuLeft, xStart, yStart, CurObj, ChangeCount, RowHeight, RowsPerPage, KeyCode, sMax, sWidth Define MainState$, MsgState$, Doing$ Define mDirection, mAcceleration Define hMax, hCur Define lMax, lPntMax, lCnt Define tMax, tCnt Define fMax, fCnt, fCur, fName$ Define flCurPage, flTopRow, flBottomRow, flCurRow, flBoxTop, flBoxBottom 100 ' ----------------------------------------------- 110 ' --- OBJECT DRAW V1.0 --- 120 ' Draw pictures with lines and text. 130 ' They are objects so that they can be 140 ' layered and deleted without erasing others. 150 ' Great for maps, room dimentions, and more. 160 ' Developed for Sharp contest entry by 10/31/99 180 ' by Chuck Newman - cnewman@mail.com 190 ' NewmanServices.com - 973-228-5753 200 ' ASP VBScript JavaScript HTML VB SQL 210 ' ----------------------------------------------- 220 ' 10/12/99 CIN - Initial key-in - V1.0 230 ' ----------------------------------------------- 2000 ' Mem Limit is 2^15=32,768 32k 2040 ' --- General --- 2060 xMax = 238 ' = 2*7*17 2080 yMax = 69 ' = 2*7*5 - 1 2100 MenuLeft = 50 2120 sMax = 40 2140 RowsPerPage = 7 2160 RowHeight = (yMax+1) / RowsPerPage 2200 GoSub *MsgBox2 2220 Print "Loading ..." 2300 ' --- Help --- 2340 hMax = 29 2360 Dim h$(hMax) * 50 ' 30*50= 1500 2400 ' --- Line Arrays --- 2440 lMax = 29 2460 lPntMax = 49 2500 Dim l$(lMax) * 3 ' 30*3= 90 2520 Dim lx$(lMax, lPntMax) * 3 ' 30*50*3= 4500 2540 Dim ly$(lMax, lPntMax) * 3 ' 30*50*3= 4500 2700 ' --- Text Arrays --- 2740 tMax = 29 2760 Dim tx$(tMax) * 3 ' 30*3= 90 2780 Dim ty$(tMax) * 3 ' 30*3= 90 2800 Dim t$(tMax) * 40 '= sMax 30*40= 1200 2900 ' --- File Names --- 2940 fMax = 27 2960 Dim f$(fMax) * 40 '= sMax 28*40= 1120 2980 ' (add program size. max is 32k) 13090 + 14k = 27k, 5k left 5000 ' *********************************************** 5020 ' INITIALIZE 5040 ' *********************************************** 5080 ' --- Load Help Text --- 5100 For i = 0 To hMax 5120 Read h$(i) 5140 Next i 6000 ' --- load file list --- 6020 For i = 0 To fMax 6040 f$(i) = "" 6060 Next i 6200 ' File might not be there yet. 6220 On Error Goto *SkipLoadingFileList 6240 Open "E:objd_fl" For Input As #1 6260 On Error Goto 0 6280 Input #1, fCnt 6300 For i = 0 To fCnt - 1 6320 Input #1, f$(i) 6340 Next 6360 Close #1 6380 MsgState$ = " " ' No messages 6400 GoSub *ShowList 6420 Goto *SkipHelp 6440*SkipLoadingFileList 6460 ' --- File missing. User's first time. Show help. --- 6480 On Error Goto 0 6500 GoSub *ShowHelp 6520*SkipHelp 6540 MainState$ = "F" 6560 On Error Goto *Trap 6580 ' --- Done Initializing --- 10100 ' *********************************************** 10110 ' MAIN LOOP 10120 ' *********************************************** 10130*Main 10135 Doing$ = "event handling" 10140 k$=InKey$(1) 10150 KeyCode = Asc k$ 10160 If MsgState$ = " " Then *Main120 10170 ' --- In Message State --- 10180 GoSub *hMsgS 10190 ' --- Loop if still in message state. 10200 If MsgState$ <> " " Then *Main 10205 If MainState$ <> "F" Then *Main100 10210 GoSub *ShowList 10215 Goto *Main 10220*Main100 10225 GoSub *ShowEditor 10230 Goto *Main 10240*Main120 10250 If MainState$ <> "F" Then *Main140 10260 ' --- In FileList State --- 10270 GoSub *hFileS 10280 Goto *Main 10290*Main140 10300 If MainState$ <> "T" Then *Main160 10310 ' --- In Text State --- 10320 GoSub *hTextS 10330 Goto *Main 10340*Main160 10400 ' ----------------------------------------- 10410 ' We're not in filelist, message or text mode 10420 ' so we must be in a graphic mode. 10430 ' So let's check for cursor movement first. 10440 ' ----------------------------------------- 10480 'Print "KeyCode='" + KeyCode + "'" 10500 If KeyCode <> 15 And KeyCode <> 4 And KeyCode <> 14 And KeyCode <> 5 Then *Main220 10510 GoSub *FlipMouse ' <-- Hide Mouse 10520 If mDirection = KeyCode Then *Main180 10530 mAcceleration = 0 10540 mDirection = KeyCode 10560*Main180 10570 mAcceleration = mAcceleration + 1 10590 GoSub *hMouseMove 10600 GoSub *FlipMouse ' <-- Show Mouse 10610 Goto *Main 10620*Main220 10630 mAcceleration = 0 10700 If MainState$ <> "E" Then *Main240 10710 GoSub *hEditorS 10720 Goto *Main 10730*Main240 10740 If MainState$ = "L" Then GoSub *hLineS 10750 Goto *Main 10800 ' *********************************************** 10900 ' -------------------- HANDLE FILE LIST STATE -------------------- 10905*hFileS 10910 'Print MainState$ + MsgState$ + k$ 10915 Doing$ = "file list" 10920 ' --- Key Enter = Open --- 10925 If KeyCode <> 10 Then *hFileS100 10930 GoSub *FileOpen 10935 Return 10940*hFileS100 10945 ' --- Key Escape = End --- 10950 If KeyCode <> 27 Then *hFileS120 10955 GoSub *SaveList 10960 End 10965 Return 10970*hFileS120 10975 ' --- Key Up --- 11080 If KeyCode <> 4 Then *hFileS140 11085 If fCur <= 0 Then Return 11090 fCur = fCur - 1 11095 GoSub *ShowList 11100 Return 11105*hFileS140 11110 ' --- Key Down --- 11115 If KeyCode <> 5 Then *hFileS160 11120 If fCnt <= fMax Then *hFileS150 11125 GoSub *ShowMsgBox 11130 Print "No room for new files." 11135 Locate MenuLeft, 5 11140 Print "OK [Enter]" 11142 MsgState$ = "X" 11145 Beep 11150 Return 11155*hFileS150 11160 If fCur = fCnt Then Return 11165 fCur = fCur + 1 11170 GoSub *ShowList 11175 Return 11180*hFileS160 11185 If KeyCode <> 6 Then *hFileS170 11190 ' --- Key Page Up --- 11195 fCur = fCur - RowsPerPage 11200 If fCur < 0 Then fCur = 0 11205 GoSub *ShowList 11210 Return 11215*hFileS170 11220 If KeyCode <> 7 Then *hFileS180 11225 ' --- Key Page Down --- 11230 fCur = fCur + RowsPerPage 11235 If fCur >= fCnt Then fCur = fCnt - 1 11240 GoSub *ShowList 11245 Return 11250*hFileS180 11255 ' --- Key Del = Shorten Name --- 11260 If KeyCode <> 12 Then *hFileS190 11265 If f$(fCur) = "" Then Return 11270 f$(fCur) = Left$(f$(fCur), Len(f$(fCur)) - 1) 11275 GoSub *ShowName 11280 Return 11285*hFileS190 11290 ' --- Key Menu --- 11295 If KeyCode <> 9 Then *hFileS200 11300 MsgState$ = "M" 11305 GoSub *ShowMsgBox 11310 Print "OBJECT DRAW - FILE LIST MENU" 11315 Locate MenuLeft, 2 11320 Print "1 - Help" 11325 Locate MenuLeft, 3 11330 Print "2 - Edit [Enter]" 11335 Locate MenuLeft, 4 11340 Print "3 - New" 11345 Locate MenuLeft, 5 11350 Print "4 - Exit [Esc]" 11355 Return 11360*hFileS200 11365 ' --- Add to Name --- 11370 If k$ < " " Then *hFileS220 11375 f$(fCur) = f$(fCur) + k$ 11380 GoSub *ShowName 11385 Return 11390*hFileS220 11395 Beep 11400 Return 11600 ' -------------------- HANDLE MOUSE MOVEMENT -------------------- 11610*hMouseMove 11615 Doing$ = "mouse move" 11620 If KeyCode <> 15 Then *hMouseMove20 11630 mx = mx - mAcceleration 11640 If mx < 0 Then mx = 0 11670 Return 11680*hMouseMove20 11690 If KeyCode <> 4 Then *hMouseMove40 11700 my = my - mAcceleration 11710 If my < 0 Then my = 0 11740 Return 11750*hMouseMove40 11760 If KeyCode <> 14 Then *hMouseMove60 11770 mx = mx + mAcceleration 11780 If mx > xMax Then mx = xMax 11810 Return 11820*hMouseMove60 11830 If KeyCode <> 5 Then *hMouseMove80 11840 my = my + mAcceleration 11850 If my > yMax Then my = yMax 11880 Return 11890*hMouseMove80 11900 'No Beep 11910 Return 12000 ' -------------------- HANDLE EDITOR STATE -------------------- 12010*hEditorS 12012 Doing$ = "editor handling" 12015 ' --- Key Enter = Save Changes --- 12020 If KeyCode <> 10 Then *hEditorS100 12030 GoSub *SaveFile 12040 GoSub *ShowList 12050 Return 12060*hEditorS100 12065 ' --- Key Escape = Exit without Saving --- 12070 If KeyCode <> 27 Then *hEditorS120 12080 GoSub *EscapeEditor 12090 Return 12100*hEditorS120 12105 ' --- Key L = Start New Line --- 12110 If k$ <> "L" Then *hEditorS140 12120 GoSub *Highlight ' <-- off 12130 GoSub *StartNewLine 12140 Return 12150*hEditorS140 12155 ' --- Key T = New Text --- 12160 If k$ <> "T" Then *hEditorS160 12170 GoSub *Highlight ' <-- off 12175 GoSub *FlipMouse ' <-- off 12180 GoSub *NewText 12190 Return 12200*hEditorS160 12205 ' --- Key Page Up = Highlight Next Object --- 12210 If KeyCode <> 6 Then *hEditorS180 12220 GoSub *Highlight ' <-- off 12225 'CurObj = (CurObj + 1) Mod (lCnt + tCnt + 1) 12230 CurObj = CurObj + 1 12235 If CurObj > lCnt + tCnt Then CurObj = 0 12240 GoSub *Highlight ' <-- on 12250 Return 12260*hEditorS180 12265 ' --- Key Page Down = Highlight Prev Object --- 12270 If KeyCode <> 7 Then *hEditorS200 12280 GoSub *Highlight ' <-- off 12285 'CurObj = (CurObj + lCnt + tCnt) Mod (lCnt + tCnt + 1) 12290 CurObj = CurObj - 1 12295 If CurObj < 0 Then CurObj = lCnt + tCnt 12300 GoSub *Highlight ' <-- on 12310 Return 12320*hEditorS200 12325 ' --- Key Del = Delete Highlighted Object --- 12330 If KeyCode <> 12 Then *hEditorS210 12335 GoSub *DelObj 12340 GoSub *ShowEditor 12345 Return 12350*hEditorS210 12355 ' --- Key R = Refresh --- 12360 If k$ <> "R" Then *hEditorS220 12365 GoSub *ShowEditor 12370 Return 12375*hEditorS220 12380 ' --- Key H = Help --- 12385 If k$ <> "H" Then *hEditorS240 12390 GoSub *ShowHelp 12400 Return 12410*hEditorS240 12415 ' --- Key Menu --- 12420 If KeyCode <> 9 Then *hEditorS260 12430 MsgState$ = "M" 12440 GoSub *ShowMsgBox 12450 Print "OBJECT DRAW - EDITOR MENU" 12460 Locate MenuLeft, 2 12470 Print "1 - [H]elp" 12480 Locate MenuLeft, 3 12490 Print "2 - Start New [L]ine" 12500 Locate MenuLeft, 4 12510 Print "3 - New [T]ext" 12520 Locate MenuLeft, 5 12530 Print "4 - Delete object [Del]" 12540 Return 12550*hEditorS260 12560 Beep 12570 Return 12700 ' -------------------- HANDLE MESSAGE STATES -------------------- 12710*hMsgS 12715 Doing$ = "message handling" 12720 If MsgState$ <> "H" Then *hMsgS100 12725 ' --- Handle Help Events ---- 12730 GoSub *hMsgSHelp 12740 Return 12750*hMsgS100 12760 If MsgState$ <> "M" Then *hMsgS110 12765 ' --- Handle Various Menu Events --- 12770 GoSub *hMsgSMenu 12780 Return 12790*hMsgS110 12800 If MsgState$ <> "S" Then *hMsgS140 12805 ' --- Handle Save Msg Events --- 12810 ' --- Key Enter = User does not what to save --- 12815 If KeyCode <> 10 Then *hMsgS120 12820 MsgState$ = " " 12830 MainState$ = "F" 12840 Return 12850*hMsgS120 12855 ' --- Key Esc = User does not want to end --- 12860 If KeyCode = 27 Then MsgState$ = " " :Else Beep 12910 Return 12920*hMsgS140 12925 ' --- Handle OK Msg Events --- 12930 If MsgState$ = "X" Then MsgState$ = " " :Else Beep 12980 Return 13100 ' -------------------- HANDLE LINE STATE -------------------- 13110*hLineS 13115 Doing$ = "line handling" 13120 If k$ <> "L" Then *hLineS100 13125 ' --- Add segment to line --- 13130 GoSub *AddSegment 13140 Return 13150*hLineS100 13160 If KeyCode <> 10 Then *hLineS120 13165 ' --- Key Enter = Finish Line --- 13170 GoSub *AddSegment 13175 GoSub *FlipMouse ' <-- Mouse Off 13180 MainState$ = "E" 13190 GoSub *Highlight ' <-- highlight 13200 GoSub *FlipMouse ' <-- Mouse On 13210 Return 13215*hLineS120 13220 If KeyCode <> 27 Then *hLineS130 13225 ' --- Key Esc = Cancel Line --- 13230 GoSub *CancelLine 13235 MainState$ = "E" 13240 GoSub *ShowEditor 13245 Return 13250*hLineS130 13255 If k$ <> "H" Then *hLineS140 13260 ' --- Help --- 13265 GoSub *ShowHelp 13270 Return 13275*hLineS140 13280 If KeyCode <> 9 Then *hLineS160 13285 ' --- Key Menu --- 13290 MsgState$ = "M" 13295 GoSub *ShowMsgBox 13300 Print "OBJECT DRAW - LINE MENU" 13310 Locate MenuLeft, 2 13320 Print "1 - [H]elp" 13330 Locate MenuLeft, 3 13340 Print "2 - Add [L]ine Segment" 13350 Locate MenuLeft, 4 13355 Print "3 - Finish Line [Enter]" 13360 Locate MenuLeft, 5 13365 Print "4 - Cancel Line [Esc]" 13370 Return 13380*hLineS160 13390 Beep 13400 Return 13500 ' -------------------- HANDLE TEXT STATE -------------------- 13510*hTextS 13520 If KeyCode <> 10 Then *hTextS100 13525 ' --- Key Enter = Keep Entry --- 13530 GoSub *KeepText 13540 Return 13550*hTextS100 13560 If KeyCode <> 27 Then *hTextS120 13565 ' --- Key Esc = Forget Entry --- 13570 MainState$ = "E" 13580 GoSub *ShowEditor 13590 Return 13600*hTextS120 13610 If KeyCode <> 12 Then *hTextS140 13615 ' --- Key Del = Shorten Text --- 13620 If t$(tCnt) = "" Then Return 13630 ChangeCount = ChangeCount + 1 13650 t$(tCnt) = Left$(t$(tCnt), Len(t$(tCnt)) - 1) 13660 'GoSub *ShowTextBox 13670 Locate xStart, yStart 13675 Print t$(tCnt) + " " 13680 Return 13690*hTextS140 13700 If KeyCode <> 9 Then *hTextS160 13715 ' --- Key Menu --- 13720 MsgState$ = "M" 13730 GoSub *ShowMsgBox 13740 Print "OBJECT DRAW - TEXT MENU" 13750 Locate MenuLeft, 2 13760 Print "1 - Help" 13770 Locate MenuLeft, 3 13780 Print "2 - Keep entry [Enter]" 13785 Locate MenuLeft, 4 13790 Print "3 - Cancel entry [Esc]" 13795 Return 13800*hTextS160 13810 If k$ < " " Then *hTextS180 13820 ' --- Add to Text --- 13825 If Len(t$(tCnt)) = sMax Then Return 13830 sWidth = GLen(t$(tCnt) + k$) 13835 If sWidth > xMax - xStart Then Return 13840 ChangeCount = ChangeCount + 1 13845 t$(tCnt) = t$(tCnt) + k$ 13850 'GoSub *ShowTextBox 13855 Locate xStart, yStart 13860 Print t$(tCnt) 13865 Return 13870*hTextS180 13880 Beep 13890 Return 14000 ' -------------------- HANDLE MESSAGE STATE - HELP -------------------- 14010*hMsgSHelp 14020 If KeyCode <> 27 And KeyCode <> 10 Then *hMsgSHelp100 14025 ' --- Key Esc or Enter = Leave Help --- 14030 hCur = 0 14040 MsgState$ = " " 14050 Return 14060*hMsgSHelp100 14070 If KeyCode <> 5 Then *hMsgSHelp120 14075 ' --- Key Down --- 14080 If hCur >= hMax - RowsPerPage Then Return 14090 hCur = hCur + 1 14100 GoSub *ShowHelp 14120 Return 14130*hMsgSHelp120 14140 If KeyCode <> 4 Then *hMsgSHelp140 14145 ' --- Key Up --- 14150 If hCur <= 0 Then Return 14160 hCur = hCur - 1 14170 GoSub *ShowHelp 14190 Return 14200*hMsgSHelp140 14210 If KeyCode <> 6 Then *hMsgSHelp160 14215 ' --- Key Page Up --- 14220 hCur = hCur - RowsPerPage 14230 If hCur < 0 Then hCur = 0 14240 GoSub *ShowHelp 14250 Return 14260*hMsgSHelp160 14270 If KeyCode <> 7 Then *hMsgSHelp200 14275 ' --- Key Page Down --- 14280 hCur = hCur + RowsPerPage 14290 If hCur > hMax - RowsPerPage Then hCur = hMax - RowsPerPage 14320 GoSub *ShowHelp 14330 Return 14340*hMsgSHelp200 14350 Beep 14360 Return 14500 ' -------------------- HANDLE MESSAGE STATE - MENU -------------------- 14510*hMsgSMenu 14520 If KeyCode <> 27 Then *hMsgSMenu100 14530 ' ------------ Key Escape = Close Menu ------------ 14540 MsgState$ = " " 14550 Return 14560*hMsgSMenu100 14570 If k$ <> "1" Then *hMsgSMenu110 14580 ' ------------ Help ------------ 14590 GoSub *ShowHelp 14600 Return 14610*hMsgSMenu110 14620 If MainState$ <> "F" Then *hMsgSMenu200 14630 ' ------------ File List ------------ 14640 If k$ <> "2" Then *hMsgSMenu120 14650 MsgState$ = " " 14660 GoSub *FileOpen 14670 Return 14680*hMsgSMenu120 14690 If k$ <> "3" Then *hMsgSMenu160 14700 ' --- New --- 14705 If fCnt <= fMax Then *hMsgSMenu140 14710 Beep 14715 Return 14720*hMsgSMenu140 14725 MsgState$ = " " 14730 fCur = fCnt 14735 Return 14740*hMsgSMenu160 14745 If k$ <> "4" Then *hMsgSMenu180 14750 ' --- End --- 14755 GoSub *SaveList 14760 End 14780*hMsgSMenu180 14790 Beep 14800 Return 14810*hMsgSMenu200 14820 If MainState$ <> "T" Then *hMsgSMenu280 14830 ' ------------ Text ------------ 14840 If k$ <> "2" Then *hMsgSMenu240 14850 MsgState$ = " " 14860 GoSub *KeepText 14870 Return 14880*hMsgSMenu240 14890 If k$ <> "3" Then *hMsgSMenu260 14895 ' --- Cancel Text --- 14900 MsgState$ = " " 14910 MainState$ = "E" 14920 Return 14930*hMsgSMenu260 14940 Beep 14950 Return 14960*hMsgSMenu280 14970 If MainState$ <> "E" Then *hMsgSMenu400 14980 ' ------------ Editor ------------ 14990 If k$ <> "2" Then *hMsgSMenu320 15000 MsgState$ = " " 15010 GoSub *StartNewLine 15020 Return 15030*hMsgSMenu320 15040 If k$ <> "3" Then *hMsgSMenu340 15050 MsgState$ = " " 15060 GoSub *NewText 15070 Return 15080*hMsgSMenu340 15090 If k$ <> "4" Then *hMsgSMenu360 15100 MsgState$ = " " 15110 GoSub *DelObj 15120 Return 15130*hMsgSMenu360 15180 Beep 15190 Return 15200*hMsgSMenu400 15210 If MainState$ <> "L" Then *hMsgSMenu500 15220 ' ------------ Line ------------ 15230 If k$ <> "2" Then *hMsgSMenu440 15240 MsgState$ = " " 15250 GoSub *AddSegment 15260 Return 15270*hMsgSMenu440 15280 If k$ <> "3" Then *hMsgSMenu460 15285 ' --- Finish Line --- 15290 MsgState$ = " " 15295 GoSub *AddSegment 15300 MainState$ = "E" 15310 Return 15320*hMsgSMenu460 15330 If k$ <> "4" Then *hMsgSMenu480 15340 MsgState$ = " " 15350 GoSub *CancelLine 15360 Return 15370*hMsgSMenu480 15380 Beep 15390 Return 15400*hMsgSMenu500 15410 Beep 15420 Return 20100 ' *********************************************** 20110 ' SUBRUTINES 20120 ' *********************************************** 20980 ' -------------------- SHOW MESSAGE BOX -------------------- 21000*ShowMsgBox 21020 Line (45, 7)-(xMax - 45, yMax - 7), R, BF 21040 Line (45, 7)-(xMax - 45, yMax - 7), S, B 21060 Locate MenuLeft, 1 21080 Return 21100 ' -------------------- SHOW MESSAGE BOX -------------------- 21120*MsgBox2 21140 'Line (45, 17)-(xMax - 45, yMax - 17), R, BF 21150 Cls 21160 Line (45, 17)-(xMax - 45, yMax - 17), S, B 21180 Locate 60, 3 21200 Return 21400 ' -------------------- SHOW FILE LIST -------------------- 21420*ShowList 21640 flCurPage = Int(fCur / RowsPerPage) 21660 flTopRow = flCurPage * RowsPerPage 21680 flBottomRow = (flCurPage + 1) * RowsPerPage - 1 21700 If flBottomRow >= fCnt Then flBottomRow = fCnt - 1 21720 Cls 21740 If flTopRow > flBottomRow Then *ShowList20 21760 For i = flTopRow To flBottomRow 21780 Print " " + f$(i) 21800 Next i 21810*ShowList20 21820 flCurRow = fCur - (flCurPage * RowsPerPage) 21840 flBoxTop = flCurRow * RowHeight 21860 flBoxBottom = flBoxTop + RowHeight - 1 21920 GoSub *ShowName 21940 Return 22000 ' -------------------- SHOW FILE NAME -------------------- 22020*ShowName 22040 'Line (0, flBoxTop)-(xMax, flBoxBottom), R, BF 22060 Locate 0, flCurRow ' <-- VB uses flBoxTop 22100 Print " " + f$(fCur) + " " 22120 Line (0, flBoxTop)-(xMax, flBoxBottom + 1), S, B ' *** Should this be X? 22140 Return 22200 ' -------------------- OPEN FILE -------------------- 22220*FileOpen 22240 If f$(fCur) > "" Then *FileOpen20 22250 ' file name may not be blank 22260 Beep 22280 Return 22300*FileOpen20 22320 fName$ = "E:objd_" + Right$(Str$(fCur + 100), 2) 22340 lCnt = 0 22360 tCnt = 0 22370 GoSub *MsgBox2 22380 Print "Opening File ..." 22400 On Error Goto *FileOpen60 22420 Open fName$ For Input As #1 22460 On Error Goto *Trap 22480 If LOF(1) < 1 Then *FileOpen40 22500 Input #1, lCnt 22510 If lCnt = 0 Then *FileOpen30 22520 For i = 0 To lCnt - 1 22540 Input #1, l$(i) 22560 For j = 0 To Val(l$(i)) - 1 22580 Input #1, lx$(i, j) 22600 Input #1, ly$(i, j) 22620 Next 22640 Next 22650*FileOpen30 22660 Input #1, tCnt 22670 If tCnt = 0 Then *FileOpen40 22680 For i = 0 To tCnt - 1 22700 Input #1, tx$(i) 22720 Input #1, ty$(i) 22740 Input #1, t$(i) 22760 Next 22780*FileOpen40 22800 Close #1 22820*FileOpen60 22840 On Error Goto *Trap 22940 MainState$ = "E" ' <-- Switch to Editor Mode 22960 ChangeCount = 0 22980 CurObj = 0 23000 mx = Int(xMax / 2) 23020 my = Int(yMax / 2) 23040 GoSub *ShowEditor 23060 Return 23200 ' -------------------- SHOW EDITOR -------------------- 23220*ShowEditor 23240 Cls 23245 ' --- Draw Lines --- 23250 If lCnt < 1 Then *ShowEditor20 23260 For i = 0 To lCnt - 1 23270 If Val(l$(i)) < 2 Then *ShowEditor10 23280 For j = 1 To Val(l$(i)) - 1 23300 Line (Val(lx$(i, j - 1)), Val(ly$(i, j - 1)))-(Val(lx$(i, j)), Val(ly$(i, j))) 23320 Next 23325*ShowEditor10 23330 Next 23340*ShowEditor20 23345 ' --- Draw Text --- 23350 If tCnt < 1 Then *ShowEditor40 23360 For i = 0 To tCnt - 1 23380 'sWidth = GLen(t$(i)) 23420 'Line (Val(tx$(i)) - 2, Val(ty$(i)) * RowHeight)-(Val(tx$(i)) + sWidth, (Val(ty$(i))+1) * RowHeight), R, BF 23430 Locate Val(tx$(i)), Val(ty$(i)) 23480 Print t$(i) 23500 Next 23510*ShowEditor40 23520 If MainState$ <> "T" Then *ShowEditor60 23540 'GoSub *Highlight ' <-- highlight 23560 GoSub *ShowTextBox 23580 Return 23600*ShowEditor60 23620 If MainState$ <> "L" Then *ShowEditor80 23640 GoSub *FlipMouse 23660 Return 23680*ShowEditor80 23700 GoSub *Highlight ' <-- highlight 23720 GoSub *FlipMouse 23740 Return 23800 ' -------------------- TOGGLE MOUSE -------------------- 23820*FlipMouse 23840 ' Toggles mouse on and off. 23860 Line (mx, my - 2)-(mx, my + 2), X 23880 Line (mx - 2, my)-(mx + 2, my), X 23900 If MainState$ <> "L" Then Return 23920 Line (xStart, yStart)-(mx, my), X 23960 Return 24000 ' -------------------- ESCAPE EDITOR -------------------- 24020*EscapeEditor 24040 If ChangeCount <= 3 Then *EscapeEditor10 24050 ' --- Show Save Message --- 24060 MsgState$ = "S" 24080 GoSub *ShowMsgBox 24100 Print "Are you sure you want to quit" 24120 Locate MenuLeft, 2 24140 Print "and loose your changes?" 24160 Locate MenuLeft, 5 24180 Print "Yes [Enter] - No [Esc]" 24200 Return 24220*EscapeEditor10 24240 MainState$ = "F" 24260 GoSub *ShowList 24280 Return 24400 ' -------------------- START NEW LINE -------------------- 24420*StartNewLine 24440 If lCnt <= lMax Then *StartNewLine10 24460 GoSub *ShowMsgBox 24465 Print "No room for new lines." 24470 Locate MenuLeft, 5 24475 Print "OK [Enter]" 24480 MsgState$ = "X" 24490 Beep 24500 Return 24520*StartNewLine10 24540 xStart = mx 24560 yStart = my 24580 l$(lCnt) = Str$(1) ' <-- Count of points 24600 lx$(lCnt, 0) = Str$(xStart) 24620 ly$(lCnt, 0) = Str$(yStart) 24640 lCnt = lCnt + 1 24660 CurObj = lCnt 24680 MainState$ = "L" ' <-- Switch to Line mode 24700 Return 24800 ' -------------------- ADD LINE SEGMENT -------------------- 24820*AddSegment 24830 GoSub *FlipMouse 24840 ChangeCount = ChangeCount + 1 24860 xStart = mx 24880 yStart = my 24900 i = CurObj - 1 24920 j = Val(l$(i)) 24940 l$(i) = Str$(j + 1) 24960 lx$(i, j) = Str$(mx) 24980 ly$(i, j) = Str$(my) 25000 Line (Val(lx$(i, j - 1)), Val(ly$(i, j - 1)))-(mx, my), S 25010 GoSub *FlipMouse 25020 If j < lPntMax Then Return 25040 Beep 25060 MainState$ = "E" 25080 GoSub *ShowEditor 25120 Return 25130 ' -------------------- CANCEL LINE -------------------- 25140*CancelLine 25150 CurObj = 0 25160 lCnt = lCnt - 1 25170 MainState$ = "E" 25180 Return 25200 ' -------------------- HIGHLIGHT CURRENT OBJECT -------------------- 25220*Highlight 25260 If CurObj = 0 Then Return 25340 If CurObj > lCnt Then *Highlight20 25345 ' --- Object is a line --- 25360 i = CurObj - 1 25380 For j = 0 To Val(l$(i)) - 1 25400 Line (Val(lx$(i, j)) - 2, Val(ly$(i, j)) - 2)-(Val(lx$(i, j)) + 2, Val(ly$(i, j)) + 2), X, B 25420 Next 25460 Return 25480*Highlight20 25500 ' --- Object is text --- 25520 i = CurObj - lCnt - 1 25540 sWidth = GLen(t$(i)) 25580 Line (Val(tx$(i)) - 2, Val(ty$(i)) * RowHeight)-(Val(tx$(i)) + sWidth, (Val(ty$(i))+1) * RowHeight), X, B 25620 Return 25800 ' -------------------- DELETE OBJECT -------------------- 25820*DelObj 25840 'To delete an object from the middle of the array, 25860 'copy the last object in the array into the deleted object's place. 25880 If CurObj = 0 Then Return 25940 If CurObj > lCnt Then *DelObj40 25960 lCnt = lCnt - 1 25980 i = CurObj - 1 26000 l$(i) = l$(lCnt) 26020 For j = 0 To lPntMax 26040 lx$(i, j) = lx$(lCnt, j) 26060 ly$(i, j) = ly$(lCnt, j) 26080 Next 26085 Goto *DelObj60 26090*DelObj40 26120 tCnt = tCnt - 1 26140 i = CurObj - lCnt - 1 26160 tx$(i) = tx$(tCnt) 26180 ty$(i) = ty$(tCnt) 26200 t$(i) = t$(tCnt) 26220*DelObj60 26240 CurObj = 0 26260 ChangeCount = ChangeCount + 1 26280 Return 26400 ' -------------------- SAVE FILE -------------------- 26420*SaveFile 26430 GoSub *MsgBox2 26440 Print "Saving File ..." 26460 Open fName$ For Output As #1 26465 ' --- Save Lines --- 26480 Print#1, lCnt 26490 If lCnt = 0 Then *SaveFile20 26500 For i = 0 To lCnt - 1 26520 Print#1, l$(i) 26540 For j = 0 To Val(l$(i)) - 1 26560 Print#1, lx$(i, j) 26580 Print#1, ly$(i, j) 26600 Next 26620 Next 26630*SaveFile20 26635 ' --- Save Text --- 26640 Print#1, tCnt 26650 If tCnt = 0 Then *SaveFile40 26660 For i = 0 To tCnt - 1 26680 Print#1, tx$(i) 26700 Print#1, ty$(i) 26720 Print#1, t$(i) 26740 Next 26750*SaveFile40 26760 Close #1 26780 ' --- Is this a new file? --- 26800 If fCur = fCnt Then fCnt = fCnt + 1 26820 GoSub *SaveList 26860 MainState$ = "F" 26880 Return 27000 ' -------------------- SAVE FILE LIST NAMES -------------------- 27020*SaveList 27060 If fCnt = 0 Then Return 27070 'GoSub *MsgBox2 27075 'Print "Saving File List ..." 27080 Open "E:objd_fl" For Output As #1 27100 Print#1, fCnt 27120 For i = 0 To fCnt - 1 27140 Print#1, f$(i) 27160 Next i 27180 Close #1 27200 Return 27300 ' -------------------- NEW TEXT -------------------- 27320*NewText 27330 If tCnt <= tMax Then *NewText20 27340 GoSub *ShowMsgBox 27350 Print "No room for new text." 27360 Locate MenuLeft, 5 27370 Print "OK [Enter]" 27375 MsgState$ = "X" 27380 Beep 27400 Return 27420*NewText20 27460 t$(tCnt) = "" 27500 xStart = mx 27520 yStart = Int(my/RowHeight) 27540 MainState$ = "T" 27560 GoSub *ShowTextBox 27580 Return 27700 ' -------------------- SHOW TEXT BOX -------------------- 27720*ShowTextBox 27740 Line (xStart - 2, yStart * RowHeight)-(xMax, (yStart+1) * RowHeight), R, BF 27760 Locate xStart, yStart 27800 Print t$(tCnt) 27820 Line (xStart - 2, yStart * RowHeight)-(xMax, (yStart+1) * RowHeight), S, B 27840 Return 28000 ' -------------------- KEEP TEXT ENTRY -------------------- 28020*KeepText 28040 MainState$ = "E" 28060 tx$(tCnt) = Str$(xStart) 28080 ty$(tCnt) = Str$(yStart) 28120 tCnt = tCnt + 1 28140 CurObj = lCnt + tCnt 28160 GoSub *ShowEditor 28180 Return 28300 ' -------------------- SHOW HELP -------------------- 28320*ShowHelp 28340 MsgState$ = "H" 28360 Cls 28380 For i = hCur To hCur+6 28390 If i > hMax Then *ShowHelp20 28400 Print h$(i) 28420 Next 28430*ShowHelp20 28440 Return 29000 ' -------------------- ERROR HANDLER -------------------- 29010*Trap 29030 GoSub *ShowMsgBox 29040 Print "Your request did not complete." 29050 Locate MenuLeft, 2 29060 Print "#" + Str$(Ern) + " on line " + Str$(Erl) + " state " + MainState$ + MsgState$ 29070 Locate MenuLeft, 3 29080 If Doing$ > "" Then Print "Occured during " + Doing$ + "." 29100 Locate MenuLeft, 4 29110 If Ern = 95 Then Print "Bad file name." 29115 If Ern = 31 Then Print "Array w/o DIM." 29120 If Ern = 10 Then Print "Syntax error." 29125 If Ern = 33 Then Print "Data out of range" 29130 If Ern = 20 Then Print "Overflow" 29135 If Ern = 21 Then Print "Division by Zero" 29140 If Ern = 22 Then Print "Illegal function call" 29145 If Ern = 32 Then Print "Subscript out of range" 29250 If Ern = 53 Then Print "Out of data" 29255 If Ern = 60 Then Print "Out of memory" 29260 If Ern = 87 Then Print "Input past end" 29265 If Ern = 90 Then Print "Type mismatch" 29270 If Ern = 100 Then Print "Low Battery error" 29280 Locate MenuLeft, 5 29290 Print "OK [Enter]" 29300 MsgState$ = "X" 29340 Resume *Main 29360 ' ----------------------------------------------- 29500 ' ----------------------------------------------- 29510 Data " --- HELP ---" 29520 Data "Press down arrow for more help. Press [ESC] to " 29530 Data "continue. To return to Help, press [MENU] then 1." 29540 Data "" 29615 ' ----/----1----/----2----/----3----/----4----/----5----/----6 29620 Data " --- QUICK START - WALK THROUGH --- " 29630 Data "This program starts with a blank file list. " 29640 Data "Type a name for a file and press [ENTER]. " 29650 Data "Now you are in the editor. Press the arrow keys " 29660 Data "to move the cross. Press [L] to start a new line. " 29680 Data "Move the cross and press [L] again to draw " 29690 Data "one segment of your line. Draw a few more " 29700 Data "segments and press [Enter] to finish the line. " 29710 Data "Press [T], type a word and press [ENTER] to add " 29720 Data "some text. Press Page Up (aka Prev) to highlight " 29725 Data "an object. Press [Del] to delete it. Press " 29730 Data "[Enter] again to save the drawing. " 29735 Data "" 29740 Data " --- TIPS & FAQs --- " 29750 Data "- [MENU] changes while drowing a line or text. " 29760 Data "- In editor, page up/down to select objects. " 29770 Data "- Beeps for limits and invalid keys. " 29780 Data "" 29785 Data "OBJECT DRAW V1.0 10/22/99 " 29790 Data " --- AUTHOR --- " 29800 Data "Chuck Newman - cnewman@mail.com " 29810 Data "NewmanServices.com - 973-228-5753 " 29820 Data "ASP VBScript JavaScript HTML VB SQL " 29830 Data "" 29840 Data "" 29850 Data "" 29860 Data "" 29870 Data ""