! script name: contrib/ascript/tsm.d/editfile_hex
! topic: edit a file
! Version_270810.a

!A
!A NAME:
!A
!A      Edit File
!A
!A DESCRIPTION:
!A
!A      This script allows a file to be edited.  The file name can be
!A      passed into the script or just an editor can be brought up

stat=ChangeLabelStr("ScriptNameStatus","Function: edit file ")

DIM Destination$[256]
DIM Answer$[256]
DIM File_name$[256]
DIM Editor$[256]
DIM Header$[4096]
DIM Jobname$[256]
DIM Filename$[256]
DIM File_name$[256]
DIM Hex_name$[256]
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Stat= CurrentHeader(Header$)
Head=ReadUserData(WsGeneralString,"HEADER",Header$)
Stat=GetUserString(Head,"File name:",Jobname$)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
File_name$= Jobname$[1,LEN(Jobname$)-4]
Filename$= File_name$&".cnc"
!Stat=DumpDebug("FILE_NAME = "&Filename$)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Stat= NamedVarStr("file editor",WsSystemVars,"notepad.exe",Editor$)
Flip_file= NamedVarVal("flip crlf",WsSystemVars,0)
Stat=EditFile(Editor$,Filename$,Flip_file)
Leave:!
IF NOT LEN(Destination$) THEN
         LOAD "typecontrol"
ELSE
         LOAD Destination$
END IF
END
