Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!waikato.ac.nz!comp.vuw.ac.nz!med.wcc.govt.nz!galaxy.southpower.co.nz!ccc.govt.nz!trevor Newsgroups: comp.lang.fortran Subject: Re: Re: character function subprogram Message-ID: <1991Apr17.131857.214@ccc.govt.nz> From: trevor@ccc.govt.nz Date: 17 Apr 91 13:18:56 NZDT References: <1991Apr7.200854.25446@math.ufl.edu> <1991Apr15.140403.210@ccc.govt.nz> Organization: Christchurch City Council, New Zealand. Lines: 72 In article <1991Apr15.140403.210@ccc.govt.nz>, trevor@ccc.govt.nz writes: > In article <1991Apr7.200854.25446@math.ufl.edu>, wang@math.ufl.edu writes: >> Can anyboby explain to me why the following FORTRAN character function >> subprogram works under VAX/VMS, but doesn't work under unix (SunOS 4.1.1, >> Sun Fortran 1.3)? >> >> CHARACTER*8 cursor,cls*4 >> cls = CHAR(27)//'[2J' >> i = 5 >> j = 35 >> PRINT *,cls,cursor(i,j),'I am here!' >> END >> >> CHARACTER FUNCTION cursor*8(row,col) >> CHARACTER*1 esc,c1*2,c2*2 >> INTEGER row,col >> esc = CHAR(27) >> WRITE(c1,'(i2.2)') row >> WRITE(c2,'(i2.2)') col >> cursor = esc//'['//c1//';'//c2//'H' >> RETURN >> END >> >> (Unix messages deleted...) >> > > I think the main problem is that direct screen addressing; direct cursor > positioning are system-dependent: even worse, they are peripheral-dependent. > The program quoted writes an output string which contains an ANSI > device-control escape sequence. It should work fine if sent to a DEC VT100, > VT200, VT300 terminal (or any other VDU which emulates a DEC ANSI CRT or > accepts ANSI device control) by a system which passes on the escape sequence > uncorrupted, but it won't work right on a VT52 or a printer, I think the > screen control sequences for HP terminals were different (but it's a looong > time since I programmed for one) and I'd be surprised if it did work under > Unix on a Sun. > Direct cursor addressing isn't standard Fortran. (Fortran carriage-controls > for printers IS standard, but we have one printer that doesn't recognise > them...) > Sorry. I'd missed the function reference in the PRINT statement (I read it as an array reference - oops). Thank you to those of you who have been patient enough to point out the error of my ways. I think what I was talking about was: CHARACTER*8 cursor,cls*4 character*8 string cls = CHAR(27)//'[2J' i = 5 j = 35 string = cursor(i,j) PRINT *,cls,string,'I am here!' END CHARACTER FUNCTION cursor*8(row,col) CHARACTER*1 esc,c1*2,c2*2 INTEGER row,col esc = CHAR(27) WRITE(c1,'(i2.2)') row WRITE(c2,'(i2.2)') col cursor = esc//'['//c1//';'//c2//'H' RETURN END which just leaves the (system-dependent) device controls to be fixed. I *will* try to pay closer attention in future... Trevor Ingham, Systems Programmer, Christchurch City Council, New Zealand. trevor@ccc.govt.nz