Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RPG/400 Question:declaring variables

Status
Not open for further replies.

badapplebob

Programmer
May 13, 2003
12
GB
Hi everyone,

I have a question regarding declaring variables in calculation specs. I know that you can declare a variable in a result field of a calculation and then specify (if
numeric, length + decimal places) or length if alphanumeric. But can you declare a variable as a standalon e in Input specs. Just as you would in Cobol (in a data division) before using it?

Thanks,

Bob
 
In RPG 4, you can declare them as part of the "D" specs (definition). If you are using free-form or the EVAL statement in fixed-form, you have to do it that way.

You can't declare a standalone variable in the I-specs.

You can also use *LIKE DEFINE if you want a field to have the same specs as another field already defined (like a field in am externally-described file).


"When once you have tasted flight, you will forever walk the Earth with your eyes turned skyward, for here you have been, and there you will always long to return."

--Leonardo da Vinci

 
Hiya,

Thanks for your reply - but my question was in relation to RPG/400.

There doesn't seem to be a way to declare a variable before using it!

Thanks,

BOb
 
Although not an explicit declaration, you can group all
of your fields at the top of your C-Specs by using "dummy"
calculations as follows...

Z-ADD0 FLDA 40
Z-ADD0 FLDB 42
MOVE *BLANKS FLDY 10
MOVE *BLANKS FLDZ 40

- vbMax
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top