-
1
- #1
Truusvlugindewind
Programmer
One of the big advantages of COBOL is it's portability. It runs on all kind of machines. If you need to know on what kind of machine your code is running, you can add this piece of code. You can test whether it is a "big endian" type of CPU or not.
In my case, I develop on a window$ machine and the target platform is AIX. This kind of info is very usefull when you have to call dedicated API's.
Yes, I know: little is misspelled. But for me a nice outline is more important than correct spelling of the field....
In my case, I develop on a window$ machine and the target platform is AIX. This kind of info is very usefull when you have to call dedicated API's.
Code:
01 Machinetest.
03 binair-0000-0100-pic-X pic X(2) value X'0004'.
03 which-endian redefines
binair-0000-0100-pic-X pic S9(4) comp-5.
03 B-I-G-endian value +0004 pic S9(4) comp-5.
03 litle-endian value +1024 pic S9(4) comp-5.
PROCEDURE DIVISION.
********************
000-MAIN Section.
000-010.
evaluate which-endian
when B-I-G-endian
display "this is the AIX (powerPC)"
when litle-endian
display "this is a PC (intel inside!)"
when other
display "how the *beep* do you run this program?"
end-evaluate.
Yes, I know: little is misspelled. But for me a nice outline is more important than correct spelling of the field....