@echo off

:writing
ip /i /e /s /f:I:\FD\MSG\WRITING /p:I:\FD\MSG\WRITING\writing /n:WRITING

if errorlevel 10 goto userbreak         ; User break
if errorlevel 6 goto pack1              ; Index has to be packed
if errorlevel 5 goto group              ; Message base locked
if errorlevel 4 goto wrongparams        ; Invalid parameters
if errorlevel 3 goto nospace            ; Insufficient disk space
if errorlevel 2 goto fatal              ; Fatal error
if errorlevel 1 goto group              ; No messages
if errorlevel 0 goto group              ; Messages imported, don't pack

:pack1
propack I:\FD\MSG\WRITING\writing 300 /deklrtvn30

:group
ip /i /e /s /f:F:\FD\MSG\GROUP /p:F:\FD\MSG\GROUP\group /n:GROUP

if errorlevel 10 goto userbreak         ; User break
if errorlevel 6 goto pack2              ; Index has to be packed
if errorlevel 5 goto loni               ; Message base locked
if errorlevel 4 goto wrongparams        ; Invalid parameters
if errorlevel 3 goto nospace            ; Insufficient disk space
if errorlevel 2 goto fatal              ; Fatal error
if errorlevel 1 goto loni               ; No messages
if errorlevel 0 goto loni               ; Messages imported, don't pack

:pack2
propack F:\FD\MSG\GROUP\group 200 /deklrtvn15

:loni
ip /i /e /s /f:I:\FD\MSG\LONI /p:I:\FD\MSG\LONI\lonix /n:LONI

if errorlevel 10 goto userbreak         ; User break
if errorlevel 6 goto pack3              ; Index has to be packed
if errorlevel 5 goto end                ; Message base locked
if errorlevel 4 goto wrongparams        ; Invalid parameters
if errorlevel 3 goto nospace            ; Insufficient disk space
if errorlevel 2 goto fatal              ; Fatal error
if errorlevel 1 goto end                ; No messages
if errorlevel 0 goto end                ; Messages imported, don't pack

:pack3
propack I:\FD\MSG\LONI\lonix 300 /deklrtvn20

goto end

:userbreak
echo BATCH PROCESSING ABORTED BY USER
goto finished

:wrongparams
echo == IP CALLED WITH INVALID PARAMETERS! > e:\log\fd.log
goto finished

:nospace
echo == INSUFFICIENT DISK SPACE DURING IMPORT/EXPORT > e:\log\fd.log
goto end

:fatal
echo == FATAL ERROR IN IMPORT/EXPORT > e:\log\fd.log
goto end

:end
echo *** PCBoard import/import complete ***
wipe f:\fd\msg\*.bak /b
wipe i:\fd\msg\*.bak /b

:finished
