cancel
Showing results for 
Search instead for 
Did you mean: 

Global Variable Scope: Bug or Feature? (and a tip)

Former Member
0 Kudos

I just ran into a situation where I declared a global array, populated it in the Detail section of the report, but when I tried to reference it in a different formula field in the Report Footer section it was empty!

Is this a bug, or a feature?

FWIW, changing the declarations to Shared fixed this issue. This was the only change to the code.

Here's a tip, which I used to verify that the array was in fact getting cleared when referenced in the Report Footer section:

In the Detail section formula field that populated the array, I added the following (Basic syntax)


dim debug as number
global dbgcnt as number

dbgcnt = dbgcnt + 1
if dbgcnt > 100 then
  debug = debug / debug
end if

This causes a divide by zero error on the 101st detail record, which brings up the formula editor and displays the values of all of the variables. I could see the arrays were populated.

I then commented the above out, and in the Report Footer section, I added


dim debug as number
debug = debug / debug

To see that the arrays had no data in them.

I find this to be a great way to debug a report. Hope you like it!

HTH,

Carl

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Try this

WhilePrintingRecords
dim debug as number
global dbgcnt as number
dbgcnt = dbgcnt + 1
if dbgcnt > 100 then
  debug = debug / debug
end if
formula=dbgcnt

Regards,

Raghavendra

Former Member
0 Kudos

Sorry, but I don't understand what you are suggesting (or why)...

The use of debug and dbgcnt have nothing to do with my question (is a global reference supposed to be cleared, or is out of scope, at Report Footer time?). It was a tip on how to "set a breakpoint" in a report so you can see exactly what is going on...

Carl

Former Member
0 Kudos

I think your tip made everyone confuse because it is completely merged with your question (in a sense that they are all in a paragraph form).

Perhaps showing a tip by putting a bold letters

Question:

....

Tip:

.....

might have done the work.

Anyhow, I think it is the feature and not the bug but I maybe wrong.

Regards

Jehanzeb

Former Member
0 Kudos

Sorry for the confusion...

I thought the "Here's a tip..." made it clear. Bad assumption on my part, I guess...