home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / c / fli106c / examples / load.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-25  |  24.2 KB  |  822 lines

  1. //
  2. // The Fusion Library Interface for DOS
  3. // Version 1.02
  4. // Copyright (C) 1990, 1991
  5. // Software Dimensions
  6. //
  7. // Dialog Development System
  8. //
  9.  
  10. #include "elements.h"
  11. #include "fliwin.h"
  12. #include "dds.h"
  13.  
  14. #include <io.h>
  15. #include <fcntl.h>
  16. #include <sys\stat.h>
  17. #include <alloc.h>
  18. #include <string.h>
  19.  
  20. //-------------------------------------------------------------------------
  21. //
  22. // Load a saved file
  23. //
  24. //-------------------------------------------------------------------------
  25.  
  26. #define CurrentFileVersion 6
  27.  
  28. void stringread(int Save,char *String)
  29. {
  30.   int Length;
  31.   read(Save,&Length,sizeof(int));
  32.   read(Save,String,Length);
  33. }
  34.  
  35. void DialogWindow::LoadFile(char *File)
  36. {
  37.   if (MainHandler)
  38.     RemoveTheMenus();
  39.  
  40.   //-------------------------------------------------------------------------
  41.   //
  42.   // Verify file existance
  43.   //
  44.   //-------------------------------------------------------------------------
  45.  
  46.   if (access(File,0))
  47.     return;
  48.  
  49.   //-------------------------------------------------------------------------
  50.   //
  51.   // Open file for load
  52.   //
  53.   //-------------------------------------------------------------------------
  54.  
  55.   int Save=open(File,O_RDWR|O_BINARY,S_IREAD|S_IWRITE);
  56.   lseek(Save,0,SEEK_SET);
  57.  
  58.   //-------------------------------------------------------------------------
  59.   //
  60.   // Get DDS file signature and verify it.  This will ensure that a user
  61.   // cannot load a file that does not belong to the DDS.  In addition,
  62.   // this will also keep the users from trying to crash the DDS.
  63.   //
  64.   //-------------------------------------------------------------------------
  65.  
  66.   char FileSignature[] = "[DDS/SD]";
  67.   char CheckSignature[sizeof(FileSignature)];
  68.  
  69.   read(Save,&CheckSignature,sizeof(FileSignature));
  70.  
  71.   if (strcmp(FileSignature,CheckSignature))
  72.   {
  73.     InfoBox NotValid;
  74.  
  75.     NotValid
  76.       + "The signature at the start of this"
  77.       + "file is incorrect which means that"
  78.       + "the file you specified is not a"
  79.       + "a DDS file or it is a file that has"
  80.       + "been corrupted.";
  81.  
  82.     NotValid.Title("Signature Wrong");
  83.     NotValid.UseInfoBox();
  84.  
  85.     close(Save);
  86.  
  87.     return;
  88.   }
  89.  
  90.   //-------------------------------------------------------------------------
  91.   //
  92.   // If pieces are currently in memory, dump them out
  93.   //
  94.   //-------------------------------------------------------------------------
  95.  
  96.   if (NumberPieces)
  97.   {
  98.     for (int i=0;i<NumberPieces;i++)
  99.       delete Pieces[i];
  100.     free(Pieces);
  101.     Pieces=0;
  102.   }
  103.  
  104.   //-------------------------------------------------------------------------
  105.   //
  106.   // Freshen the screen storage buffer
  107.   //
  108.   //-------------------------------------------------------------------------
  109.  
  110.   for (int y=0;y<60;y++)
  111.     for (int x=0;x<sizeof(Interior[0]);x+=2)
  112.     {
  113.       *(Interior[y]+x)=0;
  114.       *(Interior[y]+x+1)=WinInterior;
  115.     }
  116.  
  117.   //-------------------------------------------------------------------------
  118.   //
  119.   // Get file version code.
  120.   //
  121.   // File version history:
  122.   //  Version 1 - DDS betas 1 to 5
  123.   //  Version 2 - between DDS beta 5 and 6 (in house structure changes)
  124.   //    Version 2 eliminates some unneeded data and handles some new
  125.   //    fields that were added during testing.
  126.   //  Version 3 - incorporates new load structures for help and derivisions
  127.   //  Version 4 - permits additional element and object types to be
  128.   //    added in future versions with a version change being required.  It
  129.   //    also incorporates new pick list styles and character formats into
  130.   //    the loader.
  131.   //  Version 5 - added new focuses for buttons and resets for char/nums
  132.   //  Version 6 - added a string stripper function that only saves the
  133.   //    actual size of the string versus the entire string.
  134.   //
  135.   // This loader is compatible with *all* file versions
  136.   //
  137.   //-------------------------------------------------------------------------
  138.  
  139.   int CurVersion;
  140.  
  141.   if (!Title)
  142.     Title=new char[50];
  143.  
  144.   //-------------------------------------------------------------------------
  145.   //
  146.   // Load global dialog characteristics
  147.   //
  148.   //-------------------------------------------------------------------------
  149.  
  150.   read(Save,&CurVersion,sizeof(int));
  151.   read(Save,&CurrentColor,sizeof(int));
  152.   read(Save,&ZPositioning,sizeof(int));
  153.  
  154.   if (CurVersion<6)
  155.   {
  156.     read(Save,Title,50);
  157.     read(Save,&DerivedClass,50);
  158.   }
  159.   else
  160.   {
  161.     stringread(Save,Title);
  162.     stringread(Save,DerivedClass);
  163.   }
  164.  
  165.   if (CurVersion==1)
  166.   {
  167.     // These variables are obsolete in file version 2
  168.     // and are loaded to nowhere land
  169.  
  170.     char FunctionName[50];
  171.     read(Save,&FunctionName,50);
  172.     int OutputOutside;
  173.     read(Save,&OutputOutside,sizeof(int));
  174.   }
  175.  
  176.   read(Save,&Width,sizeof(int));
  177.   read(Save,&Height,sizeof(int));
  178.   read(Save,&X,sizeof(int));
  179.   read(Save,&Y,sizeof(int));
  180.  
  181.   //-------------------------------------------------------------------------
  182.   //
  183.   // Load the text that appears inside of the window (the typed stuff)
  184.   //
  185.   //-------------------------------------------------------------------------
  186.  
  187.   for (int i=0;i<(Height-2);i++)
  188.     read(Save,Interior[i],(Width-2)*2);
  189.  
  190.   //-------------------------------------------------------------------------
  191.   //
  192.   // Load the piece count
  193.   //
  194.   //-------------------------------------------------------------------------
  195.  
  196.   read(Save,&NumberPieces,sizeof(int));
  197.  
  198.   //-------------------------------------------------------------------------
  199.   //
  200.   // Load the elements in the order in which they were in when the
  201.   // dialog was saved and last manipulated
  202.   //
  203.   // This first section allocates a class for each element and object
  204.   // after getting the signature of the type of object
  205.   //
  206.   //-------------------------------------------------------------------------
  207.  
  208.   //-------------------------------------------------------------------------
  209.   //
  210.   // This GoIt enumeration is designed to make the load compabitible with
  211.   // file versions 1 to 3.  DO NOT alter or remove it or you can have
  212.   // problems!!
  213.   //
  214.   //-------------------------------------------------------------------------
  215.  
  216.     enum GoIt
  217.     {
  218.  
  219.     // Objects
  220.  
  221.     V3Box = 0,
  222.         V3FilledBox,
  223.         V3HorizontalLine,
  224.         V3VerticalLine,
  225.         V3Shadow,
  226.         V3EraseArea,
  227.     V3ColorizeArea,
  228.     V3__DUMMY__,
  229.  
  230.     // Elements
  231.  
  232.     V3Character,
  233.     V3Integer,
  234.     V3Long,
  235.     V3Float,
  236.     V3Double,
  237.     V3Bcd,
  238.     V3VRadio,
  239.     V3HRadio,
  240.     V3Pick,
  241.     V3Check,
  242.     V3Push,
  243.     V3__DUMMY2__,
  244.  
  245.     // Non Classifiable
  246.  
  247.     V3GroupHeading
  248.   };
  249.  
  250.   //-------------------------------------------------------------------------
  251.   //
  252.   // This loader segment loads file versions 1 to 3.
  253.   //
  254.   // DO NOT alter or remove it or you can have problems with old versions!!
  255.   //
  256.   //-------------------------------------------------------------------------
  257.  
  258.   if (CurVersion<4)
  259.   {
  260.  
  261.   if (NumberPieces)
  262.   {
  263.     Pieces=(PieceHandler **)realloc(Pieces,(NumberPieces+1)*sizeof(PieceHandler *));
  264.  
  265.     for (i=0;i<NumberPieces;i++)
  266.     {
  267.       int Layout;
  268.  
  269.       read(Save,&Layout,sizeof(int));
  270.  
  271.       switch (Layout)
  272.       {
  273.         case V3Box:
  274.           Pieces[i]=new Box(&Blaze);
  275.           break;
  276.  
  277.         case V3FilledBox:
  278.           Pieces[i]=new FilledBox(&Blaze);
  279.           break;
  280.  
  281.         case V3HorizontalLine:
  282.           Pieces[i]=new HorizontalLine(&Blaze);
  283.           break;
  284.  
  285.         case V3VerticalLine:
  286.           Pieces[i]=new VerticalLine(&Blaze);
  287.           break;
  288.  
  289.         case V3Shadow:
  290.           Pieces[i]=new Shadow(&Blaze);
  291.           break;
  292.  
  293.         case V3EraseArea:
  294.           Pieces[i]=new EraseArea(&Blaze);
  295.           break;
  296.  
  297.         case V3ColorizeArea:
  298.           Pieces[i]=new ColorizeArea(&Blaze);
  299.           break;
  300.  
  301.         case V3Character:
  302.           Pieces[i]=new Character(&Blaze);
  303.           break;
  304.  
  305.         case V3Integer:
  306.           Pieces[i]=new Integer(&Blaze);
  307.           break;
  308.  
  309.         case V3Long:
  310.           Pieces[i]=new Long(&Blaze);
  311.           break;
  312.  
  313.         case V3Float:
  314.           Pieces[i]=new Float(&Blaze);
  315.           break;
  316.  
  317.         case V3Double:
  318.           Pieces[i]=new Double(&Blaze);
  319.           break;
  320.  
  321.         case V3Bcd:
  322.           Pieces[i]=new Bcd(&Blaze);
  323.           break;
  324.  
  325.         case V3Check:
  326.           Pieces[i]=new Check(&Blaze);
  327.           break;
  328.  
  329.         case V3Push:
  330.           Pieces[i]=new Push(&Blaze);
  331.           break;
  332.  
  333.         case V3GroupHeading:
  334.           Pieces[i]=new GroupHeading(&Blaze);
  335.           break;
  336.  
  337.         case V3HRadio:
  338.           Pieces[i]=new HRadio(&Blaze);
  339.           break;
  340.  
  341.         case V3VRadio:
  342.           Pieces[i]=new VRadio(&Blaze);
  343.           break;
  344.       }
  345.  
  346.       //----------------------------------------------------------------------
  347.       //
  348.       // This set of variables is saved in the same spot for all elements.
  349.       //
  350.       //----------------------------------------------------------------------
  351.  
  352.       read(Save,&Pieces[i]->X,sizeof(int));
  353.       read(Save,&Pieces[i]->Y,sizeof(int));
  354.       read(Save,&Pieces[i]->Width,sizeof(int));
  355.       read(Save,&Pieces[i]->Height,sizeof(int));
  356.       read(Save,&Pieces[i]->Color,sizeof(int));
  357.  
  358.       //----------------------------------------------------------------------
  359.       //
  360.       // Load information that is specific to each type of element or
  361.       // object.
  362.       //
  363.       //----------------------------------------------------------------------
  364.  
  365.       switch(Layout)
  366.       {
  367.         case V3Character:
  368.         case V3Integer:
  369.         case V3Long:
  370.         case V3Float:
  371.         case V3Double:
  372.         case V3Bcd:
  373.           Pieces[i]->Mask=new char[50];
  374.           read(Save,Pieces[i]->Mask,50);
  375.           Pieces[i]->Variable=new char[50];
  376.           read(Save,Pieces[i]->Variable,50);
  377.           Pieces[i]->Prompter=new char[50];
  378.           read(Save,Pieces[i]->Prompter,50);
  379.           Pieces[i]->HotKey=new char[30];
  380.           read(Save,Pieces[i]->HotKey,30);
  381.           read(Save,&Pieces[i]->GroupCode,sizeof(int));
  382.           read(Save,&Pieces[i]->HelpId,sizeof(int));
  383.           read(Save,&Pieces[i]->ToBeDerived,sizeof(int));
  384.           read(Save,&Pieces[i]->PromptX,sizeof(int));
  385.           read(Save,&Pieces[i]->PromptY,sizeof(int));
  386.           if (CurVersion>2)
  387.           {
  388.             Pieces[i]->DerivedClass=new char[50];
  389.             read(Save,Pieces[i]->DerivedClass,50);
  390.             Pieces[i]->Help=new char[65];
  391.             read(Save,Pieces[i]->Help,65);
  392.           }
  393.           else
  394.           {
  395.             Pieces[i]->DerivedClass=new char[50];
  396.             *(Pieces[i]->DerivedClass)=0;
  397.             Pieces[i]->Help=new char[65];
  398.             *(Pieces[i]->Help)=0;
  399.           }
  400.           break;
  401.         case V3Check:
  402.           Pieces[i]->Text=new char[50];
  403.           read(Save,Pieces[i]->Text,50);
  404.           Pieces[i]->Variable=new char[50];
  405.           read(Save,Pieces[i]->Variable,50);
  406.           Pieces[i]->HotKey=new char[30];
  407.           read(Save,Pieces[i]->HotKey,30);
  408.           read(Save,&Pieces[i]->GroupCode,sizeof(int));
  409.           read(Save,&Pieces[i]->HelpId,sizeof(int));
  410.           read(Save,&Pieces[i]->ToBeDerived,sizeof(int));
  411.           if (CurVersion>2)
  412.           {
  413.             Pieces[i]->DerivedClass=new char[50];
  414.             read(Save,Pieces[i]->DerivedClass,50);
  415.             Pieces[i]->Help=new char[65];
  416.             read(Save,Pieces[i]->Help,65);
  417.           }
  418.           else
  419.           {
  420.             Pieces[i]->DerivedClass=new char[50];
  421.             *(Pieces[i]->DerivedClass)=0;
  422.             Pieces[i]->Help=new char[65];
  423.             *(Pieces[i]->Help)=0;
  424.           }
  425.           break;
  426.         case V3Push:
  427.           Pieces[i]->Text=new char[50];
  428.           read(Save,Pieces[i]->Text,50);
  429.           Pieces[i]->Constant=new char[50];
  430.           read(Save,Pieces[i]->Constant,50);
  431.           Pieces[i]->HotKey=new char[30];
  432.           read(Save,Pieces[i]->HotKey,30);
  433.           read(Save,&Pieces[i]->GroupCode,sizeof(int));
  434.           read(Save,&Pieces[i]->HelpId,sizeof(int));
  435.           read(Save,&Pieces[i]->ToBeDerived,sizeof(int));
  436.           if (CurVersion>2)
  437.           {
  438.             Pieces[i]->DerivedClass=new char[50];
  439.             read(Save,Pieces[i]->DerivedClass,50);
  440.             Pieces[i]->Help=new char[65];
  441.             read(Save,Pieces[i]->Help,65);
  442.           }
  443.           else
  444.           {
  445.             Pieces[i]->DerivedClass=new char[50];
  446.             *(Pieces[i]->DerivedClass)=0;
  447.             Pieces[i]->Help=new char[65];
  448.             *(Pieces[i]->Help)=0;
  449.           }
  450.           break;
  451.         case V3GroupHeading:
  452.           Pieces[i]->Text=new char[50];
  453.           read(Save,Pieces[i]->Text,50);
  454.           Pieces[i]->HotKey=new char[30];
  455.           read(Save,Pieces[i]->HotKey,30);
  456.           read(Save,&Pieces[i]->GroupCode,sizeof(int));
  457.           break;
  458.         case V3VRadio:
  459.         case V3HRadio:
  460.           Pieces[i]->Variable=new char[50];
  461.           read(Save,Pieces[i]->Variable,50);
  462.           Pieces[i]->Prompter=new char[50];
  463.           read(Save,Pieces[i]->Prompter,50);
  464.           Pieces[i]->HotKey=new char[30];
  465.           read(Save,Pieces[i]->HotKey,30);
  466.           read(Save,&Pieces[i]->GroupCode,sizeof(int));
  467.           read(Save,&Pieces[i]->HelpId,sizeof(int));
  468.           read(Save,&Pieces[i]->ToBeDerived,sizeof(int));
  469.           read(Save,&Pieces[i]->PromptX,sizeof(int));
  470.           read(Save,&Pieces[i]->PromptY,sizeof(int));
  471.           Pieces[i]->DerivedClass=new char[50];
  472.           read(Save,Pieces[i]->DerivedClass,50);
  473.           Pieces[i]->Help=new char[65];
  474.           read(Save,Pieces[i]->Help,65);
  475.           Pieces[i]->Elements=new char*[10];
  476.           for (int j=0;j<10;j++)
  477.           {
  478.             Pieces[i]->Elements[j]=new char[50];
  479.             read(Save,Pieces[i]->Elements[j],50);
  480.           }
  481.           break;
  482.       }
  483.     }
  484.   }
  485.  
  486.   }
  487.   else
  488.   {
  489.  
  490.   //-------------------------------------------------------------------------
  491.   //
  492.   // This loader segment loads file versions 4 and above.
  493.   //
  494.   // The enumerations for this segment are in PIECE.H
  495.   //
  496.   //-------------------------------------------------------------------------
  497.  
  498.   if (NumberPieces)
  499.   {
  500.     Pieces=(PieceHandler **)realloc(Pieces,(NumberPieces+1)*sizeof(PieceHandler *));
  501.  
  502.     for (i=0;i<NumberPieces;i++)
  503.     {
  504.       int Layout;
  505.  
  506.       read(Save,&Layout,sizeof(int));
  507.  
  508.       switch (Layout)
  509.       {
  510.         case PieceHandler::Box:
  511.           Pieces[i]=new Box(&Blaze);
  512.           break;
  513.  
  514.         case PieceHandler::FilledBox:
  515.           Pieces[i]=new FilledBox(&Blaze);
  516.           break;
  517.  
  518.         case PieceHandler::HorizontalLine:
  519.           Pieces[i]=new HorizontalLine(&Blaze);
  520.           break;
  521.  
  522.         case PieceHandler::VerticalLine:
  523.           Pieces[i]=new VerticalLine(&Blaze);
  524.           break;
  525.  
  526.         case PieceHandler::Shadow:
  527.           Pieces[i]=new Shadow(&Blaze);
  528.           break;
  529.  
  530.         case PieceHandler::EraseArea:
  531.           Pieces[i]=new EraseArea(&Blaze);
  532.           break;
  533.  
  534.         case PieceHandler::ColorizeArea:
  535.           Pieces[i]=new ColorizeArea(&Blaze);
  536.           break;
  537.  
  538.         case PieceHandler::Character:
  539.           Pieces[i]=new Character(&Blaze);
  540.           break;
  541.  
  542.         case PieceHandler::Integer:
  543.           Pieces[i]=new Integer(&Blaze);
  544.           break;
  545.  
  546.         case PieceHandler::Long:
  547.           Pieces[i]=new Long(&Blaze);
  548.           break;
  549.  
  550.         case PieceHandler::Float:
  551.           Pieces[i]=new Float(&Blaze);
  552.           break;
  553.  
  554.         case PieceHandler::Double:
  555.           Pieces[i]=new Double(&Blaze);
  556.           break;
  557.  
  558.         case PieceHandler::Bcd:
  559.           Pieces[i]=new Bcd(&Blaze);
  560.           break;
  561.  
  562.         case PieceHandler::Check:
  563.           Pieces[i]=new Check(&Blaze);
  564.           break;
  565.  
  566.         case PieceHandler::Push:
  567.           Pieces[i]=new Push(&Blaze);
  568.           break;
  569.  
  570.         case PieceHandler::GroupHeading:
  571.           Pieces[i]=new GroupHeading(&Blaze);
  572.           break;
  573.  
  574.         case PieceHandler::HRadio:
  575.           Pieces[i]=new HRadio(&Blaze);
  576.           break;
  577.  
  578.         case PieceHandler::VRadio:
  579.           Pieces[i]=new VRadio(&Blaze);
  580.           break;
  581.  
  582.         case PieceHandler::PickGeneric:
  583.           Pieces[i]=new PickGeneric(&Blaze);
  584.           break;
  585.       }
  586.  
  587.       //----------------------------------------------------------------------
  588.       //
  589.       // This set of variables is saved in the same spot for all elements.
  590.       //
  591.       //----------------------------------------------------------------------
  592.  
  593.       read(Save,&Pieces[i]->X,sizeof(int));
  594.       read(Save,&Pieces[i]->Y,sizeof(int));
  595.       read(Save,&Pieces[i]->Width,sizeof(int));
  596.       read(Save,&Pieces[i]->Height,sizeof(int));
  597.       read(Save,&Pieces[i]->Color,sizeof(int));
  598.  
  599.       //----------------------------------------------------------------------
  600.       //
  601.       // Load information that is specific to each type of element or
  602.       // object.
  603.       //
  604.       //----------------------------------------------------------------------
  605.  
  606.       switch(Layout)
  607.       {
  608.         case PieceHandler::Character:
  609.         case PieceHandler::Integer:
  610.         case PieceHandler::Long:
  611.         case PieceHandler::Float:
  612.         case PieceHandler::Double:
  613.         case PieceHandler::Bcd:
  614.           Pieces[i]->Mask=new char[50];
  615.           Pieces[i]->Variable=new char[50];
  616.           Pieces[i]->Prompter=new char[50];
  617.           Pieces[i]->HotKey=new char[30];
  618.           if (CurVersion<6)
  619.           {
  620.             read(Save,Pieces[i]->Mask,50);
  621.             read(Save,Pieces[i]->Variable,50);
  622.             read(Save,Pieces[i]->Prompter,50);
  623.             read(Save,Pieces[i]->HotKey,30);
  624.           }
  625.           else
  626.           {
  627.             stringread(Save,Pieces[i]->Mask);
  628.             stringread(Save,Pieces[i]->Variable);
  629.             stringread(Save,Pieces[i]->Prompter);
  630.             stringread(Save,Pieces[i]->HotKey);
  631.           }
  632.           read(Save,&Pieces[i]->GroupCode,sizeof(int));
  633.           read(Save,&Pieces[i]->HelpId,sizeof(int));
  634.           read(Save,&Pieces[i]->ToBeDerived,sizeof(int));
  635.           read(Save,&Pieces[i]->PromptX,sizeof(int));
  636.           read(Save,&Pieces[i]->PromptY,sizeof(int));
  637.           Pieces[i]->DerivedClass=new char[50];
  638.           Pieces[i]->Help=new char[65];
  639.           if (CurVersion<6)
  640.           {
  641.             read(Save,Pieces[i]->DerivedClass,50);
  642.             read(Save,Pieces[i]->Help,65);
  643.           }
  644.           else
  645.           {
  646.             stringread(Save,Pieces[i]->DerivedClass);
  647.             stringread(Save,Pieces[i]->Help);
  648.           }
  649.           if (CurVersion>=5)
  650.             read(Save,&Pieces[i]->Focus_Reset,sizeof(int));
  651.           if (Layout==PieceHandler::Character)
  652.           {
  653.             read(Save,&Pieces[i]->MaskCharacter,sizeof(int));
  654.             read(Save,&Pieces[i]->MaskWidth,sizeof(int));
  655.             read(Save,&Pieces[i]->ScrollWidth,sizeof(int));
  656.           }
  657.           break;
  658.         case PieceHandler::Check:
  659.           Pieces[i]->Text=new char[50];
  660.           Pieces[i]->Variable=new char[50];
  661.           Pieces[i]->HotKey=new char[30];
  662.           if (CurVersion<6)
  663.           {
  664.             read(Save,Pieces[i]->Text,50);
  665.             read(Save,Pieces[i]->Variable,50);
  666.             read(Save,Pieces[i]->HotKey,30);
  667.           }
  668.           else
  669.           {
  670.             stringread(Save,Pieces[i]->Text);
  671.             stringread(Save,Pieces[i]->Variable);
  672.             stringread(Save,Pieces[i]->HotKey);
  673.           }
  674.           read(Save,&Pieces[i]->GroupCode,sizeof(int));
  675.           read(Save,&Pieces[i]->HelpId,sizeof(int));
  676.           read(Save,&Pieces[i]->ToBeDerived,sizeof(int));
  677.           Pieces[i]->DerivedClass=new char[50];
  678.           Pieces[i]->Help=new char[65];
  679.           if (CurVersion<6)
  680.           {
  681.             read(Save,Pieces[i]->DerivedClass,50);
  682.             read(Save,Pieces[i]->Help,65);
  683.           }
  684.           else
  685.           {
  686.             stringread(Save,Pieces[i]->DerivedClass);
  687.             stringread(Save,Pieces[i]->Help);
  688.           }
  689.           break;
  690.         case PieceHandler::Push:
  691.           Pieces[i]->Text=new char[50];
  692.           Pieces[i]->Constant=new char[50];
  693.           Pieces[i]->HotKey=new char[30];
  694.           if (CurVersion<6)
  695.           {
  696.             read(Save,Pieces[i]->Text,50);
  697.             read(Save,Pieces[i]->Constant,50);
  698.             read(Save,Pieces[i]->HotKey,30);
  699.           }
  700.           else
  701.           {
  702.             stringread(Save,Pieces[i]->Text);
  703.             stringread(Save,Pieces[i]->Constant);
  704.             stringread(Save,Pieces[i]->HotKey);
  705.           }
  706.           read(Save,&Pieces[i]->GroupCode,sizeof(int));
  707.           read(Save,&Pieces[i]->HelpId,sizeof(int));
  708.           read(Save,&Pieces[i]->ToBeDerived,sizeof(int));
  709.           Pieces[i]->DerivedClass=new char[50];
  710.           Pieces[i]->Help=new char[65];
  711.           if (CurVersion<6)
  712.           {
  713.             read(Save,Pieces[i]->DerivedClass,50);
  714.             read(Save,Pieces[i]->Help,65);
  715.           }
  716.           else
  717.           {
  718.             stringread(Save,Pieces[i]->DerivedClass);
  719.             stringread(Save,Pieces[i]->Help);
  720.           }
  721.           if (CurVersion>=5)
  722.             read(Save,&Pieces[i]->Focus_Reset,sizeof(int));
  723.           break;
  724.         case PieceHandler::GroupHeading:
  725.           Pieces[i]->Text=new char[50];
  726.           Pieces[i]->HotKey=new char[30];
  727.           if (CurVersion<6)
  728.           {
  729.             read(Save,Pieces[i]->Text,50);
  730.             read(Save,Pieces[i]->HotKey,30);
  731.           }
  732.           else
  733.           {
  734.             stringread(Save,Pieces[i]->Text);
  735.             stringread(Save,Pieces[i]->HotKey);
  736.           }
  737.           read(Save,&Pieces[i]->GroupCode,sizeof(int));
  738.           break;
  739.         case PieceHandler::VRadio:
  740.         case PieceHandler::HRadio:
  741.           Pieces[i]->Variable=new char[50];
  742.           Pieces[i]->Prompter=new char[50];
  743.           Pieces[i]->HotKey=new char[30];
  744.           if (CurVersion<6)
  745.           {
  746.             read(Save,Pieces[i]->Variable,50);
  747.             read(Save,Pieces[i]->Prompter,50);
  748.             read(Save,Pieces[i]->HotKey,30);
  749.           }
  750.           else
  751.           {
  752.             stringread(Save,Pieces[i]->Variable);
  753.             stringread(Save,Pieces[i]->Prompter);
  754.             stringread(Save,Pieces[i]->HotKey);
  755.           }
  756.           read(Save,&Pieces[i]->GroupCode,sizeof(int));
  757.           read(Save,&Pieces[i]->HelpId,sizeof(int));
  758.           read(Save,&Pieces[i]->ToBeDerived,sizeof(int));
  759.           read(Save,&Pieces[i]->PromptX,sizeof(int));
  760.           read(Save,&Pieces[i]->PromptY,sizeof(int));
  761.           Pieces[i]->DerivedClass=new char[50];
  762.           Pieces[i]->Help=new char[65];
  763.           if (CurVersion<6)
  764.           {
  765.             read(Save,Pieces[i]->DerivedClass,50);
  766.             read(Save,Pieces[i]->Help,65);
  767.           }
  768.           else
  769.           {
  770.             stringread(Save,Pieces[i]->DerivedClass);
  771.             stringread(Save,Pieces[i]->Help);
  772.           }
  773.           Pieces[i]->Elements=new char*[10];
  774.           for (int j=0;j<10;j++)
  775.           {
  776.             Pieces[i]->Elements[j]=new char[50];
  777.             if (CurVersion<6)
  778.               read(Save,Pieces[i]->Elements[j],50);
  779.             else
  780.               stringread(Save,Pieces[i]->Elements[j]);
  781.           }
  782.           break;
  783.         case PieceHandler::PickGeneric:
  784.           Pieces[i]->Prompter=new char[50];
  785.           Pieces[i]->HotKey=new char[30];
  786.           if (CurVersion<6)
  787.           {
  788.             read(Save,Pieces[i]->Prompter,50);
  789.             read(Save,Pieces[i]->HotKey,30);
  790.           }
  791.           else
  792.           {
  793.             stringread(Save,Pieces[i]->Prompter);
  794.             stringread(Save,Pieces[i]->HotKey);
  795.           }
  796.           read(Save,&Pieces[i]->HelpId,sizeof(int));
  797.           read(Save,&Pieces[i]->ToBeDerived,sizeof(int));
  798.           read(Save,&Pieces[i]->PromptX,sizeof(int));
  799.           read(Save,&Pieces[i]->PromptY,sizeof(int));
  800.           Pieces[i]->DerivedClass=new char[50];
  801.           Pieces[i]->Help=new char[65];
  802.           if (CurVersion<6)
  803.           {
  804.             read(Save,Pieces[i]->DerivedClass,50);
  805.             read(Save,Pieces[i]->Help,65);
  806.           }
  807.           else
  808.           {
  809.             stringread(Save,Pieces[i]->DerivedClass);
  810.             stringread(Save,Pieces[i]->Help);
  811.           }
  812.           break;
  813.       }
  814.     }
  815.   }
  816.  
  817.   }
  818.  
  819.   close(Save);
  820. }
  821.  
  822.