home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / GRAPHICS / PLOT / SURFUTI3.ZIP / INICVT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1991-09-28  |  3.8 KB  |  106 lines

  1. { INICVT.PAS - Convert from old to new SURFMODL INI file format. }
  2. program INICVT;
  3.  
  4. {$I DEFINES.INC}
  5. {$M 5000, 0, 0}     { Leave memory for EXEC call }
  6.  
  7. uses dos,
  8.      crt,
  9.      SHAREDEC,
  10.      SURFGRAF;
  11.  
  12. { Global variables }
  13. var   Filemask: text80;                    { mask for naming data files }
  14.       Inifile: text80;                     { name of INI file }
  15.       Xeye, Yeye, Zeye: real;              { coords of eye }
  16.       Xfocal, Yfocal, Zfocal: real;        { coords of focal point }
  17.       Magnify: real;                       { magnification factor }
  18.       Viewtype: integer;                   { code for viewing type: }
  19.                                            { 0=perspective, 1=XY, 2=XZ, 3=YZ }
  20.       XYadjust: real;                      { factor for screen width }
  21.       Fileread: boolean;                   { flag first file read }
  22.       Nmatl: integer;                      { number of materials }
  23.       Nsurf: word;                         { # surfaces }
  24.       Nnodes: word;                        { # nodes }
  25.       Nlite: integer;                      { # light sources }
  26.       Interpolate: boolean;                { flag for Gouraud interpolation }
  27.       Epsilon: real;                       { Gouraud interpolation range }
  28.       Shadowing: boolean;                  { flag shadowing option }
  29.       Showaxes: integer;                   { code to show (0) no axes; (1) }
  30.                                            { axis directions; (2) full axes }
  31.       Xaxislen,Yaxislen,Zaxislen: real;    { lengths of axes }
  32.       Axiscolor: integer;                  { color to draw axes }
  33.       Nwindow: integer;                    { # graphics windows on screen }
  34.       ShowAllBorders: integer;             { code to (1) show surface borders}
  35.                                            { in shaded plots or (0) not }
  36.       Ini_ok: boolean;                     { was the INI file OK? }
  37.       Lastplot: integer;
  38.       R1, R2, R3: array[1..MAXMATL] of real;
  39.         { material reflectivity constants }
  40.       Color: array[1..MAXMATL] of integer;
  41.         { material color number }
  42.       Ambient: array[1..MAXMATL] of real;
  43.         { ambient light intensity for each material }
  44.       Xlite, Ylite, Zlite: array[1..MAXLITE] of real;
  45.         { coords of light sources }
  46.       Intensity: array[1..MAXLITE] of real;
  47.         { light source intensities }
  48.  
  49. {$define INICVT}
  50. {$I INITIAL.INC}
  51. {$I CHKCMMD.INC}
  52. {$I INREAL.INC}
  53. {$I READINI.INC}
  54. {$I WRITECFG.INC}
  55.  
  56. { CVTINI: This procedure does the actual conversion.  Since the old and
  57.   new file names are really the same, we will copy the old file.INI
  58.   to file.OLD and then create the new one as file.INI.
  59. }
  60. procedure CVTINI (Datafile: string);
  61. var Oldini: text80;       { file.OLD }
  62.     Cmmd: text80;         { command to system }
  63.  
  64. begin
  65.  
  66.   { First we read the old INI file, and store in global vbls. }
  67.   readini (Datafile);
  68.  
  69.   if (not Ini_ok) then begin
  70.     writeln ('ERROR reading ', Inifile);
  71.     exit;
  72.   end;
  73.  
  74.   { Copy file.INI to file.OLD.
  75.     Invoke a secondary command processor to use the DOS COPY command:
  76.   }
  77.   Oldini := Filemask + '.OLD';
  78.   Cmmd := '/C COPY ' + Inifile + ' ' + Oldini;
  79.   exec ( getenv ('COMSPEC'), Cmmd);
  80.  
  81.   writecfg;
  82.  
  83.   writeln ('Conversion successful.');
  84.   writeln (Inifile, ' has been modified.');
  85.   writeln ('The old copy is now stored in ', Filemask, '.OLD');
  86.  
  87. end; { CVTINI }
  88.  
  89. begin { main }
  90.  
  91.   { Process cmmd-line parms }
  92.   if (Paramcount <> 1) then begin
  93.     writeln ('usage: INICVT filename');
  94.     writeln ('  where filename is the name of the old .INI file to convert.');
  95.     writeln ('INICVT will convert a .INI file from the old SURFMODL format');
  96.     writeln ('to the new format (symbolic commands).');
  97.     halt(1);
  98.   end;
  99.  
  100.   Ini_ok := TRUE;
  101.   initial;
  102.  
  103.   cvtini (Paramstr(1));
  104.  
  105. end. { main }
  106.