GX.RAR@forsythe.stanford.edu (Buc Richards) (05/12/89)
Can standard fortran output a tab character? That is if I want tab delimited output to be read into a spredsheet, can I generate the output using Fortran Write and Format statements? I have checked a few references and did not find any answers. Thanks for the assistance.
danl@cbnewsc.ATT.COM (daniel.r.levy) (05/12/89)
In article <3101@lindy.Stanford.EDU>, GX.RAR@forsythe.stanford.edu (Buc Richards) writes: > Can standard fortran output a tab character? (Please pardon the net answer. Reply mail wanted to send to lindy!news which doesn't look right, and doesn't explain how to get to forsythe.stanford.edu) If you are using FORTRAN-77 and an ASCII character set, there's an easy way. Print char(9) (9 is the ASCII value of tab) with an A1 format descriptor. E.g., THIS=1.3 THAT=9.5 THOTHR=4.8 WRITE(6,10)THIS,CHAR(9),THAT,CHAR(9),THOTHR 10 FORMAT(1X,F9.3,A1,F9.3,A1,F9.3) which will print as 1.300<tab> 9.500<tab> 4.800 -- Dan'l Levy UNIX(R) mail: att!ttbcad!levy, att!cbnewsc!danl AT&T Bell Laboratories 5555 West Touhy Avenue Any opinions expressed in the message above are Skokie, Illinois 60077 mine, and not necessarily AT&T's.
mikel@pyrps5 (Mike Lipsie) (05/12/89)
In article <3101@lindy.Stanford.EDU> GX.RAR@forsythe.stanford.edu (Buc Richards) writes: > >Can standard fortran output a tab character? Standard FORTRAN (77) does not allow for a tab character, per se. The T, TL, and TR FORMAT codes (which can be mnemonically thought of as tab, tab left, and tab right) are clearly to be implemented with blanks. However, it allows you to have CHARACTER variables/constants with "any characters capable of representation in the processor". This means that, while you cannot have any truly portable code, you can write code that will work on your machine. And, if your machine uses ASCII, your code should work on a large set of machines. ----------- Mike Lipsie mikel@pyramid.com Pyramid Technology Corp, Mountain View, CA +1 415 965 7200 ext. 4980
variyar@dukeac.UUCP (Jayasankar E. Variyar) (05/13/89)
In article <3101@lindy.Stanford.EDU>, GX.RAR@forsythe.stanford.edu (Buc Richards) writes: > > Can standard fortran output a tab character? That is if I want tab > delimited output to be read into a spredsheet, can I generate the > output using Fortran Write and Format statements? I have checked a > few references and did not find any answers. Thanks for the > assistance. The easiest way to do that is by defining a character variable . CHARACTER TAB TAB = 9 !ASCII equivalent of TAB Write(UNIT#,900)a,tab,b 900 Format(f10.4,a1,f10.4) etc.. This defenitely works on MACTRAN, a fortran compiler for the Mac Jay
brainerd@unmvax.unm.edu (Walt Brainerd) (05/13/89)
In article <3101@lindy.Stanford.EDU>, GX.RAR@forsythe.stanford.edu (Buc Richards) writes: > > Can standard fortran output a tab character? The answer is yes, but after reading on, you may think you have asked the wrong question! Usually, being standard means being portable, but there are some exceptions, and this is one of them. The _program_ that does any of these things is standard conforming; it is just not portable (just like a Fortran function with side effects). The reason it is not portable is that the set of characters, other than those given explicitly in the standard (which does _not_ include the tab character), is processor dependent. Thus a tab may be an acceptable character on one machine and not on another. A response indicated that CHAR(9) would do it. This is true only if the machine uses ASCII. The standard says you get character #9, whatever that is, in the collating sequence for your machine. The proposed 8x has two new functions ACHAR and IACHAR, converting from integer to ASCII characters and back. With these ACHAR(9) will be the tab character for sure and this will be portable. Walt Brainerd Unicomp, Inc. 505/275-0800 brainerd@unmvax.unm.edu