@@ -447,6 +447,10 @@ Public Class frmMain
447447 Dim line_no As Match = Regex.Match(m.Value, "[0-9]+" ) 'get the original line number reference
448448 editLine &= line.Substring(curIndex, m.Index + line_no.Index - curIndex) 'copy the line until the match including GOSUB
449449 curIndex = m.Index + line_no.Index + line_no.Length 'position the index after the old line number
450+ If Not matchMap.Contains(line_no.Value.Trim()) Then
451+ Dim lineMatch = Regex.Match(line, "^ *[0-9]+" )
452+ txtLog.Text &= vbCrLf & "Warning: Invalid line reference at line " & lineMatch.Value.Trim() & ": Line " & line_no.Value.Trim() & " does not exist!" & vbCrLf & vbCrLf
453+ End If
450454 editLine &= matchMap(line_no.Value.Trim()) 'add the new line number
451455 Next
452456 editLine &= line.Substring(curIndex, line.Length - curIndex) 'copy the rest of the line untill the end
@@ -457,6 +461,10 @@ Public Class frmMain
457461 If match.Success Then
458462 'The line contains GOTO, GOSUB or THEN followed by constant line number at the end of line.
459463 Dim line_no As Match = Regex.Match(match.Value, "[0-9]+$" ) 'get the original line number reference
464+ If Not matchMap.Contains(line_no.Value.Trim()) Then
465+ Dim lineMatch = Regex.Match(line, "^ *[0-9]+" )
466+ txtLog.Text &= vbCrLf & "Warning: Invalid line reference at line " & lineMatch.Value.Trim() & ": Line " & line_no.Value.Trim() & " does not exist!" & vbCrLf & vbCrLf
467+ End If
460468 line = Regex.Replace(line, "GOTO *[0-9]+$" , "GOTO " & matchMap(line_no.Value.Trim()), RegexOptions.IgnoreCase)
461469 line = Regex.Replace(line, "THEN *[0-9]+$" , "THEN " & matchMap(line_no.Value.Trim()), RegexOptions.IgnoreCase)
462470 changedLines &= line & vbCrLf
0 commit comments