Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can someone explain some of this CR code please

Status
Not open for further replies.

jconaty

Programmer
Oct 4, 2010
4
US
I understand that we are looping. what I really dont get is how the variable (rdebits) is assigned a value. Can someone explain whats going on? thanks!

WhilePrintingRecords;
numbervar rdebits;

local numbervar amt:= abs(rdebits/{ACCRUAL_SUMMARY.HOURSPERDAYINSECS});
local numbervar days:= abs(truncate(amt));//gets the whole # of days
local numbervar secs:= remainder(abs(rdebits),{ACCRUAL_SUMMARY.HOURSPERDAYINSECS});
local stringvar con:= totext(secs/3600,"00") + ":" + totext(remainder(abs(secs),3600)/60,"00");//gets the remaining hrs:min
local stringvar sign := if rdebits < 0 then '-' else '';

select {ACCRUAL_SUMMARY.ACCRUALCODETYPE}

Case 1: if {?decimal format} = 0 then totext(rdebits/3600) else
totext(rdebits/3600, "0") + ":" + totext(remainder(abs(rdebits), 3600)/60, "00")

Case 2: if {?decimal format} = 0 then sign + totext(amt) else//gets days.days
sign + totext(days,0) + ":" + con //gets days:hrs:min

Case 3: totext($(rdebits))

 
I think rdebits is being assigned a value in a separate formula.

-LB
 
ahh didnt know you could do that. thanks for the reply.

It looks like its being declared here so... Could there be some changing going on as the records are being rendered?
 
I don't know what you mean. There is no assignment of value to rdebits in the formula you are showing.

-LB
 
Hi LB,
Isn't this
Code:
WhilePrintingRecords;
numbervar rdebits;

assigning value to rdebits? ( maybe 0 )







[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Technically I suppose that's true, but I doubt that was the intent!

-LB
 
i concur with lbass.

it appears that the variable rdebits is declared so that it can be used within the shown formula but would not return any useful data (as far as i can tell) unless it received it's value from some other source (other formula).

 
Hi,
Maybe I'm confused ( not at all unlikely) but wouldn't this declaration eliminate any previously assigned value for this and, therefore, eliminate the possibility that it has an assigned value from some other formula?



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
this is why I'm scratching my head. it looks to be a value of 0. I thought maybe it was incrementing (Based on the while statement above it) or something. I cannot seem to see anywhere that it is actually given a value. Hence the reason for posting it.

I dont like to assume anything. This piece of code was written in a report that has been used for several years. I just figured I was missing something.
 
I believe that, when declared and given a value in a previously used formula, then 'redeclared' in an additional formula, the variable will retain the value from the 1st formula unless it is explicitly assigned a new value.
 
I think you need to look systematically through all formulas
to see where the variable is assigned a value, as in

whileprintingrecords;
numbervar rdebits := <some field or summary or calculation>;

-LB
 
Hi,
fisheromacse it seems you are correct - a global variable can be redeclared ( and may have to be, to be used in a formula other then where it was first declared):

docs said:
Global variables use the same memory block to store a value throughout the main report. This value is then available to all formulas that declare the variable, except for those in subreports.


[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 

When you figure it out don't forget to add in a comment where it is being set.

You may want to do an export to report definition format and search that to see where it is used.
 
Thanks Tey,
I was going to ask everyone for an easy way to attempt to locate it. It seemed to be like finding a needle in a haystack. I was getting ready to go through each calculated field. This is a big report :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top