Highlighted
Absent Member.
Absent Member.
1595 views

global variable

Jump to solution

[Migrated content. Thread originally posted on 24 April 2012]

Hi ((:

I'm trying to write a program, but the compiler give me an error in following line of code, and I do not know why :X


       class-id assembler public.
       
       01 CurrentNdx binary-long.
       01 AsLength binary-short unsigned.
       01 IsEnd condition-value.
       01 ExecutionAddress binary-short unsigned.
       
       method-id Main static.
       01 LabelTable type System.Collections.Hashtable.
       procedure division using by value Args as string occurs any.
              set LabelTable to new System.Collections.Hashtable(50).
             
              *> Error here
              set IsEnd to false.
             
       end method Main.
       
       enum-id. Reg private.
           78 Unknown value 0.
           78 A value 4.
           78 B value 2.
           78 D value 1.
           78 X value 16.
           78 Y value 8.
       end enum Reg.
       
       end class assembler


Thanks
Alexandre
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: global variable

Jump to solution
By default, data items in the class working-storage section are assumed to be instance data and therefore cannot be accessed from a static method such as your Main.

In order to access IsEnd from a static method you need to make it into static data.
You can do this by adding the static keyword to its definition:

01 IsEnd condition-value static.

or you can define a static section in your program so that everything contained in it will be defined as static:


       class-id assembler public.
       static.
       01 CurrentNdx binary-long.
       01 AsLength binary-short unsigned.       
       01 IsEnd condition-value.       
       01 ExecutionAddress binary-short unsigned.             
       method-id Main static.       
       01 LabelTable type System.Collections.Hashtable.       
       procedure division using by value Args as string occurs any.             
          set LabelTable to new System.Collections.Hashtable(50).                           
          *> Error here             
          set IsEnd to false.                     
       end method Main.
       end static.             
       enum-id. Reg private.           
       78 Unknown value 0.           
       78 A value 4.           
       78 B value 2.           
       78 D value 1.           
       78 X value 16.           
       78 Y value 8.       
       end enum Reg.             
       end class assembler.

View solution in original post

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: global variable

Jump to solution
By default, data items in the class working-storage section are assumed to be instance data and therefore cannot be accessed from a static method such as your Main.

In order to access IsEnd from a static method you need to make it into static data.
You can do this by adding the static keyword to its definition:

01 IsEnd condition-value static.

or you can define a static section in your program so that everything contained in it will be defined as static:


       class-id assembler public.
       static.
       01 CurrentNdx binary-long.
       01 AsLength binary-short unsigned.       
       01 IsEnd condition-value.       
       01 ExecutionAddress binary-short unsigned.             
       method-id Main static.       
       01 LabelTable type System.Collections.Hashtable.       
       procedure division using by value Args as string occurs any.             
          set LabelTable to new System.Collections.Hashtable(50).                           
          *> Error here             
          set IsEnd to false.                     
       end method Main.
       end static.             
       enum-id. Reg private.           
       78 Unknown value 0.           
       78 A value 4.           
       78 B value 2.           
       78 D value 1.           
       78 X value 16.           
       78 Y value 8.       
       end enum Reg.             
       end class assembler.

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.