这个旧程序是用什么语言写的?

What language is this old program written in?

"Hi, could you rewrite something for me",我老板说,"some legacy code"。是的,遗留代码写在中生代早期的某个地方。

我还有30个小时,我还不知道,这是什么语法!超高密度脂蛋白? VBA?程序专用于 something 音频文件,专用于 DOS 下的 运行。

你能告诉我这是什么吗?如何编译呢?

代码片段:

enter \ Load - main screen
empty  forth definitions  decimal
application  warning on

: TITLE ." KCS version 0.8  28-Jan-06" cr ;

cr .( Compiling: )  title  2 load

 cr .( Save to disk? )  y/n
[if]
\  pad reserve @ + 256 + limit s0 @ - + set-limit
  turnkey program  KCS
[then]



\ Load - defaults
 variable RESERVE  0 reserve !       \ reserved memory tally
 defer ?BREAK  ' noop is ?break      \ break check off
 defer SET-IO  ' bios-io is set-io   \ default console mode
 defer ERRFIX  ' noop is errfix      \ reset on-error handler

 blk @ 1+ #screens 1- thru       \ load electives & application

 ' (?break) is ?break           \ enable user break
\ ' dos-io is set-io             \ enable console redirection
\ ' deloutfile +is errfix        \ delete outfile on error
\ wrtchk off                     \ disable overwrite check




\ Load - electives
  1 fload DOSLIB     \ load DOSLIB library

 _Errors            \ error handler
 _Inout1            \ number output
 _Inout2            \ string & number input
 _String1           \ basic strings
\ _String2           \ extra strings
 _Parsing           \ command-line parsing
 _Fileprims         \ file primitives
 _Files             \ default files
 _Bufinfile         \ buffered input file
 _Bufoutfile        \ buffered output file


\ DECODE
\ Convert wave file to program
: DECODE  ( -- )
  0. decodecount 2!  0. paritycount 2!  0 errors !
  skipheader
  begin
    ['] decodebyte  1 ?catch 0=
   while ( not EOF )


 conout @ if  emit  else  writechar  then
    1 decodecount m+!
  repeat
  .decoded ;




\ SETMODE
\ Select Kansas City Standard or Processor Tech. CUTS mode
: SETMODE  ( -- )
  mode @ if ( CUTS )
    8 to databits  2 sbits !  4 speed !  parity off  pace off
    nullcnt off
    ['] 0bit-sqr-cuts is 0bit-sqr  ['] 1bit-sqr-cuts is 1bit-sqr
    ['] 0bit-sin-cuts is 0bit-sin  ['] 1bit-sin-cuts is 1bit-sin
    ['] seekstart-cuts is seekstart  ['] getbit-cuts is getbit
  else ( KCS )
    ['] 0bit-sqr-kcs is 0bit-sqr  ['] 1bit-sqr-kcs is 1bit-sqr
    ['] 0bit-sin-kcs is 0bit-sin  ['] 1bit-sin-kcs is 1bit-sin
    ['] seekstart-kcs is seekstart  ['] getbit-kcs is getbit
  then ;


\ (RUN)
\ Run application
: (RUN)  ( -- )
  setmode
  r/o openinfile
  decoding @ if
    conout @ 0= if  r/w makeoutfile  then
    cr decode
  else
    r/w makeoutfile
    cr encode
  then
  closefiles
  ;


\ DEFAULTS
\ Set application defaults
: DEFAULTS  ( -- )
  mode off  decoding on  strict off  ignore off  conout off
  1 speed !  2 sbits !  parity off  5 leadtime !  10 nullchar !
  pace off  nullcnt off  wave off  tone off  inverted off ;

defaults








\ RUN PROGRAM
\ Run application with error handling
: RUN  ( -- )
  ['] (run) catch ?dup if  >r errfix r> throw  then ;

\ Main
: PROGRAM  ( -- )
  set-io                \ set console mode
  defaults              \ set defaults
  cr title              \ show application name
  parsecmd              \ get options/filenames
  run                   \ run application
  cr ." done"           \ show success
  ;

它是用 Forth, probably the DX-Forth dialect. The program decodes and encodes WAVE files that contain data in the Kansas City standard format. This format was used to record data on cassette tapes on early S-100 CP/M machines. Searching the web reveals that there was a program written in DX-Forth 编写的,可以解码和编码这种格式的 WAVE 文件,所以我猜这是您要重写的程序。

然而,与其重写此代码,更简单的做法是使用已经完成这项工作的现有免费软件。例如,有一个用 Haxe 编写的名为 py-kcs written in Python that should be a functional replacement and one called hx-kcs 的程序可以进行解码。