Liberty BASIC Community Forum
« debug-yes;regular-no »

Welcome Guest. Please Login or Register.
Dec 12th, 2017, 08:14am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: debug-yes;regular-no  (Read 117 times)
alincon2001
Guru
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 503
xx debug-yes;regular-no
« Thread started on: Dec 3rd, 2017, 11:08am »

How is it possible for a LB program to run correctly in debug mode, but not in regular mode?
I have a pretty simple program with data input screens, move data to random file record fields, and write the records to the file. I calculate the next record number by diving lof by record length. It all works fine in debug mode, but in regular mode no record is added. No other records are changed by mistake when the add fails.

r.m.
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5585
xx Re: debug-yes;regular-no
« Reply #1 on: Dec 3rd, 2017, 11:14am »

Event handling is different in debug mode. Do you have a timer running? Some code would help.
User IP Logged

alincon2001
Guru
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 503
xx Re: debug-yes;regular-no
« Reply #2 on: Dec 3rd, 2017, 12:21pm »

I have no timers in the program.

r.m

Code:

    open "memberData" for random as #memberFile len = 400
    field #memberFile, 20 as lname$, 20 as fname$, 1 as initial$, 8 as password$, 10 as phone$, 30 as email$, 10 as signDate$, 1 as payMeth, 16 as cardNbr$, 4 as expDate$, _
                      2 as age$, 2 as height$, 3 as weight$, 2 as gndr$, 9 as employed$, 9 as marital$, 9 as race$, 9 as orientation$, 9 as smoking$, _
                      9 as drinking$, 9 as education$, 9 as politics$, 108 as matches$, 12 as acceptSex$, 2 as viewed, 2 as refused, 75 as filler$
    memberNbr = lof(#memberFile)/400

    for n = 1 to memberNbr
        gettrim #memberFile, n
         security$(n) = lname$ + "|" + fname$ + "|" + initial$ + "|" + password$
    next

    call windowCommon 500,410
    menu #main, "FILES",  "FilePrint", [filePrint]
    menu #main, "NEW MEMBER", "Signup", [addMember]
    menu #main, "CURRENT MEMBER", "Seek Matches", [getSeek], "Update File", [retrieveData]
    open "Matchmaker" for window as #main
    #main, "trapclose closeWin"
    wait

 [addMember]
    newOld$ = "new"
    goto [signupWindow]

 [getSeek]
    action$ = "seek"

 [retrieveData]
    call windowCommon 600,300
    statictext #login.statictext2, "Last Name", 80,  32,  65,  20
    textbox #login.tbLname,  60,  57, 130,  25
    statictext #login.statictext4, "First Name", 220,  32,  65,  20
    textbox #login.tbFname, 210,  57, 130,  25
    statictext #login.statictext6, "Initial", 360,  32,  30,  20
    textbox #login.tbInitial, 360,  57,  25,  25
    Stylebits #login.tbInitial, _ES_UPPERCASE, 0, 0, 0     'Uppercase
    statictext #login.statictext8, "Password", 425, 32,  99,  20
    textbox #login.tbPassword, 420, 57, 80,  25
    button #login.btn1, "Accept Data", [loginAccept], UL 300,220

    open "Log In" for dialog_Modal as #login
    #login, "trapclose [personalWindow]"
    call tbLimit hwnd(#login.tbLname),20
    call tbLimit hwnd(#login.tbFname),20
    call tbLimit hwnd(#login.tbInitial),1
    call tbLimit hwnd(#login.tbPassword),8
    #login.tbLname, "!setfocus"
    wait

 [loginAccept]
    #login.tbLname, "!contents? x$" : log.lname$ = capTize$(x$)
    #login.tbFname, "!contents? x$" : log.fname$ = capTize$(x$)
    #login.tbInitial, "!contents? log.initial$"
    #login.tbPassword, "!contents? log.password$"
    log.compare$ = log.lname$ + "|" + log.fname$ + "|" + log.initial$ + "|" + log.password$
    for recNbr = 1 to memberNbr
         if security$(recNbr) = log.compare$ then exit for
    next
    if recNbr > memberNbr then
        notice "Login Failed"
        wait
    end if
    get #memberFile, recNbr
    newOld$ = "old"
    close #login
    if action$ = "seek" then
      action$ = "" : goto [seekMatches]
    end if

 


Code:

 [saveMemberData]
    confirm "Do you want to save all your data?"; answer$ 
    if answer$ = "no" then wait
    if newOld$ = "new" then
        memberNbr = memberNbr + 1
        recNbr = memberNbr      'found record number to update
    end if
    notice "newOld$ "; newOld$
    notice "Record Nbr "; str$(recNbr)
    put #memberFile, recNbr
    wait

 
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5585
xx Re: debug-yes;regular-no
« Reply #3 on: Dec 3rd, 2017, 2:41pm »

Try bypassing all the confirm and notice commands. Just save the file without confirm or notice, does that work?
User IP Logged

tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1708
xx Re: debug-yes;regular-no
« Reply #4 on: Dec 3rd, 2017, 2:56pm »

Not sure it it's related but summing your FIELDS lengths I got 389, not 400.
User IP Logged

damned Dog in the Manger
alincon2001
Guru
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 503
xx Re: debug-yes;regular-no
« Reply #5 on: Dec 3rd, 2017, 4:29pm »

The notice commands tell me that the record count is correct and that I am adding, not changing a record. I always like to confirm before writing.
I don't see how either can cause the results I am getting.

I just re-checked the record size and I got 400.

r.m.
User IP Logged

tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1708
xx Re: debug-yes;regular-no
« Reply #6 on: Dec 4th, 2017, 12:18am »

Quote:
I just re-checked the record size and I got 400.

OK I got 400 second time too
User IP Logged

damned Dog in the Manger
Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5585
xx Re: debug-yes;regular-no
« Reply #7 on: Dec 4th, 2017, 01:47am »

Please try and remove confirm and notice from the program flow. Does it then work?

Confirm and notice both interfere with the program flow, both have been associated with bugs in the past.
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5585
xx Re: debug-yes;regular-no
« Reply #8 on: Dec 4th, 2017, 04:39am »

I extracted some runnable code from your posting. It runs without error for me either in normal mode or debug mode.

Code:
    open "test.dat" for random as #memberFile len = 400
    field #memberFile, 20 as lname$, 20 as fname$, 1 as initial$, 8 as password$, 10 as phone$, 30 as email$, 10 as signDate$, 1 as payMeth, 16 as cardNbr$, 4 as expDate$, _
                      2 as age$, 2 as height$, 3 as weight$, 2 as gndr$, 9 as employed$, 9 as marital$, 9 as race$, 9 as orientation$, 9 as smoking$, _
                      9 as drinking$, 9 as education$, 9 as politics$, 108 as matches$, 12 as acceptSex$, 2 as viewed, 2 as refused, 75 as filler$

    for n= 1 to 4
        lname$="Rod";n
        put #memberFile, n
    next
    memberNbr=lof(#memberFile)/400
    newOld$="new"




[saveMemberData]
    confirm "Do you want to save all your data?"; answer$ 
    if answer$ = "no" then wait
    if newOld$ = "new" then
        memberNbr = memberNbr + 1
        recNbr = memberNbr      'found record number to update
    end if
    notice "newOld$ "; newOld$
    notice "Record Nbr "; str$(recNbr)
    put #memberFile, recNbr
    print lof(#memberFile)/400
    close #memberFile
    end
 


I just wonder whether the file name you use should have an .extension. I expect the problem is some other outstanding event being handled while the confirm or notice commands are being handled.

Does it happen every time or randomly?

You might also try just adding one to the record number, perhaps the code is racing with the file handler and not getting the correct LOF. Is the new record overwriting the last record when it errors?
« Last Edit: Dec 4th, 2017, 04:42am by Rod » User IP Logged

alincon2001
Guru
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 503
xx Re: debug-yes;regular-no
« Reply #9 on: Dec 4th, 2017, 09:08am »

changed file name to memberfile.rdm
omitted confirm and notice commands

same result

r.m.
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5585
xx Re: debug-yes;regular-no
« Reply #10 on: Dec 4th, 2017, 10:01am »

Can you supply some code that will run and show the problem. If we had code that failed for you it would be easier to help.

Does the runnable code I posted work for you?
User IP Logged

alincon2001
Guru
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 503
xx Re: debug-yes;regular-no
« Reply #11 on: Dec 5th, 2017, 11:24am »

well duh!
When I changed from this
Code:
open "Matchmaker" for the window as #main
    #main, "trapclose closeWin"

sub closeWin win$
    close #win$ 
    end sub

 

to this
Code:
open "Matchmaker" for window as #main
    #main, "trapclose [endPgm]"
    wait

 [endPgm]
    close #memberFile
    close #main
    end
 


program works fine.
r.m.
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5585
xx Re: debug-yes;regular-no
« Reply #12 on: Dec 5th, 2017, 2:06pm »

So in the first you did not close #memberfile and did not end the program you just close #main.

In the second you closed both the #memberfile and the #main and you ended the program.

Quite a difference.
« Last Edit: Dec 5th, 2017, 2:08pm by Rod » User IP Logged

alincon2001
Guru
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 503
xx Re: debug-yes;regular-no
« Reply #13 on: Dec 5th, 2017, 2:10pm »

What I'm wondering now is why did I get no error message about not closing the #memberFile. I would never have had to start this thread.

r.m.
User IP Logged

Chris Iverson
Administrator
ImageImageImageImageImage


member is offline

Avatar

20% Cooler


Homepage PM

Gender: Male
Posts: 2289
xx Re: debug-yes;regular-no
« Reply #14 on: Dec 5th, 2017, 2:22pm »

Because you didn't end the program, either.

There was no END statement in the trapclose subroutine.

It closes the main window, and the subroutine returns to LB's event processing, doing nothing.

You don't get the error about the program not closing the file handle, because the program was still running. If you had an END statement in the sub, you'd have gotten the error once the END statement was executed.

That's one thing you have to be careful of when using subroutine instead of branch label event handlers, and why many of us wind up using a sleep loop instead of just waiting.
User IP Logged

"Do you believe in destiny?" - Pyrrha Nikos, RWBY
"With what wish will your Soul Gem shine?" - Kyubey, Puella Magi Madoka Magica
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls