Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yazz committed Dec 30, 2024
1 parent 191e255 commit d7415ac
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 59 deletions.
2 changes: 1 addition & 1 deletion comments.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------------/
//
// /-------------------------------------/
// / FUNCTION functionName /
// / functionName( ... ) { ... } /
// /-------------------------------------/
//
//----------------------------------------------------------------------------/
Expand Down
113 changes: 55 additions & 58 deletions public/go.html
Original file line number Diff line number Diff line change
Expand Up @@ -13573,11 +13573,13 @@ <h1 style='width:100%;vertical-align:top;display:inline-block;font-size:100px; t
//----------------------------------------------------------------------------------/
//
// /-------------------------------------/
// / FUNCTION startDebug /
// / startDebug( ... ) { ... } /
// /-------------------------------------/
//
//----------------------------------------------------------------------------/
// This is in the code when we want to start the recording of some code.
// This is in the code when we want to start the recording of some code for
// debug purposes.
//
// This is executed either from the start of a function, or from an event
// being called in HTML. If this is called from the start of a function
// then do not forget to close off the call with "endOfDebugSection( )"
Expand Down Expand Up @@ -13618,66 +13620,61 @@ <h1 style='width:100%;vertical-align:top;display:inline-block;font-size:100px; t
// store the debug code
//
let startLineNumber = sourceForFunction.lineNumber - 1
//let codeSectionRecord1 = yz.uiDb.sqlui1("select * from ui_table_debug_code_sections where fk_debug_id = ?",
// [debugId])
//if (!codeSectionRecord1) {
let indexOfDebugId = sourceForFunction.lineText.indexOf(debugId)
let upToDebugId = sourceForFunction.lineText.substring(indexOfDebugId)
let indexToEndOfDebugId = upToDebugId.indexOf("\")")
let afterDebugId = upToDebugId.substring(indexToEndOfDebugId)
let lengthOfRestOfLine = afterDebugId.length

// start debug section is in the code
if (lengthOfRestOfLine < 5) {
startLineNumber = sourceForFunction.lineNumber - 1
let previousLine = yz.debug.linesOfSourceFile[sourceForFunction.fileName][startLineNumber - 1]
let fnName = yz.uiDb.getFnNameFromLine( previousLine )
let allText = ""
let indexOfDebugId = sourceForFunction.lineText.indexOf(debugId)
let upToDebugId = sourceForFunction.lineText.substring(indexOfDebugId)
let indexToEndOfDebugId = upToDebugId.indexOf("\")")
let afterDebugId = upToDebugId.substring(indexToEndOfDebugId)
let lengthOfRestOfLine = afterDebugId.length

// start debug section is in the code
if (lengthOfRestOfLine < 5) {
startLineNumber = sourceForFunction.lineNumber - 1
let previousLine = yz.debug.linesOfSourceFile[sourceForFunction.fileName][startLineNumber - 1]
let fnName = yz.uiDb.getFnNameFromLine( previousLine )
let allText = ""

let readAnotherLine = true
let nextLine
let endLineNumber = startLineNumber
while(readAnotherLine) {
nextLine = yz.debug.linesOfSourceFile[sourceForFunction.fileName][endLineNumber - 1]
if (endLineNumber == yz.debug.linesOfSourceFile[sourceForFunction.fileName].length) {
readAnotherLine = false
} else if (nextLine.indexOf("yz.debug.endOfDebugSection(") != -1) {
endLineNumber ++
readAnotherLine = false
} else {
endLineNumber ++
}
}
for (let lineIndex = startLineNumber; lineIndex <= endLineNumber; lineIndex ++) {
allText += yz.debug.linesOfSourceFile[sourceForFunction.fileName][lineIndex - 1] + "\n"
let readAnotherLine = true
let nextLine
let endLineNumber = startLineNumber
while(readAnotherLine) {
nextLine = yz.debug.linesOfSourceFile[sourceForFunction.fileName][endLineNumber - 1]
if (endLineNumber == yz.debug.linesOfSourceFile[sourceForFunction.fileName].length) {
readAnotherLine = false
} else if (nextLine.indexOf("yz.debug.endOfDebugSection(") != -1) {
endLineNumber ++
readAnotherLine = false
} else {
endLineNumber ++
}
yz.uiDb.sqlui("INSERT INTO ui_table_debug_code_sections ( fk_debug_id , fk_fn_name_id , fn_name , file_name , start_line_number , end_line_number , debug_all_text ) VALUES (?,?,?,?,?,?,?)",
[
debugId,
null,
fnName,
sourceForFunction.fileName,
startLineNumber,
endLineNumber,
allText
])

// debug section is an event
} else {
startLineNumber = sourceForFunction.lineNumber
yz.uiDb.sqlui("INSERT INTO ui_table_debug_code_sections ( fk_debug_id , fk_fn_name_id , fn_name , file_name , start_line_number , end_line_number , debug_all_text ) VALUES (?,?,?,?,?,?,?)",
[
debugId,
null,
null,
sourceForFunction.fileName,
sourceForFunction.lineNumber,
sourceForFunction.lineNumber,
sourceForFunction.lineText.trim()
])
}
for (let lineIndex = startLineNumber; lineIndex <= endLineNumber; lineIndex ++) {
allText += yz.debug.linesOfSourceFile[sourceForFunction.fileName][lineIndex - 1] + "\n"
}
yz.uiDb.sqlui("INSERT INTO ui_table_debug_code_sections ( fk_debug_id , fk_fn_name_id , fn_name , file_name , start_line_number , end_line_number , debug_all_text ) VALUES (?,?,?,?,?,?,?)",
[
debugId,
null,
fnName,
sourceForFunction.fileName,
startLineNumber,
endLineNumber,
allText
])

//}
// debug section is an event
} else {
startLineNumber = sourceForFunction.lineNumber
yz.uiDb.sqlui("INSERT INTO ui_table_debug_code_sections ( fk_debug_id , fk_fn_name_id , fn_name , file_name , start_line_number , end_line_number , debug_all_text ) VALUES (?,?,?,?,?,?,?)",
[
debugId,
null,
null,
sourceForFunction.fileName,
sourceForFunction.lineNumber,
sourceForFunction.lineNumber,
sourceForFunction.lineText.trim()
])
}

//
// insert the trace record
Expand Down

0 comments on commit d7415ac

Please sign in to comment.