In SQR, we donot explicitly declare variable as global in general unless the variables are passed through the procedure in_list.
Below is the sample program to demonstrate usage of variable value globally.
!**********************************************************************
!begin-program
!**********************************************************************
Begin-Program
do Stdapi-Init !stdapi.sqc
do Init-Report !Init Report
do Process-Main !Process-Main-Logic
do Stdapi-Term !stdapi.sqc
End-Program
!**********************************************************************
!Init-Report
!**********************************************************************
begin-procedure Init-Report
let $Flag = 'N'
end-procedure Init-Report
!**********************************************************************
!Process-Main
!**********************************************************************
begin-procedure Process-Main
! Business logic
BEGIN-SELECT
show ' Before override = ' $Flag
let $Flag = 'Y'
show ' After override = ' $Flag
do procedure-1
END-SELECT
end-procedure Process-Main
!**********************************************************************
!procedure-1
!**********************************************************************
begin-procedure procedure-1
let $Flag = 'N'
show ' In procedure-1 = ' $Flag
end-procedure procedure-1
Output:
Before override = N
After override = Y
In procedure-1 = N
Below is the sample program to demonstrate usage of variable value globally.
!**********************************************************************
!begin-program
!**********************************************************************
Begin-Program
do Stdapi-Init !stdapi.sqc
do Init-Report !Init Report
do Process-Main !Process-Main-Logic
do Stdapi-Term !stdapi.sqc
End-Program
!**********************************************************************
!Init-Report
!**********************************************************************
begin-procedure Init-Report
let $Flag = 'N'
end-procedure Init-Report
!**********************************************************************
!Process-Main
!**********************************************************************
begin-procedure Process-Main
! Business logic
BEGIN-SELECT
show ' Before override = ' $Flag
let $Flag = 'Y'
show ' After override = ' $Flag
do procedure-1
END-SELECT
end-procedure Process-Main
!**********************************************************************
!procedure-1
!**********************************************************************
begin-procedure procedure-1
let $Flag = 'N'
show ' In procedure-1 = ' $Flag
end-procedure procedure-1
Output:
Before override = N
After override = Y
In procedure-1 = N
No comments:
Post a Comment