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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variabele length field 1

Status
Not open for further replies.

JohnnyBlazer

Programmer
Sep 26, 2008
5
BE
Hello professionals!

I ran stuck on this problem. Maybe some of you can point me in the right direction.

77 Test PIC 99 VALUE 0.
...
DISPLAY Input

The outcome of the Display would be 00
Is there any way to get this shortened to 0?
I tried the INSPECT Test REPLACING LEADING ZERO BY SPACE statement but that gives me a "}" sign!!! :-(

Any help would be very appreciated.

Thanks,
John
 
it depends on what you're wanting to do.

But according to what you defined in the variable, it is displaying what you are desiring. A numeric display variable of two display digits.

Define the variable to be one numeric display digit, or display an edited field to get what you are wanting.

As for your INSPECT, spaces are invalid in numeric fields and it is likely correcting/interpreting it the best it can as a numeric field.

----------
Measurement is not management.
 
If your compiler supports reference modification you can DISPLAY TEST(1:1) displaying the 1st digit of the field or
DISPLAY TEST(2:1) displaying the 2nd digit of the field.

Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
 
Thanks for your replies!
Jack, your solution worked like a charm! :) Thanks a bunch for that.
Do you accidently know how I can right align/fill an input (PIC 9(8)) on an ACCEPT?
I tried ACCEPT Num WITH SPACE-FILL and it works except when I input a 0, because that get's replaced right? How can I right align without replacing the zero :-( This is part of the goal so..

When inputing value
right: 9
wrong: 00000009
wrong: 9

When inputing zero
right: 0
wrong:

With regards,
John
 
John,
Are you able to change the format of the field at all? If you able to use numeric edited fields, it might solve your problems. In your first example, you could define the field as Z9 and in your 2nd Z(7)9.

I'm not sure if you can ACCEPT into these types of fields, so you may need to may the accepted value to a field of this format.

Hope this is of some help.

Marc
 
Hello Marc, and thanks for your quick reply.

The field can't be declared as it is used later in a divide function (so numeric is required). I tried it although it doesn't seem to do any alignment. :-(

PS: if anyone is interested I'm willing to send my code (it's only 85 lines). That's maybe easier for you.

Greetings,
John
 
how mumerics are handled on input depends on compiler used, and on compiler/runtime/code used within the accept.

Give us the compiler vendor/version, and we may be able to help further

Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
01 input-field pic x(8) just.
01 input-num redefines input-field pic 9(8).


move spaces to input-field.
accept input-field.
inspect input-field replacing all space by zero.
if input-field not numeric
display "not a numeric response"
end-if
move input-num to output-num.
 
John,

Could you define 2 fields; 1 for the DISPLAY, 1 for the arith. E.g.:
Code:
ARITH-FLD   pic 9(008).
DISP-FLD    pic z(007)9.

ACCEPT ARITH-FLD
MOVE ARITH-FLD TO DISP-FLD

Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
 
Or this could work too:
Code:
ARITH-FLD   pic 9(008).
DISP-FLD redefines ARITH-FLD pic z(007)9.
ACCEPT ARITH-FLD
* Work with DISP-FLD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top