Search code examples
pl-i

PL/1 locator qualifier


I'm getting compilation error "BASED variable without an implicit qualifier must be explicitly qualified." for line no 19 & 22. What is wrong with these 2 statements?
My intent of this prog is to understand what values get assigned when using locator qualifier.

000001  PROG: PROC OPTIONS(MAIN);            
000002                                       
000003         DCL VARA CHAR(12) BASED(PA);  
000004         DCL VARB CHAR(15) BASED;      
000005         DCL (PA,PB) POINTER;          
000006                                       
000007         ALLOCATE VARA;                
000008                                       
000009         VARA = 'TEST-DATA';           
000010         PA->VARA='TEST-DATA1';        
000011         PUT SKIP LIST(PA);            
000012         PUT SKIP LIST(VARA);          
000013                                       
000014         PB->VARA='TEST-DATA2';        
000015         PUT SKIP LIST(PA,PB);         
000016         PUT SKIP LIST(VARA);          
000017                                    
000018         ALLOCATE VARB SET (PB);    
000019         VARB = 'NEW-TEST-DATA';    
000020         PB->VARB='NEW-TEST-DATA1'; 
000021         PUT SKIP LIST(PB);         
000022         PUT SKIP LIST(VARB);       
000023  END PROG;   

Solution

  • A BASED-variable is basically a mask you can put over some storage-area and see the storage contents through this data-description.

    Your VARA is declared to use the storage at PA as the default if there is no explicit mention of the address you want to use.

    VARB has no such default-address, so if you want to use it you always have to tell the compiler explicitly which storage to look at by using the ->-operator which is missing in lines 19 and 22.