Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Statics keyword

Former Member
0 Likes
1,181

Statics can be used only within Form....EndForm. Is there any similar thing which can be used outside Form so that one can persist data between calls to the subroutine

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
970

Hi Mala,

Static Local Data Objects

If you want to keep the value of a local data object after exiting the subroutine, you must use the STATICS statement to declare it instead of the DATA statement. With STATICS you declare a data object that is globally defined, but only locally visible from the subroutine in which it is defined.

But if you want to have a varibale outside the subroutines which persists their values between subroutine calls,it is better to define them as global variables and they will be available.

In case you have any further clarifications,do let me know.

Regards,

Puneet Jhari.

Statics can be used only within Form....EndForm. Is there any similar thing which can be used outside Form so that one can persist data between calls to the subroutine

3 REPLIES 3
Read only

Clemenss
Active Contributor
0 Likes
970

Hi Mala,

outside FORM variables are global: They are initialized at program start and will retain their values until end of program run.

STATICS means that the field will not lose it's value when the FORM processing is left. Next time the FORM is called, the value is still stored in the STATIC field. This means the variable field is like a global variable with the difference that you can not see it from outside the form.

Regards,

Clemens

Read only

Former Member
0 Likes
970

Hi,

If you declare that variable globally (like in a top include). then that variable will be available..

Thanks

Naren

Read only

Former Member
0 Likes
971

Hi Mala,

Static Local Data Objects

If you want to keep the value of a local data object after exiting the subroutine, you must use the STATICS statement to declare it instead of the DATA statement. With STATICS you declare a data object that is globally defined, but only locally visible from the subroutine in which it is defined.

But if you want to have a varibale outside the subroutines which persists their values between subroutine calls,it is better to define them as global variables and they will be available.

In case you have any further clarifications,do let me know.

Regards,

Puneet Jhari.