; K2.INI - Standard Kermit 95 for OS/2 initialization file.
;
; V2.3, June 1997
;
; This file sets up the standard and expected environment for Kermit/2.
; Please don't edit this file.  Make any desired customizations in the
; K2CUSTOM.INI file, which is executed by this file.
;
; V2.4, August 2022
; Updated to support C-Kermit for OS/2

local _edit _boot
echo Executing \v(cmdfile) for \v(system)...

if = \v(xversion) 0 {
    ; Running on C-Kermit for OS/2.
    if < \v(version) 800206 forward custom ; C-Kermit too old
} else {
    if < \v(xversion) 1121 forward custom  ; K95 too old
}

; Dialing and Network directories
; (THESE ARE OBSOLETE)
; set dial directory ckermit.kdd cis.kdd sprint.kdd tymnet.kdd genie.kdd
; set netw directory ckermit.knd

; Editor - Version 1.1.9 or later required

if def \v(editor) forward netedit     ; Picked up from registry?

; Set up the default editor for the EDIT command.  If you would rather use
; a different editor, then either define an EDITOR environment variable, or
; add a SET EDITOR command to your K2CUSTOM.INI file to override this one.
;
asg _edit \$(EDITOR)
xif not exist \m(_edit) {
    asg _boot \$(SYSTEM_INI)
    xif def _boot {
        asg \%9 \frindex(\\,\m(_boot))
        if = \%9 0 asg \%9 \frindex(/,\m(_boot))
        if not = 0 \%9 asg _edit \fsubstr(\m(_boot),1,\%9)E.EXE
    }
}
if not exist \m(_edit) asg _edit C:/OS2/E.EXE
if exist \m(_edit) set editor \m(_edit)

:NETEDIT

; NETEDIT macro -- See UPDATES.TXT for an explanation.
;  
def _NETEDIT {
    switch \v(protocol) {
      :kermit,   output kermit -s \%1\13, break
      :zmodem,   output sz -a \%1\13, break
      :ymodem,   output sb -a \%1\13, break
      :ymodem-g, output sb -a \%1\13, break
      :xmodem,   output sx -a \%1\13, break
      :default, end 1 "\v(protocol)" - protocol unexpected
    }
    receive \%1
    if fail end 1 "\%1" - Download failed
    edit \%1
    if def WAIT_FOR_EDITOR getok
    if not exist \%1 end 1 -
      File "\%1" missing after edit - Did you change its name\?
    set file type text
    send \%1
    asg status \v(status)
    delete \%1
    if not = \m(status) 0 end 1 Upload failed
    end 0
}

def NETEDIT {
    local mode current
    asg mode \v(ftype)			; Save things
    set term autodownload off
    asg current \v(directory)
    if def \v(download) cd \v(download)
    do _netedit \%1			; Execute the macro
    asg status \v(status)
    set term autodownload on		; Restore things
    cd \m(current)
    set file type \m(mode)
    end \m(status)			; Return
}

; The K2CUSTOM.INI file is created for you by SETUP.
; You can edit K2CUSTOM.INI to suit your preferences.

if exist \$(K2CUSTOM) -
  take \$(K2CUSTOM)
else if exist K2CUSTOM.INI -
  take K2CUSTOM.INI 
else if exist \v(inidir)K2CUSTOM.INI -
  take \v(inidir)K2CUSTOM.INI 
else if exist \v(startup)K2CUSTOM.INI -
  take \v(startup)K2CUSTOM.INI 
else if exist \v(exedir)K2CUSTOM.INI -
  take \v(exedir)K2CUSTOM.INI 
else if exist CKERMOD.INI -
  take CKERMOD.INI 
else if exist \v(inidir)CKERMOD.INI -
  take \v(inidir)CKERMOD.INI 
else if exist \v(startup)CKERMOD.INI -
  take \v(startup)CKERMOD.INI 
else if exist \v(exedir)CKERMOD.INI -
  take \v(exedir)CKERMOD.INI 

if < \v(ntime) 43200 echo Good Morning, smile!
  else if < \v(ntime) 61200 echo Good Afternoon, smile!
  else echo Good Evening, smile!

end ; of K2.INI

