Stepping through a procedure

I have several procedures that were created in Pan 6 that crashes the program when using the Menu or using the Run icon in the procedure sheet. The procedure will run if I step through the procedure. It turns out these procedures also crash in 10.2. Is there a way to step through these procedures. Thanks
Dave88

I would recommend that you set up Debug Instrumentation, then add zlog statements at various points in your procedure. The instrumentation will then show you exactly how far the program is getting.

It turns out these procedures also crash in 10.2.

I think what you are saying is that this crash happened in Panorama 10.1 and now still happens in 10.2. Your system has submitted the exact same crash log for both versions. The same exact crash has been submitted 4 times, starting in June 2020. No other users have submitted this exact crash. It appears that the crash starts with the count statement, does your procedure include a count statement? Then it updates the display, then it does a removesummaries statement. Then it updates the display, and it crashes in the process of displaying a text object on a form. I wonder if it is somehow trying to display the summary record that is now gone.

I’m guessing that there is another statement (or more than one) between count and removesummaries that saves the count into a variable, these extra statements aren’t preserved in the crash log. If you just want to get the count into a variable, there is a much better way to do that in Panorama X that wasn’t available in Panorama 6, the aggregate( function.

Using this eliminates the need to make a temporary summary record, it’s much faster and easier. (However this only works for an overall total or count, if you are grouping the database then you will have to stick with summary records.)

If you post your actual code here I may be able to suggest how to use the aggregate( function instead.

Jim
Here is a procedure that usually crashes the program without stepping through it:

Local tdate, resp, sym1, rank1

Select SYM = “PCAR”

Field Date

Sortup

LastRecord

Loop

UpRecord

Until 2

tdate = Date

select Date > tdate

Field «SYM»

SortUp

Field «Date»

SortUpWithin

Field AVE

Count

FirstRecord

resp = “”

rank1 = “”

noshow

Loopwhile not info(“eof”)

;Loop

sym1 = SYM

rank1 = Rank[1,8]

downrecord

;if sym1 = SYM

if rank1 = Rank[1,8]

resp = " S^"

endif

if rank1 <> Rank[1,8]

resp = " C^"

endif

Tier = Tier + resp

downrecord

endloop

show

RemoveSummaries “7”

Save

call Today

I’ve reformatted your code to make it more readable:

Local tdate, resp, sym1, rank1
Select SYM = “PCAR”
Field Date
Sortup
LastRecord
Loop
	UpRecord
Until 2
tdate = Date
select Date > tdate
Field «SYM»
SortUp
Field «Date»
SortUpWithin
Field AVE
Count
FirstRecord
resp = “”
rank1 = “”
noshow
Loopwhile not info(“eof”)
	sym1 = SYM
	rank1 = Rank[1,8]
	downrecord
	if rank1 = Rank[1,8]
		resp = " S^"
	endif
	if rank1 <> Rank[1,8]
		resp = " C^"
	endif
	Tier = Tier + resp
	downrecord
endloop
show
RemoveSummaries “7”
Save
call Today

This is very mysterious code. You select all dates greater than the record 2 from the bottom after sorting by date? I assume you must have your reasons, anyway, that has nothing to do with the crash, so I won’t worry about it.

The count statement creates a summary record with the number of records in the AVE field. But you never use this count. So why bother creating the count and then removing it later with the removesummaries statement? Since that is what is causing the crash, I would suggest removing both of these statements and see if it works.

You assign a value to the sym1 variable but never use this variable later. So you might as well remove that line and the definition of this variable, though it isn’t hurting anything either.

The loop modifies the Tier field for every other record. Is that what you intended?

Why is the noshow/show only around the loop? I would think you would want to move the noshow to the top of the code, and the show to the bottom. That might even fix the crash even if you still create and remove the summary record.

But I would start by removing the count and removesummaries lines. They aren’t doing anything, and that’s where the crash is.


I made this simple procedure:

field A
count
lastrecord
removesummaries 7

When I ran this with a form window active, sometimes the form items would wind up blank instead of showing the first record (which is what they should show). It didn’t happen every time, and it didn’t crash, but I think this may be the same problem you are encountering. I’ve made a record of this so it can be investigated further. But in your case, I would just remove these lines since they aren’t serving any purpose.

Another minor note. I would suggest changing:

	if rank1 = Rank[1,8]
		resp = " S^"
	endif
	if rank1 <> Rank[1,8]
		resp = " C^"
	endif

to

	if rank1 = Rank[1,8]
		resp = " S^"
	else
		resp = " C^"
	endif

It’s just simpler. Or, you could make it just one line:

    resp = ?(rank1=Rank[1,8]," S^"," C^")

This won’t make it work better, just a suggestion to make it simpler.

In fact, you could get rid of the resp variable completely.

    Tier = Tier + ?(rank1=Rank[1,8]," S^"," C^")

You could also get rid of the lines:

resp = “”
rank1 = “”

they are not needed.

Here’s my complete suggestion for a revised version of your procedure.

noshow
Select SYM = “PCAR”
Field Date Sortup
LastRecord
UpRecord
UpRecord
let tdate = Date
select Date > tdate
Field «SYM» SortUp
Field «Date» SortUpWithin
FirstRecord
Loopwhile not info(“eof”)
	let rank1 = Rank[1,8]
	downrecord
	Tier = Tier + ?(rank1=Rank[1,8]," S^"," C^")
	downrecord
endloop
show
Save
call Today

Mr Rea
I’ve been making the suggested changes in the multiple procedures that have been giving me problems. They no longer crash. Its a great relief. Thank You for your help.
Dave88