Strange

Just starting out? Need help? Post your questions and find answers here.
ANDY ANDERSON
User
User
Posts: 62
Joined: Thu Aug 28, 2014 9:02 pm

Strange

Post by ANDY ANDERSON »

I've had pretty good luck bringing programs over from PowerBasic but I've encountered an
anomaly: I translated and compiled a program and ran it. It bombed without invoking the
error routine. So, I inserted several MessageRequesters into the program to determine where
it failed. After recompiling, it ran fine and produced the correct results. If I comment out the
MessageRequesters, it bombs again.

All thought are welcome.

Thanks.
DontTalkToMe
Enthusiast
Enthusiast
Posts: 334
Joined: Mon Feb 04, 2013 5:28 pm

Re: Strange

Post by DontTalkToMe »

Stack corruption ?

Your description is clearly not detailed enough (to put it kindly).

Probably by examining the code someone here could tell you why it happens.

If that is not possible try to reduce the code. Cut, cut, cut until it stops "bombing" (whatever that means) and then examine the delta of the two sources for clues.

Also you didn't say if it runs in debug mode in the IDE, if you tried the purifier, what PB version you are using, what O.S., if it's "bombing" right at the start or if you can use it for a while, ... think about all the useful things you could say (even if nothing beat what the source could say).

The usual stuff everyone should say when asking this kind of questions :wink:

Tell more (or start cutting) !
ANDY ANDERSON
User
User
Posts: 62
Joined: Thu Aug 28, 2014 9:02 pm

Re: Strange

Post by ANDY ANDERSON »

Thank you, DontTalkToMe.

When you mentioned stack corruption, it reminded me of problems I have had with
Select/Case. So, I changed the use of it to a sequence of If/ElseIf statements and the
program ran just fine.

As an aside, I'm using 5.31 on a Windows machine.

Thanks again.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Strange

Post by Fred »

If you could reproduce it in a small snippet showing the bug, I would be glad to take a closer look.
ANDY ANDERSON
User
User
Posts: 62
Joined: Thu Aug 28, 2014 9:02 pm

Re: Strange

Post by ANDY ANDERSON »

Fred,

I'll will try to cobble a working example but before I do, I wonder if the below code
might be involved. Note the use of If/EndIf within the case structure.

The program produces U.S. Medicare health care claims. The first claim is produced
as expected but the case that it falls in does not have an If/EndIf statement.

Production of the second claim fails and it falls in a case that has an If/EndIf
statement.

Code: Select all

Case 2
HCD$ = Mid(PATREC, 3125, 2): HDTE1$ = Mid(PATREC, 3045, 6)
HDTE2$ = Mid(PATREC, 3051, 6): If HCD$ = "  ": HCD$ = "70": EndIf
PCD$ = Mid(PATREC, 2890, 2): PDTE1$ = Mid(PATREC, 2892, 6)
PDTE2$ = Mid(PATREC, 2898, 6)
Case 3
Last edited by ANDY ANDERSON on Wed Sep 16, 2015 10:21 pm, edited 1 time in total.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Strange

Post by IdeasVacuum »

Does that snippet run in your app?

Replace

Code: Select all

Case = 2
with

Code: Select all

Case 2
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
ANDY ANDERSON
User
User
Posts: 62
Joined: Thu Aug 28, 2014 9:02 pm

Re: Strange

Post by ANDY ANDERSON »

Sorry, I pasted it over from the PowerBasic code because I had already replaced the
Select/Case code in the PureBasic program with If/ElseIf statements. I changed all the
syntax except that one that I missed.

Is there a way to edit the post ?
User avatar
Vera
Addict
Addict
Posts: 858
Joined: Tue Aug 11, 2009 1:56 pm
Location: Essen (Germany)

Re: Strange

Post by Vera »

ANDY ANDERSON wrote:Is there a way to edit the post ?
Yes - just look at your posting (bottom right) and click on the Image - button.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Strange

Post by IdeasVacuum »

Hi Andy
Still not enough in that snippet to go on.
What is PATREC? A string? I ask because you are identifying other strings with $.

Code: Select all

      LINE$ = "FKmPq66Bv66ScgBtmfuGPN24k9S4U9VhB7WR4K9eF6XH4g2fnbM3PvVZkwK6nn5NbSn6jn3P9Qe4X7928LTE7xm9SW552ZA3zMYH" ;100 chars
    PATREC$ = ""
iTestCase.i = 2

For i = 1 To 32

   PATREC$ = PATREC$ + LINE$
Next

Select iTestCase

             Case 2

                   HCD$ = Mid(PATREC$, 3125, 2): HDTE1$ = Mid(PATREC$, 3045, 6)
                 HDTE2$ = Mid(PATREC$, 3051, 6): If HCD$ = "  ": HCD$ = "70": EndIf
                   PCD$ = Mid(PATREC$, 2890, 2): PDTE1$ = Mid(PATREC$, 2892, 6)
                 PDTE2$ = Mid(PATREC$, 2898, 6)
                 Debug "  HCD$-->" + HCD$ + "<--"
                 Debug "HDTE1$-->" + HDTE1$ + "<--"
                 Debug "HDTE2$-->" + HDTE2$ + "<--"
                 Debug "  HCD$-->" + HCD$ + "<-- (after If)"
                 Debug "  PCD$-->" + PCD$ + "<--"
                 Debug "PDTE1$-->" + PDTE1$ + "<--"
                 Debug "PDTE2$-->" + PDTE2$ + "<--"

             Case 3
EndSelect
[/size]

What exactly is the failure? When you say the app 'bombs', what do you mean? App crashes off the screen? Locks up? Unexpected result?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
ANDY ANDERSON
User
User
Posts: 62
Joined: Thu Aug 28, 2014 9:02 pm

Re: Strange

Post by ANDY ANDERSON »

IdeasVacuum, thanks for your interest.

Yes, PATREC is a string (Define.S PATREC). It's just a quaint convention of mine
to leave off the $ for variables that hold a record read from file. Helps me keep
things straight.

To explain the symptoms: This job stream has 4 programs. The first one accepts user
entries such as facility number (billing party) and period date (%MM%YY).

After ENTER is pressed, it shells to (RunProgram) and waits for 3 programs that do
the Medicare Part A claims, then Medicare Part B claims and then Medicare Part B
Therapy claims. Meanwhile, the original dialog stays presented with a small window
that indicates the claim set it is processing. When all 3 jobs are finished, control
returns to the original dialog.

What happens in this failure, is that the 1st of the 3 programs ends with no error
message even though I have an error routine and the monitor returns to the desktop.
A check on the output shows that only one claim was produced.

When I replaced the Select/Case statements with If/ElseIf ones, the job ran to a
successful completion with all claims generated. Since I had found out the hard way
that you can't use GoTo's within a Case structure, I thought that maybe you couldn't
use If/EndIf either.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Strange

Post by IdeasVacuum »

Your switch from Select Case to If Else might not be a finite solution but if the code is actually working without any blips then why not stick with it? There is a possibility that the 2nd and 3rd programs will be interrupted by an Anti-virus app. Certainly true these days that a program that sets-off other exe files is considered suspicious. Since you are rebuilding in PB, you could have the entire task processed by one program instead of 4, using threads if necessary.

There isn't anything wrong with PB's Select Case, I use it all the time, it's robust. So, there is probably a fault in your logic, if so it will be right there staring back at you but you won't see it straight away! :|
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply