/* Rexx */
If 0 then do
 '@If Exists C:\Windows Exit'
End

Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
Call SysLoadFuncs

Address CMD '@Echo off'; Call SysCls

Line_break = D2C( '13' ) || D2C( '10' )
Temp_drive = Left( Value( 'TEMP',, 'OS2Environment' ), 2 )

Call SysSetPriority 1, -31

/* * */

Book_title = 'Verified Assembly Language: an Overview'

File_name = 'Verified_Assembly_Language_an_Overview-RU'

/* * */

Address CMD 'Del /F ' || Temp_drive || '\' || File_name || '.inf > NUL 2> NUL'
Address CMD 'Del /F ' || Temp_drive || '\' || File_name || '.ipf > NUL 2> NUL'
Address CMD 'Del /F ' || Temp_drive || '\' || File_name || '.fb2 > NUL 2> NUL'

Call SysFileTree Temp_drive || '\' || File_name || '.inf', 'Files', 'FO'
If Files.0 then Exit

Temp_file = Temp_drive || '\' || File_name || '.ipf'

/* * */

Book.0 = 0;                       N = 1
Book.N = ':userdoc.';             N = N + 1
Book.N = ':title.' || Book_title; N = N + 1

Call SysFileTree '*_RU.ipf', 'Files', 'SFO'

Do i = 1 to Files.0
 Book.N = CharIn( Files.i,, Chars( Files.i ) ); N = N + 1
 Call Stream Files.i, 'C', 'Close'
End

Book.N = ':euserdoc.'
Book.0 = N

Do i = 1 to Book.0
 Call LineOut Temp_file, Book.i
End

Call Stream Temp_file, 'C', 'Close'

/* * */

Address CMD 'Cd ' || Temp_drive || '\'
Address CMD 'PHP -q ' || Directory() || '\FFFF-Bin\Replace.php --check-relations ' || Temp_file || ' ' || Directory()

Call SysFileTree Temp_drive || '\' || File_name || '.ipf', 'Files', 'FO'
If Files.0 = 0 then Exit

Address CMD 'Ipfc.exe -i -s ' || Temp_file

Say
Say 'Compiling FB2...'
Address CMD 'PHP -q ' || Directory() || '\FFFF-Bin\FBook.php ' || Temp_file

Exit