	program Cx
c	creates a command file to build a C job and runs it
c	
	byte string(133),ERR
C
C
C	INPUT IS 'DEV:FILE.[EXT]'
C	OUTPUT IS TO 'FILE.COM'
C
C	G.F.FORSYTH
C	ARL MELBOURNE
C
C	FILE HANDLING
	INTEGER*2 SPEC(39)
	REAL*4 DEF(2)
	INTEGER*2 name(4)
	BYTE FILNAM(25),FILE(6),OPTION(15),LNKFIL(40),COMMND(15)
c
C	'C  ' DEFAULT EXTENSION FOR INPUT AND 'COM' OUTPUT
	DATA DEF/6RC  COM,6RCOMCOM/
c	name(1) is device, 2,3 filnam
c	name(4) used for output extension
	DATA NAME(4)/3RCOM/
C
C
C
c	Use CSI to get file and options
500	IF (ICSI(SPEC,DEF,,,0).NE.0) GOTO 500
C
c	now need to check if there is an input file
c	we have only two file handling options
c	"FILE" with no option to use that file
c	<RET> to display ident and help info
c
c	can identify blank-file options by lack of SPEC(16)
	IF (SPEC(16).NE.0) GOTO 600
	TYPE 1
1	format(' CX "C" Language eXecute utility ---  GFF070786'/,
	1' USAGE: CX DEV:FILE.[C  ]',/,
	2' OPTIONS: NOT YET IMPLEMENTED',/)
	goto 500
C
c	open output files and input file
600	NAME(1)=SPEC(16)
	NAME(2)=SPEC(17)
	NAME(3)=SPEC(18)
C
C	ASSUME FILE IN NAME(1) TO NAME(3)
C	MAIN FILE EXTENSION IN NAME(4)
C
C	NEED TO CONVERT DATA FROM RAD50 TO ASCII TO PUT IN COMMANDS
C
C	CONVERT DEVICE TO ASCII
C	NOTE MAY HAVE TRAILING SPACES..
	CALL R50ASC(3,NAME(1),FILNAM(1))
	CALL TRIM(FILNAM)
	I=LEN(FILNAM)+1
	FILNAM(I)=':'
	I=I+1
C	CONVERT FILE TO ASCII
	CALL R50ASC(6,NAME(2),FILE(1))
C
	CALL TRIM(FILE)
	CALL SCOPY(FILE,LNKFIL(1))
	CALL SCOPY(FILE,FILNAM(I))
	COMMND(1)='$'
	COMMND(2)='@'
	CALL SCOPY(FILE,COMMND(3))
	CALL TRIM(COMMND)
C
	J=LEN(LNKFIL)+1
	I=LEN(FILNAM)+1
	FILNAM(I)='.'
	I=I+1
C	NOW ADD EXTENSION
	CALL R50ASC(3,SPEC(19),FILNAM(I))
	CALL TRIM(FILNAM)
C
	CALL IASIGN(2,NAME(1),NAME(2),0,9)
C
C
C	
C
C	NEED TO ADD OPTION PROCESSING IN HERE
	CALL SCOPY(',C:(SUPORT,CLIB)',LNKFIL(J))
C
C
	WRITE (2,10) (FILNAM(K),K=1,LEN(FILNAM))
10	FORMAT('+RUN C:CC ',25A1)
	WRITE (2,12) (FILE(K),K=1,LEN(FILE))
12	FORMAT(' RUN C:AS ',25A1)
	WRITE (2,15) (LNKFIL(K),K=1,LEN(LNKFIL))
15	FORMAT(' LINK ',40A1)
	WRITE (2,20) (FILE(K),K=1,LEN(FILE))
20	FORMAT(' RUN ',6A1)
	close(unit=2)
c
	call setcmd(COMMND)
	call exit
C
	END
