ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

NOMAIN module variables not getting reinitilized.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • NOMAIN module variables not getting reinitilized.

    Generraly,
    Note: For a program compiled with DFTACTGRP(NO), global static variables are marked for re-initialization when the module or program ends with *INLR on. (This behavior differs from OPM and DFTACTGRP=*YES, where static storage is freed when the program ends with *INLR on.) Local static variables are not reinitialized.

    But, for global variables of no main module are not getting re initilized. Is there any way to get them re initialized when we call them for second time.
    TSTPGM2: Program
    Code:
     
    [FONT=Courier New]df s 10s 0 [/FONT]
    [FONT=Courier New]dxxpr pr [/FONT]
    [FONT=Courier New]c callb 'TST22' -------- MODULE [/FONT]
    [FONT=Courier New]c callp xxpr() ---------Procedure in NOMAIN module[/FONT]
    [FONT=Courier New]c eval *inlr = *on [/FONT]
    [FONT=Courier New]c return [/FONT]
    ----------------------------
    TST22 *MODULE
    -----------------------------
    Code:
     
    [FONT=Courier New]dstr2 s 10a [/FONT]
    [FONT=Courier New]/free [/FONT]
    [FONT=Courier New]str2 = 'bhar'; [/FONT]
    [FONT=Courier New] [/FONT]
    [FONT=Courier New]*inlr = *on; <<<<<<<<MARKS p reinitialization. for str2 <> return; [/FONT]
    [FONT=Courier New]/end-free[/FONT]
    -------------------------------------
    TST11 --- NOMAIN module.
    -----------------------------------------
    Code:
     
    [FONT=Courier New]h nomain [/FONT]
    [FONT=Courier New] [/FONT]
    [FONT=Courier New]dstr s 10a <<<<<<<<<<<<NOT p getting initilized.<> d xxpr pr [/FONT]
    [FONT=Courier New]p xxpr b export [/FONT]
    [FONT=Courier New]/free [/FONT]
    [FONT=Courier New]str = 'bhar'; [/FONT]
    [FONT=Courier New] [/FONT]
    [FONT=Courier New]*inlr = *on; <<<<<<<<<< return; [/FONT]
    [FONT=Courier New]/end-free [/FONT]
    [FONT=Courier New]p xxpr e[/FONT]
    ************************

    When the Globle variable in NOMAIN main module gets initialized. Is their any way.

  • #2
    Re: NOMAIN module variables not getting reinitilized.

    *INLR means absolutely NOTHING inside a NOMAIN module. if the variables are defined as STATIC that's exactly what it means! any data in a STATIC variable will retain it's value UNTIL you reinitialize them.
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment

    Working...
    X