Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!comp.vuw.ac.nz!med.wcc.govt.nz!galaxy.southpower.co.nz!ccc.govt.nz!trevor From: trevor@ccc.govt.nz Newsgroups: comp.lang.fortran Subject: Re: character function subprogram Message-ID: <1991Apr15.140403.210@ccc.govt.nz> Date: 15 Apr 91 20:11:57 GMT References: <1991Apr7.200854.25446@math.ufl.edu> Lines: 44 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...) I do know you can't use any sort of direct cursor addressing when writing for GEM; you have to use the appropriate GEM VDI or AES call. I know this doesn't HELP much, but I hope it might explain a little. Trevor Ingham, Systems Programmer, Christchurch City Council, New Zealand. trevor@ccc.govt.nz