1@echo off
2setlocal
3
4set dir=%~dps0
5if exist %dir%cgconfig.bat (
6  call %dir%cgconfig.bat
7  goto getwish
8)
9if exist %dir%..\cgconfig.bat call %dir%..\cgconfig.bat
10
11:getwish
12if "%CG_BIN_DIR%" == "" set CG_BIN_DIR=%dir%
13
14if exist %dir%calcwish.exe (
15  set wish=%dir%calcwish.exe
16  goto getscript
17)
18if exist %dir%cgnstools\calcwish.exe (
19  set wish=%dir%cgnstools\calcwish.exe
20  goto getscript
21)
22echo calcwish.exe not found
23pause
24goto done
25
26:getscript
27if exist %dir%cgnscalc.tcl (
28  set script=%dir%cgnscalc.tcl
29  goto run
30)
31if not "%CG_LIB_DIR%" == "" (
32  if exist %CG_LIB_DIR%\cgnscalc.tcl (
33    set script=%CG_LIB_DIR%\cgnscalc.tcl
34    goto run
35  )
36)
37if exist %dir%..\share\cgnscalc.tcl (
38  if "%CG_LIB_DIR%" == "" set CG_LIB_DIR=%dir%..\share
39  set script=%dir%..\share\cgnscalc.tcl
40  goto run
41)
42echo cgnscalc.tcl not found
43pause
44goto done
45
46:run
47start /b %wish% %script% %1
48
49:done
50endlocal
51