|
Post by donmalone on Nov 30, 2018 10:26:25 GMT -5
Just messing with a simple program and during the process of wanting to check out the creation of a sting to fill a list box. I wanted to put a couple of break points in to examine my code.
The problem only arises when I use the debugging button.
I had a few lines of code to populate a string if the first two records were not loaded in. The program had the option to jump to the [mainmenu] if the records were loaded. The code runs fine without an error, but if I debug. I get a 'Branch label not found' message somewhere in my code. I have tried changing the name as well as copy an paste, but the error still occurs. Is this a persistent bug from the earlier version that was not correctable for whatever reason or am I not understanding how the Goto command functions under the debugger.
|
|
|
Post by Rod on Nov 30, 2018 13:00:54 GMT -5
If a branch label is not found it is because it is misspelt, does not exist or is not in scope. So are you in a Sub and expecting to find an external branch label? Or is it simply misspelt?
|
|
|
Post by donmalone on Nov 30, 2018 14:01:05 GMT -5
It may be a scope issue. The label it cannot find is a branch label under the second menu option.
It might be considered a subroutine, but if that is the case, would it not run at all? The error still pops up under the debugger, but not when run normally.
I would post the code, but I have already reworked it some and removed the code that would create two records of data if the file was an empty file So I can see my file structure.
I can try and produce some lite code to see if it does the same thing. Be warned that my code is ugly. Not professional or even a decent amateur effort. I am a brute force basic hack. I make it work but I would never share my code because it would be done better by someone else.
Thank you for your reply.
|
|
|
Post by Rod on Nov 30, 2018 14:14:57 GMT -5
My code initially is ugly so stop worrying about that. Real code begets real answers and no judgement.
|
|
|
Post by donmalone on Dec 1, 2018 0:27:16 GMT -5
Here it is. The beginning stages of a task manager I want to write.
I am running Liberty Basic 4.5.1 Registered
Just running from the editor. I get no errors when I press the 'View due tasks" button from the main menu. This and exit and save buttons are the only active buttons currently. Run from the debug button. And it says the label can not be found for "ViewTasks".
Not the end of the world since I know it will run. I have not touched Liberty Basic in a while and I am working on learning slowly using the help and the searchable help from the contest.
Thank you for taking the time to respond. Code below. Please be kind.
nomainwin global aa aa=10000 bb=4 DataVer$="1.2"
' required for file command ' dim info$(10, 10)
dim tRec(aa), tTask$(aa), tCompleted(aa), tNextDue(aa), tPriority(aa)
dim bRec(bb),bRecName$(bb), bRecDays(bb) data 1,"Day(s)",1,2,"Week(s)",7,3,"Month(s)",30,4,"Year(s)",365 for a=1 to bb read c read d$ read e bRec(a)=c bRecName$(a)=d$ bRecDays(a)=e next a
gosub [LoadData]
if tTask$(1)<>"" then
tRec(1)=1 tTask$(1)="task number 1" tCompleted(1)=date$("6/11/2018") tNextDue(1)=date$("6/11/2018")+180 tPriority(1)=1
tRec(2)=2 tTask$(2)="Test task 2" tCompleted(2)=date$("11/21/2018") tNextDue(2)=date$("11/21/2018")+30 tPriority(2)=3 end if
[MainMenu]
'Form created with the help of Freeform 3 v07-31-2015 'Generated on Nov 27, 2018 at 06:29:54
[setup.mainmenu.Window]
'-----Begin code for #mainmenu
WindowWidth = 740 WindowHeight = 475 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
ForegroundColor$ = "blue"
'-----Begin GUI objects code
statictext #mainmenu.statictext1, "Select desired option", 232, 5, 127, 20 button #mainmenu.exitptogram, "Exit program", [mmExitProgram], UL, 480,380 button #mainmenu.savedata, "Save Data", [mmSaveData], UL, 50,50,200,25 button #mainmenu.addtask, "Add new task(s)", [mmaddtask], ul, 50,100,200,25 button #mainmenu.checkofftask, "Mark off finished task(s)",[mmmarktask], ul , 50, 150, 200,25 button #mainmenu.viewjoblist, "View due tasks", [mmviewtasks],ul, 50,200,200,25 '-----End GUI objects code
open "TaskManager Main Menu" for window as #mainmenu print #mainmenu, "font ms_sans_serif 10"
wait
' manimenu loops [mmExitProgram] gosub [ExitProgram] wait
[mmSaveData] gosub [SaveData] wait
[mmaddtask] wait
[mmmarktask] wait
[mmviewtasks] goto [ViewTasks]
wait
close #mainmenu
end
' Subroutines for gosubs
[LoadData] 'See if file exists open "TaskManager.dat" for append as #5 fe=lof(#5) close #5 if fe>1 then
print "Loading Data" open "TaskManager.dat" for input as #1
input #1, tempaa if tempaa <> aa then aa= tempaa ' Data version for added data streams input #1, TempDataVer$
for a= 1 to aa input #1, tRec(a), tTask$(a), tCompleted(a), tNextDue(a) if TempDataVer$>="1.2" then input #1, tPriority(a) end if next a close #1 else print "File not found." end if
return wait
[SaveData] print "Saving Data" open "TaskManager.dat" for output as #2 print #2, aa print #2, DataVer$
for a= 1 to aa print #2, tRec(a) print #2, tTask$(a) print #2, tCompleted(a) print #2, tNextDue(a) print #2, tPriority(a) next a close #2
return wait
[ViewTasks] [setup.viewtasks.Window]
dim TaskArray$(aa) for ta=1 to aa if tTask$(ta)<>"" then taa$=str$(tNextDue(ta)-tCompleted(ta)) tab$=tTask$(ta) tac$=str$(tRec(ta)) lentaa=(10-len(taa$)) TaskArray$(ta)=taa$+space$(lentaa)+tab$+" <"+tac$+">" end if next ta
'-----Begin code for #mainmenu
WindowWidth = 640 WindowHeight = 480 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
ForegroundColor$ = "black"
'-----Begin GUI objects code
statictext #viewtasks.statictext1, "View Tasks", 232, 5, 127, 20 button #viewtasks.button1, "View All Tasks", [mmViewAllTasks], UL, 50,50,200,25 button #viewtasks.button2, "View Due Tasks", [mmViewDueTasks], UL, 50,100,200,25 button #viewtasks.button3, "View All Tasks by Due Date", [mmAllTasksByDateDue], ul, 50,150,200,25 button #viewtasks.closewindow, "Close Task View Window",[mmCloseTaskWindow], ul , 50, 200, 200,25 LISTBOX #viewtasks.listbox1, TaskArray$(), [tvSelectRecord], 260, 30, 250, 400 'button #viewtasks.viewjoblist, "unused", [mmviewtasks],ul, 275,50,200,200 '-----End GUI objects code
open "View Tasks" for window as #viewtasks print #viewtasks, "font ms_sans_serif 10"
wait [mmViewAllTasks] wait [mmViewDueTasks] wait [mmAllTasksByDateDue] wait [mmCloseTaskWindow] close #viewtasks wait [tvSelectRecord]
wait
[ExitProgram] 'confirm "Save Data and Close?"; answer$ 'if answer$ = "no" then [MainMenu] gosub [SaveData] 'notice "Data Saved" close #mainmenu 'notice "Mainmenu closed" end
|
|
|
Post by metro on Dec 1, 2018 3:00:25 GMT -5
For some reason the debugger wants to see a line of code between two branch labels
I changed this
[ViewTasks] [setup.viewtasks.Window]
To this
[ViewTasks] a=b ' USE EITHER ONE 'print "I've made it to here" [setup.viewtasks.Window]
no error in debugger
|
|
|
Post by Rod on Dec 1, 2018 3:26:17 GMT -5
Ah, that is an old bug. I thought that had been fixed long ago.
|
|
|
Post by metro on Dec 1, 2018 4:45:34 GMT -5
I realise your posted code is probably not the complete program
I'm a long way short of a good coder but can I suggest you use the trapclose command on each window also if you make the viewtasks window dialog_modal the user cannot click on any button on the mainwindow and set off errors. and pressing escape when viewtasks has focus will close it and drop back to mainwindow
I hope you don't mind but here are my changes
don't forget to save the copied code first, or it will throw an error trying to open a file
nomainwin global aa aa=10000 bb=4 DataVer$="1.2"
' required for file command ' dim info$(10, 10)
dim tRec(aa), tTask$(aa), tCompleted(aa), tNextDue(aa), tPriority(aa)
dim bRec(bb),bRecName$(bb), bRecDays(bb) data 1,"Day(s)",1,2,"Week(s)",7,3,"Month(s)",30,4,"Year(s)",365 for a=1 to bb read c read d$ read e bRec(a)=c bRecName$(a)=d$ bRecDays(a)=e next a
gosub [LoadData]
if tTask$(1)<>"" then
tRec(1)=1 tTask$(1)="task number 1" tCompleted(1)=date$("6/11/2018") tNextDue(1)=date$("6/11/2018")+180 tPriority(1)=1
tRec(2)=2 tTask$(2)="Test task 2" tCompleted(2)=date$("11/21/2018") tNextDue(2)=date$("11/21/2018")+30 tPriority(2)=3 end if
[MainMenu]
'Form created with the help of Freeform 3 v07-31-2015 'Generated on Nov 27, 2018 at 06:29:54
[setup.mainmenu.Window]
'-----Begin code for #mainmenu
WindowWidth = 740 WindowHeight = 475 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
ForegroundColor$ = "blue"
'-----Begin GUI objects code
statictext #mainmenu.statictext1, "Select desired option", 232, 5, 127, 20 button #mainmenu.exitptogram, "Exit program", [mmExitProgram], UL, 480,380 button #mainmenu.savedata, "Save Data", [mmSaveData], UL, 50,50,200,25 button #mainmenu.addtask, "Add new task(s)", [mmaddtask], ul, 50,100,200,25 button #mainmenu.checkofftask, "Mark off finished task(s)",[mmmarktask], ul , 50, 150, 200,25 button #mainmenu.viewjoblist, "View due tasks", [mmviewtasks],ul, 50,200,200,25 '-----End GUI objects code
open "TaskManager Main Menu" for window as #mainmenu print #mainmenu, "font ms_sans_serif 10" print #mainmenu, "trapclose [ExitProgram]" wait
' manimenu loops [mmExitProgram] gosub [ExitProgram] wait
[mmSaveData] gosub [SaveData] wait
[mmaddtask] wait
[mmmarktask] wait
[mmviewtasks] goto [ViewTasks] 'goto [setup.viewtasks.Window] wait
'close #mainmenu
'end
' Subroutines for gosubs
[LoadData] 'See if file exists open "TaskManager.dat" for append as #5 fe=lof(#5) close #5 if fe>1 then
print "Loading Data" open "TaskManager.dat" for input as #1
input #1, tempaa if tempaa <> aa then aa= tempaa ' Data version for added data streams input #1, TempDataVer$
for a= 1 to aa input #1, tRec(a), tTask$(a), tCompleted(a), tNextDue(a) if TempDataVer$>="1.2" then input #1, tPriority(a) end if next a close #1 else print "File not found." end if
return wait
[SaveData] print "Saving Data" open "TaskManager.dat" for output as #2 print #2, aa print #2, DataVer$
for a= 1 to aa print #2, tRec(a) print #2, tTask$(a) print #2, tCompleted(a) print #2, tNextDue(a) print #2, tPriority(a) next a close #2
return wait
[ViewTasks] a=b 'print "I've made it to here" [setup.viewtasks.Window]
dim TaskArray$(aa) for ta=1 to aa if tTask$(ta)<>"" then taa$=str$(tNextDue(ta)-tCompleted(ta)) tab$=tTask$(ta) tac$=str$(tRec(ta)) lentaa=(10-len(taa$)) TaskArray$(ta)=taa$+space$(lentaa)+tab$+" <"+tac$+">" end if next ta
'-----Begin code for #mainmenu
WindowWidth = 640 WindowHeight = 480 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
ForegroundColor$ = "black"
'-----Begin GUI objects code
statictext #viewtasks.statictext1, "View Tasks", 232, 5, 127, 20 button #viewtasks.button1, "View All Tasks", [mmViewAllTasks], UL, 50,50,200,25 button #viewtasks.button2, "View Due Tasks", [mmViewDueTasks], UL, 50,100,200,25 button #viewtasks.button3, "View All Tasks by Due Date", [mmAllTasksByDateDue], ul, 50,150,200,25 button #viewtasks.closewindow, "Close Task View Window",[mmCloseTaskWindow], ul , 50, 200, 200,25 LISTBOX #viewtasks.listbox1, TaskArray$(), [tvSelectRecord], 260, 30, 250, 400 'button #viewtasks.viewjoblist, "unused", [mmviewtasks],ul, 275,50,200,200 '-----End GUI objects code
open "View Tasks" for Dialog_modal as #viewtasks print #viewtasks, "font ms_sans_serif 10"
print #viewtasks, "trapclose [mmCloseTaskWindow]"
h2=hWnd(#viewtasks) left=UpperLeftX :top=UpperLeftY'+40
CALL MoveWindow h2,left,top,640,480
wait [mmViewAllTasks] wait [mmViewDueTasks] wait [mmAllTasksByDateDue] wait [mmCloseTaskWindow] close #viewtasks wait [tvSelectRecord]
wait
[ExitProgram] 'confirm "Save Data and Close?"; answer$ 'if answer$ = "no" then [MainMenu] gosub [SaveData] 'notice "Data Saved" close #mainmenu 'notice "Mainmenu closed" end
SUB MoveWindow hWnd,x,y,w,h CallDLL #user32, "MoveWindow",hWnd As long, x As long, y As long,_ w As long, h As long, 1 As boolean, r As boolean END SUB
|
|
|
Post by donmalone on Dec 1, 2018 6:06:40 GMT -5
Thank you for the information. That makes sense now.
I was not overly worried about the structure of my app and using trap close since it was only for me. I know that there are already task manager apps out there. I just wanted to create my own to suit my needs. I do not use the debugger much and was looking to see how to create my consistent spacing for my text going into the listbox or I never would have noticed.
Thanks again
Don Malone
|
|
|
Post by Carl Gundel on Dec 1, 2018 14:41:18 GMT -5
Ah, that is an old bug. I thought that had been fixed long ago. Me too.
|
|