home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / visionix / vresfu.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-11-21  |  49.8 KB  |  2,374 lines

  1. {
  2.  ════════════════════════════════════════════════════════════════════════════
  3.  
  4.  Visionix Resource File (VRESFILE)
  5.    Version 0.7
  6.  Copyright 1991,92,93 Visionix
  7.  ALL RIGHTS RESERVED
  8.  
  9.  File text retrieving library.  This unit provides the ability to use an
  10.  external text file for all text.  This is so that programs being supplied
  11.  to non-English countries may modify the text to their native language.
  12.  Also, this provides a method of automating the creation of basic menus -
  13.  all data provided in the .VRF file.
  14.  
  15.  ────────────────────────────────────────────────────────────────────────────
  16.  
  17.  Revision history in reverse chronological order:
  18.  
  19.  Initials  Date      Comment
  20.  ────────  ────────  ────────────────────────────────────────────────────────
  21.  
  22.  jrt       11/20/93  Added IFDEF VUI around code that requires
  23.                      the vuiwinu types.  This allows this unit
  24.                      to be used without VUI.
  25.  
  26.  rob       08/31/93  Added VRF_NewInMem, Reads a VRF from memory.
  27.  
  28.  jrt       08/2?/93  Added code for reading the VRF at the end of an
  29.                      EXE file.
  30.  
  31.  jrt       05/06/93  Added code to support hiercheral sections,
  32.                      addded maxlines paramater to VRF_New,
  33.                      added VRF_ChangeSection as part of section mods,
  34.                      added VRF_GetView, VRF_GetBoolean, VRF_GetReal,
  35.                      moved vrf info from local data segment to
  36.                      TVRF rec which is allocated from the heap.
  37.  
  38.  lpg       03/15/93  Added Source Documentation
  39.  
  40.  jrt       04/08/93  Cleaned up code to use VGEN functions;
  41.                      (GetParamName, etc)
  42.                      Added code to do indexing.  Don't ask about
  43.                      the indexing algorithym.
  44.  
  45.  mep       02/11/93  Cleaned up code for beta release
  46.  
  47.  jrt       11/21/92  Sync with beta 0.08
  48.  
  49.  jrt       09/29/92  Converted function names to new format;
  50.                      Added VRF_GetInt; cleaned up, etc. etc.
  51.  
  52.  jrt       09/01/92  First logged revision.
  53.  
  54.  ════════════════════════════════════════════════════════════════════════════
  55. }
  56.  
  57. (*-
  58.  
  59. [TEXT]
  60.  
  61. <About this unit>
  62.  
  63. This is a text-based resoure retrieval library.
  64.  
  65. This unit provides the ability to use an external text file for all text,
  66. integers, reals, menus, dialogs, colors, and boolean values used by a
  67. program.
  68.  
  69.  
  70. <<ALL EXAMPLES ASSUME A RESOURCE FILE AS FOLLOWS>>
  71.  
  72. File Name: PROGRAM.VRF
  73.  
  74. ---FILE BEGIN---
  75.  
  76. MENU_BEGIN "Sector Menu"
  77.   "Read Sector      "
  78.   "Write Sector     "
  79.   "View/Edit Sector "
  80.   KEYS = "RWV"
  81.   ROWS = 5
  82.   COLS = 1
  83.   FORE = White
  84.   BACK = Cyan
  85.   MESG = "Select Action|<ESC>=Abort"
  86. MENU_END
  87.  
  88. DIALOG_BEGIN "Out of Range"
  89.   "[Sorry but that Entry is out of Range.|Please Try Again.]"
  90.   TYPE = "[1]"
  91.   OPTS = "OK"
  92. DIALOG_END
  93.  
  94. DIALOG_BEGIN "AbortRetry Dialog"
  95.   "[Error in Operation.||Please Select Action.]"
  96.   TYPE = "[1]"
  97.   OPTS = "[Abort|Retry|Ignore|Fail]"
  98.   KEYS = "ARIF"
  99. DIALOG_END
  100.  
  101. TEXT "Program Name" = "Sector Edit Program, Ver 1.0"
  102.  
  103. TEXT "DevName"      = "Device Name   :"
  104. TEXT "TotBlks"      = "Total Sectors :"
  105.  
  106. TEXT "BPS"          = "Bytes Per Sector    :"
  107. TEXT "SPC"          = "Sectors Per Cluster :"
  108. TEXT "CPD"          = "Clusters Per Drive  :"
  109.  
  110. TEXT "EnterBlk"     = "Enter Sector to Load"
  111.  
  112. TEXT "PressKey"     = "Press any key to Continue"
  113.  
  114. TEXT "Reading"      = "Reading Sector.  One Moment..."
  115. TEXT "Writing"      = "Writing Sector.  One Moment..."
  116. TEXT "View/Edit"    = "Use Arrow Keys to Scroll|<ESC> to Quit"
  117. TEXT "NoMessage"    = " "
  118. TEXT "CurrInfo"     = "Drive : %D     Current Sector : %S"
  119.  
  120. TEXT "GB"           = "Thousand Bytes"
  121. TEXT "KB"           = "KiloByte"
  122. TEXT "MB"           = "MegaByte"
  123.  
  124. TEXT "Block"        = "Sector"
  125.  
  126. INTEGER "One"       = 1
  127. INTEGER "Ten"       = 10
  128. INTEGER "Hundred"   = 100
  129. INTEGER "Thousand"  = 1000
  130.  
  131. INTEGER "Byte"      = 256
  132.  
  133. INTEGER "SectSize"  = 256
  134. INTEGER "BlkSize"   = 512
  135. INTEGER "ClustSize" = 2048
  136. INTEGER "DrvSize"   = 20
  137.  
  138. INTEGER "Kilo"      = 1024
  139. INTEGER "Meg"       = 1048576
  140.  
  141. COLOR "Black"       = 0
  142. COLOR "Blue"        = 1
  143. COLOR "Green"       = 2
  144. COLOR "Cyan"        = 3
  145. COLOR "Red"         = 4
  146. COLOR "Magenta"     = 5
  147. COLOR "Brown"       = 6
  148. COLOR "Lt Gray"     = 7
  149. COLOR "Dk Gray"     = 8
  150. COLOR "Lt Blue"     = 9
  151. COLOR "Lt Green"    = 10
  152. COLOR "Lt Cyan"     = 11
  153. COLOR "Lt Red"      = 12
  154. COLOR "Lt Magenta"  = 13
  155. COLOR "Yellow"      = 14
  156. COLOR "White"       = 15
  157.  
  158. ---FILE END---
  159.  
  160. -*)
  161.  
  162. Unit VResFu;
  163.  
  164. Interface
  165.  
  166. Uses
  167.  
  168.   VTypesu,
  169.   VStringu,
  170.   VGenu,
  171.   VTextu,
  172. {$IFDEF VUI}
  173.   VUIWinu,
  174. {$ENDIF}
  175.   VDOSHu;
  176.  
  177. {────────────────────────────────────────────────────────────────────────────}
  178.  
  179. Procedure VRF_New(                     FName     : ST80;
  180.                                        NMaxLines : INTEGER      );
  181.  
  182. Procedure VRF_NewInMem(    P         : Pointer;
  183.                            Size      : Word;
  184.                            NMaxLines : INTEGER   );
  185.  
  186. Procedure VRF_ChangeSection(           Sec        : STRING );
  187.  
  188. {$IFDEF VUI}
  189.  
  190. Procedure VRF_GetMenu(                 ID         : ST80;
  191.                                    Var Menu       : TMenu;
  192.                                    Var Keys       : ST80;
  193.                                    Var NumChoices : INTEGER;
  194.                                    Var Rows       : INTEGER;
  195.                                    Var Cols       : INTEGER;
  196.                                    Var FC         : INTEGER;
  197.                                    Var BC         : INTEGER;
  198.                                    Var Message    : ST80     );
  199.  
  200. Function  VRF_DoMenu(                  Opts      : ST80;
  201.                                        ID        : ST80;
  202.                                        X         : INTEGER;
  203.                                        Y         : INTEGER;
  204.                                        FC        : INTEGER;
  205.                                        BC        : INTEGER   ) : INTEGER;
  206.  
  207. Function  VRF_DoMenu_Kill(             Opts      : ST80;
  208.                                        ID        : ST80;
  209.                                        X         : INTEGER;
  210.                                        Y         : INTEGER;
  211.                                        FC        : INTEGER;
  212.                                        BC        : INTEGER   ) : INTEGER;
  213.  
  214. Function  VRF_GetDialog(               ID        : ST80      ) : STRING;
  215.  
  216. Procedure VRF_GetView(                 ID        : ST80;
  217.                                    Var Menu      : TMenu;
  218.                                    Var Lines     : INTEGER   );
  219.  
  220.  
  221. {$ENDIF} { ifdef vui }
  222.  
  223. Function  VRF_GetText(                 ID        : ST80      ) : STRING;
  224.  
  225.  
  226.  
  227. Function  VRF_GetInt(                  ID        : ST80      ) : LONGINT;
  228.  
  229. Function  VRF_GetBoolean(              ID        : ST80      ) : BOOLEAN;
  230.  
  231.  
  232. Function  VRF_GetReal(                 ID        : ST80      ) : REAL;
  233.  
  234. Function  VRF_GetColorNum(             ID        : ST80      ) : BYTE;
  235.  
  236. Procedure VRF_Dispose;
  237.  
  238. {────────────────────────────────────────────────────────────────────────────}
  239.  
  240. Implementation
  241.  
  242.  
  243. {$IFDEF VUI}
  244. Uses
  245.  
  246.   VCRTu,
  247.   VUIwidgu;
  248. {$ELSE}
  249. Uses
  250.  
  251.   VCRTu;
  252.  
  253. {$ENDIF}
  254.  
  255.  
  256. Type
  257.  
  258.   TArrayPStr = Array[1..1] of PSTRING;
  259.  
  260.   PArrayPStr = ^TArrayPStr;
  261.  
  262.   TVRF = RECORD
  263.  
  264.     IndexText     : Array[1..600     ] of PSTRING;
  265.     IndexAt       : Array[1..600     ] of INTEGER;
  266.     IndexLines    : INTEGER;
  267.     LastStartLine : INTEGER;
  268.  
  269.     CurSec        : STRING;
  270.  
  271.     MenuText      : PArrayPStr;
  272.     NumLines      : INTEGER;
  273.  
  274.     MaxLines      : INTEGER;
  275.  
  276.   END;
  277.  
  278.   PVRF = ^TVRF;
  279.  
  280. Var
  281.  
  282.   avrf          : PVRF;
  283.  
  284.  
  285. {────────────────────────────────────────────────────────────────────────────}
  286.  
  287. Function GetHeapString( P : POINTER ) : STRING;
  288.  
  289. BEGIN
  290.  
  291.   GetHeapString :=  VStrGet( P );
  292.  
  293. END;
  294.  
  295.  
  296. (*-
  297.  
  298. [FUNCTION]
  299.  
  300. Procedure VRF_Error(                     S         : ST80      );
  301.  
  302. [PARAMETERS]
  303.  
  304. S           Resource File Error Message
  305.  
  306. [RETURNS]
  307.  
  308. (None)
  309.  
  310. [DESCRIPTION]
  311.  
  312. Takes the Provided Resource File Error Message and Displays it in the top
  313. ONLEFT of the Screen.  Then Shuts down the Program.
  314.  
  315. [SEE-ALSO]
  316.  
  317. [EXAMPLE]
  318.  
  319. BEGIN
  320.  
  321.   WriteLn( 'About to Call VRF_Error...' );
  322.  
  323.   VRF_Error( 'Could not find Menu Item' );  { HALTS HERE }
  324.  
  325.   WriteLn( 'Should have never gotten here!' );
  326.  
  327. END;
  328.  
  329. -*)
  330.  
  331. Procedure VRF_Error(                     S         : ST80      );
  332.  
  333. BEGIN
  334.  
  335. {$IFDEF VUI}
  336.   WGemMsgBox( '[4][Pardon me, but the following|'+
  337.                   'resource file error occurred:||' +
  338.                   S +
  339.                   '|This program is stopping.][Sorry ]' );
  340.  
  341.   WClose;
  342.  
  343. {$ELSE}
  344.   WriteStringAt( 1,1,
  345.                  white, black,
  346.                  'ResFile Error: '+S+'--Program Exiting.' );
  347.  
  348. {$ENDIF}
  349.  
  350.  
  351.   Halt( 1 );
  352.  
  353. END;  { VRF_Error }
  354.  
  355. {────────────────────────────────────────────────────────────────────────────}
  356.  
  357. (*-
  358.  
  359. [FUNCTION]
  360.  
  361. Function GetStartLine(                 ID        : ST80      ) : INTEGER;
  362.  
  363. [PARAMETERS]
  364.  
  365. ID          Resource File Item ID Name to search for
  366.  
  367. [RETURNS]
  368.  
  369. The Indexed Line Number which this Item ID Name represents.
  370.  
  371. [DESCRIPTION]
  372.  
  373. Takes the Item ID Name and searches the Pre-Loaded Resource File Data
  374. until it either finds this item or fails to.  If it is found then the
  375. Line Index Number is returned.
  376.  
  377. If not, then this is an Error Condition though nothing happens.
  378.  
  379. [SEE-ALSO]
  380.  
  381. [EXAMPLE]
  382.  
  383. {NOTE: All Examples use Above Demo Resource File}
  384.  
  385. BEGIN
  386.  
  387.   WriteLn( 'Found at Line ',GetStartLine( 'Blue' ) );
  388.  
  389.   { Should have Found this ID on Line x of the example Resource File }
  390.  
  391. END;
  392.  
  393. -*)
  394.  
  395. Function GetStartLine(                 ID        : ST80      ) : INTEGER;
  396.  
  397. Var
  398.  
  399.   Z   : INTEGER;
  400.   SLS : INTEGER;
  401.  
  402.   S   : ST80;
  403.  
  404. BEGIN
  405.  
  406.   With AVRF^ Do
  407.   BEGIN
  408.  
  409.     { fixup ID to include section name }
  410.  
  411.     If ID[1]<>'\' Then
  412.       Insert( CurSec, ID, 1 );
  413.  
  414.  
  415.     Z := LastStartLine-1;
  416.  
  417.     Repeat
  418.       Inc( Z );
  419.       S := GetHeapString( IndexText[Z] );
  420.     Until ( Z > IndexLines ) or
  421.           ( S = ID );
  422.  
  423.  
  424.  
  425.     IF Z > IndexLines Then
  426.     BEGIN
  427.  
  428.       Z:=0;
  429.       Repeat
  430.         Inc( Z );
  431.       Until ( Z > LastStartLine ) or
  432.             ( GetHeapString( IndexText[Z] ) = ID );
  433.  
  434.       If Z > LastStartLine Then
  435.         Z := NumLines+1;
  436.  
  437.     END;
  438.  
  439.     GetStartLine := IndexAt[Z];
  440.  
  441.   END; {with}
  442.  
  443. END;  { GetStartLine }
  444.  
  445. {────────────────────────────────────────────────────────────────────────────}
  446.  
  447. (*-
  448.  
  449. [FUNCTION]
  450.  
  451. Procedure VRF_New(                     FName     : ST80      );
  452.  
  453. [PARAMETERS]
  454.  
  455. FName       Resource File to Load
  456.  
  457. [RETURNS]
  458.  
  459. (None)
  460.  
  461. [DESCRIPTION]
  462.  
  463. Reads the Resource File Data from the given File Name and Loads all
  464. the Data in RAM for Quick Access.
  465.  
  466. [SEE-ALSO]
  467.  
  468. [EXAMPLE]
  469.  
  470. {NOTE: All Examples use Above Demo Resource File}
  471.  
  472. Uses VGen,VWinHigh,VResFile;
  473.  
  474. VAR
  475.   I : INTEGER;
  476.  
  477. BEGIN
  478.  
  479.   WOpen( '▒',BLACK,BLUE,'CLOCK' );
  480.   VRF_New( 'PROGRAM.MNU' );
  481.  
  482.   I := WGemDialogBox( VRF_GetDialog( 'AbortRetry' ) );
  483.  
  484.   WMessage( 'Selection : ' + IntToStr(i) + '|' + VRF_GetText('PressKey'),
  485.             WHITE,CYAN );
  486.   While NOT WKeyPressed Do;
  487.  
  488.   WDispose;
  489.   WClose;
  490.  
  491. END;
  492.  
  493. -*)
  494.  
  495. Procedure VRF_New(                     FName     : ST80;
  496.                                        NMaxLines : INTEGER      );
  497.  
  498. Var
  499.  
  500.   F   : TEXT;
  501.   S   : STRING;
  502.   S2  : STRING;
  503.  
  504.   Sec : STRING;
  505.  
  506.  
  507.   Function CleanUpLine( S : STRING ) : STRING;
  508.  
  509.   BEGIN
  510.  
  511.     {--------------}
  512.     { Zap the tabs }
  513.     {--------------}
  514.  
  515.     S := SR( S, #9, ' ' );  { !^! maybe dis problem later, eh? }
  516.  
  517.     {-------------------------------}
  518.     { Get rid of unnecessary spaces }
  519.     {-------------------------------}
  520.  
  521.     S := TrimChar( S, ONCENTER, ' ' );
  522.  
  523.     CleanUpLine := S;
  524.  
  525.   END;
  526.  
  527. BEGIN
  528.  
  529.  
  530.   {----------------------}
  531.   { get memory for a VRF }
  532.   {----------------------}
  533.  
  534.   New( AVRF );
  535.  
  536.   {-------------------------------------------------}
  537.   { get memory for the array of pointers to strings }
  538.   {-------------------------------------------------}
  539.  
  540.   GetMem( AVRF^.MenuText, 4*NMaxLines );
  541.  
  542.   { do the do }
  543.  
  544.   With AVRF^ Do
  545.   BEGIN
  546.  
  547.  
  548.     MaxLines   := NMaxLines;
  549.  
  550.     NumLines   := 0;
  551.     IndexLines := 0;
  552.  
  553.     {---------------}
  554.     { Open the file }
  555.     {---------------}
  556.  
  557.     If NOT FileExist( FName ) Then
  558.       VRF_Error( FName + ' Not Found!' );
  559.  
  560.     VTextAssign( 0,
  561.                  F,
  562.                  FName );
  563.  
  564.     Reset( F );
  565.  
  566.  
  567.     {-------------------------}
  568.     { look for RESOURCE_BEGIN }
  569.     {-------------------------}
  570.  
  571.     Repeat
  572.       ReadLn( F, S );
  573.     Until (EOF(F)) or (CleanUpLine( S )='RESOURCE_BEGIN');
  574.  
  575.  
  576.     If EOF(F) Then
  577.       VRF_Error('No RESOURCE_BEGIN found.');
  578.  
  579.  
  580.     {---------------------}
  581.     { default section = \ }
  582.     {---------------------}
  583.  
  584.     Sec := '\';
  585.  
  586.     {--------------------------------}
  587.     { loop until EOF or RESOURCE_END }
  588.     {--------------------------------}
  589.  
  590.     Repeat
  591.  
  592.       ReadLn( F, S );
  593.  
  594.       S := CleanUpLine( S );
  595.  
  596.       {-------------------------------------------}
  597.       { If anything is ONLEFT in the line, store it }
  598.       {-------------------------------------------}
  599.  
  600.       If S <> '' Then
  601.       BEGIN
  602.  
  603.         Inc( NumLines );
  604.  
  605.         If NumLines > MaxLines Then
  606.           VRF_Error( 'Exceeded Maximum Menu File Size.' );
  607.  
  608.         MenuText^[NumLines] := VStrNew( S );
  609.  
  610.  
  611.         {------------------------------------}
  612.         { Now we check to see if the line is }
  613.         { a section marker or the beggining  }
  614.         { of a resource.                     }
  615.         {------------------------------------}
  616.  
  617.         S  := UpperString( S );
  618.  
  619.         { is it a section marker? }
  620.  
  621.         If Copy( S, 1, 13) = 'SECTION_BEGIN' Then
  622.         BEGIN
  623.  
  624.           Sec := Sec + GetQuote( S ) + '\';
  625.  
  626.         END
  627.         ELSE
  628.         If Copy( S, 1, 11) = 'SECTION_END' Then
  629.         BEGIN
  630.  
  631.  
  632.           {---------------------------------------------}
  633.           { Truncate everything after the 2nd ending \  }
  634.           { in other words, go back one dir or section. }
  635.           { Could have used PredDir but didnt feel like }
  636.           { using VDOSHIGH                              }
  637.           {---------------------------------------------}
  638.  
  639.           Sec := TruncAfterEnd( TruncAtEnd( Sec, '\' ),
  640.                                 '\'                      );
  641.  
  642.           If Sec='' Then
  643.             VRF_Error('More SECTION_ENDS than SECTION_BEGINS.' );
  644.  
  645.  
  646.         END
  647.         ELSE
  648.         BEGIN
  649.  
  650.           {----------------------------------}
  651.           { Should we put it in the index?   }
  652.           { (is it the start of a resource?) }
  653.           {----------------------------------}
  654.  
  655.           S2 := Copy( S, 1, 4 );
  656.  
  657.           If Length( S2 ) = 4 Then
  658.           BEGIN
  659.  
  660.             If (S2='MENU') or
  661.                (S2='DIAL') or
  662.                (S2='TEXT') or
  663.                (S2='INTE') or
  664.                (S2='VIEW') or
  665.                (S2='BOOL') or
  666.                (S2='REAL') or
  667.                (S2='COLO') Then
  668.             BEGIN
  669.  
  670.               {-----------------------------------------}
  671.               { it is the start of a resource.  Get the }
  672.               { resource name from the quotes, and      }
  673.               { put it into the index.                  }
  674.               {-----------------------------------------}
  675.  
  676.               S := GetQuote( S );
  677.  
  678.               IF Byte(S[0])>0 Then
  679.               BEGIN
  680.  
  681.                 Inc( IndexLines );
  682.  
  683.                 IndexText[ IndexLines ] := VStrNew( Sec+S );
  684.                 IndexAt  [ IndexLines ] := NumLines;
  685.  
  686.               END;  { If Bytes(S[0]) }
  687.  
  688.             END;  { If S2='MENU' }
  689.  
  690.           END;  { If Length(S2) }
  691.  
  692.         END; { if section marker / else }
  693.  
  694.       END;  { If S <> '' }
  695.  
  696.     Until (EOF( F )) or (S='RESOURCE_END');
  697.  
  698.     LastStartLine := IndexLines;
  699.  
  700.     Close( F );
  701.  
  702.     CurSec := '\';
  703.  
  704.   END; {with}
  705.  
  706. END;  { VRF_New }
  707.  
  708. {────────────────────────────────────────────────────────────────────────────}
  709.  
  710. Procedure VRF_ChangeSection(           Sec        : STRING );
  711.  
  712. BEGIN
  713.  
  714.  
  715.    With AVRF^ DO
  716.   BEGIN
  717.  
  718.  
  719.     If Length( Sec )>0 Then
  720.     BEGIN
  721.  
  722.       { make sure string has \ at end }
  723.  
  724.       If Sec[Length(Sec)]<>'\' Then
  725.         Sec := Sec + '\';
  726.  
  727.       {-------------------------------------------}
  728.       { if string starts at root section, replace }
  729.       { cursection with it.  otherwise add the    }
  730.       { section onto cursection.                  }
  731.       {-------------------------------------------}
  732.  
  733.       If Sec[1]='\' Then
  734.         CurSec := Sec
  735.       ELSE
  736.       If Sec[1]='.' Then
  737.       BEGIN
  738.  
  739.         Delete( Sec, 1, 1 );
  740.  
  741.         While Sec[1]='.' Do
  742.         BEGIN
  743.  
  744.           CurSec := TruncAfterEnd( TruncAtEnd( CurSec, '\' ),
  745.                                    '\'                      );
  746.  
  747.           Delete( Sec, 1, 1 );
  748.  
  749.         END;
  750.  
  751.         If CurSec='' Then
  752.           CurSec := '\';
  753.  
  754.         If Sec[1]='\' Then
  755.         BEGIN
  756.  
  757.           Delete( Sec, 1, 1 );
  758.  
  759.           If Length( Sec ) >0 Then
  760.           BEGIN
  761.  
  762.             If Sec[Length(Sec)]<>'\' Then
  763.               Sec:=Sec+'\';
  764.  
  765.             CurSec := CurSec + Sec;
  766.  
  767.           END; { if length(sec)>0 (dir after ..s) }
  768.  
  769.         END; {if sec[1]=\ (dir after ..s) }
  770.  
  771.       END   { if sec[1]=. }
  772.       ELSE
  773.       BEGIN
  774.  
  775.         CurSec := CurSec + Sec
  776.  
  777.       END;
  778.  
  779.     END; { if length(sec)>0 }
  780.  
  781.   END; {with}
  782.  
  783. END;
  784.  
  785. {────────────────────────────────────────────────────────────────────────────}
  786.  
  787. {$IFDEF VUI}
  788.  
  789. (*-
  790.  
  791. [FUNCTION]
  792.  
  793. Procedure VRF_GetMenu(                 ID         : ST80;
  794.                                    Var Menu       : TMenu;
  795.                                    Var Keys       : ST80;
  796.                                    Var NumChoices : INTEGER;
  797.                                    Var Rows       : INTEGER;
  798.                                    Var Cols       : INTEGER;
  799.                                    Var FC         : INTEGER;
  800.                                    Var BC         : INTEGER;
  801.                                    Var Message    : ST80     );
  802.  
  803. [PARAMETERS]
  804.  
  805. ID          Resource File Menu ID Name
  806. Menu        VAR Returned Menu Data
  807. Keys        VAR Returned Active Menu Keys
  808. NumChoices  VAR Returned Number of Menu Choices
  809. Rows        VAR Returned Number of Menu Rows
  810. Cols        VAR Returned Number of Menu Cols
  811. FC          VAR Returned Menu Foreground Color
  812. BC          VAR Returned Menu Background Color
  813. Message     VAR Returned Message Line associated with Menu
  814.  
  815. [RETURNS]
  816.  
  817. Function : None
  818. (VAR     : [Menu] Menu Data)
  819. (VAR     : [Keys] Active Menu Keys)
  820. (VAR     : [NumChoices] Number of Menu Choices)
  821. (VAR     : [Rows] Number of Menu Rows)
  822. (VAR     : [Cols] Number of Menu Cols)
  823. (VAR     : [FC] Menu Foreground Color)
  824. (VAR     : [BC] Menu Background Color)
  825. (VAR     : [Message] WMessage Line associated with Menu)
  826.  
  827. [DESCRIPTION]
  828.  
  829. Searches the Pre-Loaded Resource File Data for the Menu identified by the
  830. ID Name.  When this is found, loads and returns all the Menu Information
  831. associated with this.
  832.  
  833. [SEE-ALSO]
  834.  
  835. VFR_GetDialog
  836. VFR_GetText
  837. VFR_GetInt
  838. VRF_GetColorNumber
  839. VRF_DoMenu
  840. VRF_DoMenu_Kill
  841.  
  842. [EXAMPLE]
  843.  
  844. {NOTE: All Examples use Above Demo Resource File}
  845.  
  846. Uses VGen,VWinHigh,VResFile;
  847.  
  848. VAR
  849.   Menu      : TMenu;
  850.   Keys, Msg : ST80;
  851.   Num,
  852.   Rows,Cols,
  853.   FC,BC,
  854.   I,Start   : INTEGER;
  855.  
  856. BEGIN
  857.  
  858.   WOpen( '▒', BLACK,BLUE, 'CLOCK' );
  859.   VRF_New( 'Program.mnu' );
  860.  
  861.   VRF_Menu( 'Sector Menu', Menu, Keys, Num, Rows, Cols, FC,BC, Msg );
  862.  
  863.   WMessage( Msg, WHITE,CYAN );
  864.   Start := 1;
  865.   I     := WAutoMenu_Kill( Addr( Menu ),
  866.                            Num,
  867.                            Cols,
  868.                            Rows,
  869.                            Keys,
  870.                            X, Y,
  871.                            FC, BC,
  872.                            FC, BC,
  873.                            'Sector Menu',
  874.                            Start );
  875.  
  876.   WMessage( 'Selection : '+IntToStr( i )+'|Press any Key to Quit',
  877.             WHITE,CYAN );
  878.   While NOT WKeyPressed Do;
  879.  
  880.   VRF_Dispose;
  881.   WClose;
  882.  
  883. END;
  884.  
  885. -*)
  886.  
  887. Procedure VRF_GetMenu(                 ID         : ST80;
  888.                                    Var Menu       : TMenu;
  889.                                    Var Keys       : ST80;
  890.                                    Var NumChoices : INTEGER;
  891.                                    Var Rows       : INTEGER;
  892.                                    Var Cols       : INTEGER;
  893.                                    Var FC         : INTEGER;
  894.                                    Var BC         : INTEGER;
  895.                                    Var Message    : ST80     );
  896.  
  897. Var
  898.  
  899.   Z     : INTEGER;
  900.   ZZ    : INTEGER;
  901.   Error : INTEGER;
  902.   S     : ST5;
  903.   S1    : STRING;
  904.   upS1  : STRING;
  905.  
  906.  
  907. BEGIN
  908.  
  909.  
  910.   With AVRF^ DO
  911.   BEGIN
  912.  
  913.     NumChoices := 0;
  914.     Keys       := '';
  915.     Message    := '';
  916.  
  917.     ID := UpperString( ID );
  918.  
  919.     Z := GetStartLine( ID );
  920.  
  921.     If Z > NumLines Then
  922.       VRF_Error( 'Could Not Find Menu "' + ID + '"' );
  923.  
  924.     Rows := 0;
  925.     Cols := 0;
  926.  
  927.     Repeat
  928.  
  929.       Inc( Z );
  930.       S1 := GetHeapString( MenuText^[Z] );
  931.  
  932.       UpS1 := UpperString( S1 );
  933.  
  934.       If S1[1] = '"' Then
  935.       BEGIN
  936.  
  937.         Inc( NumChoices );
  938.  
  939.         Menu[NumChoices] := Copy( S1, 2, Length( S1 ) - 1 );
  940.  
  941.         Menu[NumChoices]:=
  942.                 Copy( Menu[NumChoices], 1, Pos( '"', Menu[NumChoices] ) - 1 );
  943.  
  944.       END;   { Of Then }
  945.  
  946.       {------------------------------------------}
  947.       { Find the keys definition inside the menu }
  948.       {------------------------------------------}
  949.  
  950.       If GetParamName( upS1 ) = 'KEYS' Then
  951.       BEGIN
  952.  
  953.         Keys := GetParamData( S1 );
  954.  
  955.         Keys := TrimChar( Keys, ONLEFT, ' ' );
  956.         Keys := TrimChar( Keys, ONCENTER, '"' );
  957.  
  958.       END;   { Of Then }
  959.  
  960.       {---------------------------------------------}
  961.       { Find the message definition inside the menu }
  962.       {---------------------------------------------}
  963.  
  964.       If GetParamName( upS1 ) = 'MESG' Then
  965.       BEGIN
  966.  
  967.         Message := GetParamData( S1 );
  968.  
  969.         Message := TrimChar( Message, ONLEFT, ' ' );
  970.         Message := TrimChar( Message, ONCENTER, '"' );
  971.  
  972.       END;   { Of Then }
  973.  
  974.       {-----------------------------------------}
  975.       { Find the number of rows inside the menu }
  976.       {-----------------------------------------}
  977.  
  978.       If GetParamName( ups1 ) = 'ROWS' Then
  979.         Rows := StrToInt( GetParamData( upS1 ) );
  980.  
  981.       {--------------------------------------------}
  982.       { Find the number of columns inside the menu }
  983.       {--------------------------------------------}
  984.  
  985.  
  986.       If GetParamName( upS1 ) = 'COLS' Then
  987.         Cols := StrToInt( GetParamData( upS1 ) ) ;
  988.  
  989.       {------------------------------------------------------}
  990.       { Find the foreground color definition inside the menu }
  991.       {------------------------------------------------------}
  992.  
  993.       IF GetParamName( upS1 ) = 'FORE' Then
  994.         FC := WColorFromString( GetParamData( upS1 ) );
  995.  
  996.       {------------------------------------------------------}
  997.       { Find the background color definition inside the menu }
  998.       {------------------------------------------------------}
  999.  
  1000.       IF GetParamName( upS1 ) = 'BACK' Then
  1001.         BC := WColorFromString( GetParamData( upS1 ) );
  1002.  
  1003.     Until ( TrimChar( upS1, ONCENTER, ' ' ) = 'MENU_END' )
  1004.           OR ( Z > NumLines );
  1005.  
  1006.     {----------------------}
  1007.     { Do the goodbye stuff }
  1008.     {----------------------}
  1009.  
  1010.     If Z > NumLines Then
  1011.       VRF_Error( 'Could Not Find End of Menu "' + ID + '"' );
  1012.  
  1013.     If Rows = 0 Then
  1014.       Rows := NumChoices;
  1015.  
  1016.     If Cols = 0 Then
  1017.       Cols := 1;
  1018.  
  1019.  
  1020.   END; {with}
  1021.  
  1022. END;  { VRF_GetMenu }
  1023.  
  1024. {────────────────────────────────────────────────────────────────────────────}
  1025.  
  1026. (*-
  1027.  
  1028. [FUNCTION]
  1029.  
  1030. Function  VRF_GetDialog(               ID        : ST80      ) : STRING;
  1031.  
  1032. [PARAMETERS]
  1033.  
  1034. ID          Resource File Dialog ID Name
  1035.  
  1036. [RETURNS]
  1037.  
  1038. Dialog Box String associated with ID Name
  1039.  
  1040. [DESCRIPTION]
  1041.  
  1042. Searches the Pre-Loaded Resource File Data for the Dialog identified by
  1043. the ID Name.  When this is found, loads and returns the Dialog String
  1044. information associated with this.
  1045.  
  1046. [SEE-ALSO]
  1047.  
  1048. VFR_GetMenu
  1049. VFR_GetText
  1050. VFR_GetInt
  1051. VRF_GetColorNumber
  1052.  
  1053. [EXAMPLE]
  1054.  
  1055. {NOTE: All Examples use Above Demo Resource File}
  1056.  
  1057. Uses VGen,VWinHigh,VResFile;
  1058.  
  1059. VAR
  1060.   S : STRING;
  1061.   I : INTEGER;
  1062.  
  1063. BEGIN
  1064.  
  1065.   WOpen( '▒',BLACK,BLUE,'CLOCK' );
  1066.   VRF_New( 'PROGRAM.MNU' );
  1067.  
  1068.   I := WGemDialogBox( VFR_GetDialog( 'AbortRetry' ) );
  1069.  
  1070.   WMessage( 'Selection : ',IntToStr(i)+'|Press any key to Quit',
  1071.             WHITE,CYAN );
  1072.   While NOT WKeyPressed Do;
  1073.  
  1074.   WDispose;
  1075.   WClose;
  1076.  
  1077. END;
  1078.  
  1079. -*)
  1080.  
  1081. Function  VRF_GetDialog(               ID        : ST80      ) : STRING;
  1082.  
  1083. Var
  1084.  
  1085.   Z          : INTEGER;
  1086.   S          : ST80;
  1087.   S1         : STRING;
  1088.   upS1       : STRING;
  1089.   DiaText    : STRING;
  1090.   DiaType    : ST80;
  1091.   DiaButtons : ST80;
  1092.   DiaKeys    : STRING[10];
  1093.  
  1094. BEGIN
  1095.  
  1096.  
  1097.   With AVRF^ Do
  1098.   BEGIN
  1099.  
  1100.  
  1101.     DiaText    := '';
  1102.     DiaType    := '[0]';
  1103.     DiaButtons := '[Okay ]';
  1104.     DiaKeys    := '[1234]';
  1105.  
  1106.  
  1107.     ID := UpperString( ID );
  1108.  
  1109.     Z := GetStartLine( ID );
  1110.  
  1111.     If Z > NumLines Then
  1112.       VRF_Error( 'Could Not Find Dialog "' + ID + '"' );
  1113.  
  1114.     Repeat
  1115.       Inc( Z );
  1116.  
  1117.       S1 := GetHeapString( MenuText^[Z] );
  1118.  
  1119.       upS1 := UpperString( S1 );
  1120.  
  1121.       If S1[1] = '"' Then
  1122.       BEGIN
  1123.  
  1124.         S := Copy( S1, 2, Length( S1 ) - 1 );
  1125.         S := Copy( S, 1, Pos( '"', S ) - 1 );
  1126.  
  1127.         DiaText := DiaText + S + '|';
  1128.  
  1129.       END;   { Of Then }
  1130.  
  1131.       {-------------------------------------}
  1132.       { Find the dialog box type definition }
  1133.       {-------------------------------------}
  1134.  
  1135.       If GetParamName( upS1 ) = 'TYPE' Then
  1136.       BEGIN
  1137.  
  1138.         S := GetParamData( upS1 );
  1139.  
  1140.         S := TrimChar( S, ONLEFT, ' ' );
  1141.         S := TrimChar( S, ONCENTER, '"' );
  1142.  
  1143.         DiaType := '[' + S + ']';
  1144.  
  1145.       END;   { Of Then }
  1146.  
  1147.       {--------------------------------------}
  1148.       { Find the avaiable options definition }
  1149.       {--------------------------------------}
  1150.  
  1151.       If GetParamName( upS1 ) = 'OPTS' Then
  1152.       BEGIN
  1153.  
  1154.         DiaButtons := GetParamData( upS1 );
  1155.  
  1156.         DiaButtons := TrimChar( DiaButtons, ONLEFT, ' ' );
  1157.         DiaButtons := TrimChar( DiaButtons, ONCENTER, '"' );
  1158.  
  1159.         If DiaButtons[1]<>'[' Then
  1160.           Insert( '[',DiaButtons,1 );
  1161.  
  1162.         If DiaButtons[Length(DiaButtons)]<>']' Then
  1163.           DiaButtons:=DiaButtons+']';
  1164.  
  1165.       END;   { Of Then }
  1166.  
  1167.       {--------------------------}
  1168.       { Find the keys definition }
  1169.       {--------------------------}
  1170.  
  1171.  
  1172.       If GetParamName( upS1 ) = 'KEYS' Then
  1173.       BEGIN
  1174.  
  1175.         DiaKeys := GetParamData( upS1 );
  1176.  
  1177.         DiaKeys := TrimChar( DiaKeys, ONLEFT, ' ' );
  1178.         DiaKeys := TrimChar( DiaKeys, ONCENTER, '"' );
  1179.  
  1180.       END;   { Of Then }
  1181.  
  1182.     Until ( TrimChar( upS1, ONCENTER, ' ' ) = 'DIALOG_END' )
  1183.           OR ( Z > NumLines );
  1184.  
  1185.  
  1186.     {----------------------}
  1187.     { Do the goodbye stuff }
  1188.     {----------------------}
  1189.  
  1190.     If Z > NumLines Then
  1191.       VRF_Error( 'Could Not Find End of Dialog "' + ID + '"' );
  1192.  
  1193.     Delete( DiaText, Length( DiaText ), 1 );
  1194.  
  1195.     VRF_GetDialog := DiaType + '[' + DiaText + ']' + DiaButtons + DiaKeys;
  1196.  
  1197.   END; { with }
  1198.  
  1199. END;  { VRF_GetDialog }
  1200.  
  1201. {────────────────────────────────────────────────────────────────────────────}
  1202.  
  1203. (*-
  1204.  
  1205. [FUNCTION]
  1206.  
  1207.  
  1208. Procedure VRF_GetView(                 ID        : ST80;
  1209.                                    Var Menu      : TMenu;
  1210.                                    Var Lines     : INTEGER   );
  1211.  
  1212. [PARAMETERS]
  1213.  
  1214.  
  1215. [RETURNS]
  1216.  
  1217.  
  1218. [DESCRIPTION]
  1219.  
  1220.  
  1221. [SEE-ALSO]
  1222.  
  1223. [EXAMPLE]
  1224.  
  1225. -*)
  1226.  
  1227.  
  1228. Procedure VRF_GetView(                 ID        : ST80;
  1229.                                    Var Menu      : TMenu;
  1230.                                    Var Lines     : INTEGER   );
  1231.  
  1232.  
  1233.  
  1234. Var
  1235.  
  1236.   Z     : INTEGER;
  1237.   S1    : STRING;
  1238.  
  1239.  
  1240. BEGIN
  1241.  
  1242.  
  1243.   Lines := 0;
  1244.  
  1245.   With AVRF^ DO
  1246.   BEGIN
  1247.  
  1248.     ID := UpperString( ID );
  1249.  
  1250.     Z := GetStartLine( ID );
  1251.  
  1252.     If Z > NumLines Then
  1253.       VRF_Error( 'Could Not Find View "' + ID + '"' );
  1254.  
  1255.     Repeat
  1256.  
  1257.       Inc( Z );
  1258.       S1 := GetHeapString( MenuText^[Z] );
  1259.  
  1260.       If S1[1] = '"' Then
  1261.       BEGIN
  1262.  
  1263.         Inc( Lines );
  1264.  
  1265.         Menu[Lines] := GetQuote( S1 );
  1266.  
  1267.       END;   { Of Then }
  1268.  
  1269.     Until ( UpperString( TrimChar( S1, ONCENTER, ' ' ) )= 'VIEW_END' )
  1270.           OR ( Z > NumLines );
  1271.  
  1272.     {----------------------}
  1273.     { Do the goodbye stuff }
  1274.     {----------------------}
  1275.  
  1276.     If Z > NumLines Then
  1277.       VRF_Error( 'Could Not Find End of VIEW "' + ID + '"' );
  1278.  
  1279.   END; {with}
  1280.  
  1281. END;  { VRF_GetMenu }
  1282.  
  1283. {$ENDIF} { ifdef VUI }
  1284.  
  1285.  
  1286. {────────────────────────────────────────────────────────────────────────────}
  1287.  
  1288.  
  1289. (*-
  1290.  
  1291. [FUNCTION]
  1292.  
  1293. Function  VRF_GetText(                 ID        : ST80      ) : STRING;
  1294.  
  1295. [PARAMETERS]
  1296.  
  1297. ID          File-Text Text ID Name
  1298.  
  1299. [RETURNS]
  1300.  
  1301. Text Associated with the Text ID Name
  1302.  
  1303. [DESCRIPTION]
  1304.  
  1305. Searches the Pre-Loaded File-Text Data for the Text identified by the
  1306. ID Name.  When this is found, loads and returns the Text String
  1307. information associated with this.
  1308.  
  1309. [SEE-ALSO]
  1310.  
  1311. VFR_GetMenu
  1312. VFR_GetDialog
  1313. VFR_GetInt
  1314. VRF_GetColorNumber
  1315.  
  1316. [EXAMPLE]
  1317.  
  1318. {NOTE: All Examples use Above Demo Resource File}
  1319.  
  1320. Uses VWinHigh,VResFile;
  1321.  
  1322. VAR
  1323.   BPS,
  1324.   SPC,
  1325.   CPD : LONGINT;
  1326.  
  1327. BEGIN
  1328.  
  1329.   WOpen( '▒', BLACK,BLUE, 'CLOCK' );
  1330.   VRF_New( 'PROGRAM.MNU' );
  1331.  
  1332.   WPrgName( VRF_Text( 'ProgName' ) );
  1333.   WNew( 10, 5, 40, 15, WHITE,CYAN,WHITE,CYAN, 'Drive Info' )
  1334.  
  1335.   BPS := VRF_GetInt('BlkSize') DIV VRF_GetInt('SectSize')
  1336.   SPC := VRF_GetInt('ClustSize') DIV BPS;
  1337.   CPD := VRF_GetInt('DrvSize') * VRF_GetInt('MB') DIV SPC;
  1338.  
  1339.   WriteLn ( VRF_Text( 'BPS' ), BPS );
  1340.   WriteLn ( VRF_Text( 'SPC' ), SPC );
  1341.   WriteLn ( VRF_Text( 'CPD' ), CPD );
  1342.  
  1343.   WMessage( VRF_GetText( 'PressKey' ), WHITE,CYAN );
  1344.  
  1345.   While NOT WKeyPressed Do;
  1346.  
  1347.   WDispose( 'Drive Info' );
  1348.   VRF_Dispose;
  1349.   WClose;
  1350.  
  1351. END;
  1352.  
  1353. -*)
  1354.  
  1355. Function  VRF_GetText(                 ID        : ST80      ) : STRING;
  1356.  
  1357. Var
  1358.  
  1359.   Z    : INTEGER;
  1360.   S    : STRING;
  1361.   Text : STRING;
  1362.   S1   : STRING;
  1363.  
  1364.   SaveZ: INTEGER;
  1365.  
  1366. BEGIN
  1367.  
  1368.  
  1369.   With AVRF^ Do
  1370.   BEGIN
  1371.  
  1372.     Text := '';
  1373.  
  1374.     ID := UpperString( ID );
  1375.  
  1376.  
  1377.     Z := GetStartLine( ID );
  1378.  
  1379.     If Z > NumLines Then
  1380.       VRF_Error( 'Could Not Find End of Text "' + ID + '"' );
  1381.  
  1382.  
  1383.     If Copy( GetHeapString( MenuText^[Z] ),
  1384.              1,
  1385.              5                             )<> 'TEXT_' Then
  1386.  
  1387.     BEGIN
  1388.  
  1389.       {------------------------------}
  1390.       { We found the text, so get it }
  1391.       {------------------------------}
  1392.  
  1393.       Text := GetHeapString( MenuText^[Z] );
  1394.  
  1395.       {------------------------}
  1396.       { Get just the data part }
  1397.       {------------------------}
  1398.  
  1399.       Text := Copy( Text,
  1400.                     Pos( '=', Text )+1,
  1401.                     255                   );
  1402.  
  1403.       {----------------------------}
  1404.       { trim the spaces and quotes }
  1405.       {----------------------------}
  1406.  
  1407.       Text := TrimChar( Text, ONLEFT, ' ' );
  1408.       Text := TrimChar( Text, ONCENTER, '"' );
  1409.  
  1410.     END   { Of Then }
  1411.     Else
  1412.     BEGIN
  1413.  
  1414.       Repeat
  1415.  
  1416.         Inc( Z );
  1417.  
  1418.         S1 := GetHeapString( MenuText^[Z] );
  1419.  
  1420.         If S1[1] = '"' Then
  1421.         BEGIN
  1422.  
  1423.           Text := Text + TrimChar( S1, ONCENTER, '"' );
  1424.  
  1425.         END;   { Of Then }
  1426.  
  1427.       Until ( UpperString( S1 ) = 'TEXT_END' ) OR ( Z > NumLines );
  1428.  
  1429.       If Z > NumLines Then
  1430.         VRF_Error( 'Could Not Find End of Text "' + ID + '"' );
  1431.  
  1432.     END;   { Of Else }
  1433.  
  1434.     VRF_GetText := SR( Text, '\n', #13 + #10 );
  1435.  
  1436.   END;
  1437.  
  1438. END;   { VRF_GetText }
  1439.  
  1440.  
  1441. {────────────────────────────────────────────────────────────────────────────}
  1442.  
  1443.  
  1444. (*-
  1445.  
  1446. [FUNCTION]
  1447.  
  1448. Function  VRF_GetInt(                  ID        : ST80      ) : LONGINT;
  1449.  
  1450. [PARAMETERS]
  1451.  
  1452. ID          Resource File Integer ID Name
  1453.  
  1454. [RETURNS]
  1455.  
  1456. Integer Value associate with the Integer ID Name
  1457.  
  1458. [DESCRIPTION]
  1459.  
  1460. Searches the resource file data for the integer value identified by the
  1461. ID name, and returns the value.
  1462.  
  1463. [SEE-ALSO]
  1464.  
  1465. VFR_GetMenu
  1466. VFR_GetDialog
  1467. VFR_GetText
  1468. VFR_GetColorNumber
  1469.  
  1470. [EXAMPLE]
  1471.  
  1472. {NOTE: All Examples use demo resource file at top of unit.}
  1473.  
  1474. Uses VWinHigh,VResFile;
  1475.  
  1476. VAR
  1477.   BPS,
  1478.   SPC,
  1479.   CPD : LONGINT;
  1480.  
  1481. BEGIN
  1482.  
  1483.   WOpen( '▒', BLACK,BLUE, 'CLOCK' );
  1484.   VRF_New( 'PROGRAM.MNU' );
  1485.  
  1486.   WPrgName( VRF_Text( 'ProgName' ) );
  1487.   WNew( 10, 5, 40, 15, WHITE,CYAN,WHITE,CYAN, 'Drive Info' )
  1488.  
  1489.   BPS := VRF_GetInt('BlkSize') DIV VRF_GetInt('SectSize')
  1490.   SPC := VRF_GetInt('ClustSize') DIV BPS;
  1491.   CPD := VRF_GetInt('DrvSize') * VRF_GetInt('MB') DIV SPC;
  1492.  
  1493.   WriteLn ( VRF_Text( 'BPS' ), BPS );
  1494.   WriteLn ( VRF_Text( 'SPC' ), SPC );
  1495.   WriteLn ( VRF_Text( 'CPD' ), CPD );
  1496.   WriteLn;
  1497.   WriteLn( 'KiloByte = ', VRF_GetInt( 'KB' ) );
  1498.   WriteLn( 'GigaByte = ', VRF_GetInt( 'GB' ) );
  1499.  
  1500.   WMessage( VRF_GetText( 'PressKey' ), WHITE,CYAN );
  1501.   While NOT WKeyPressed Do;
  1502.  
  1503.   WDispose( 'Drive Info' );
  1504.   VRF_Dispose;
  1505.   WClose;
  1506.  
  1507. END;
  1508.  
  1509. -*)
  1510.  
  1511. Function  VRF_GetInt(                  ID        : ST80      ) : LONGINT;
  1512.  
  1513. Var
  1514.  
  1515.   Z    : INTEGER;
  1516.   S    : ST80;
  1517.   Text : ST80;
  1518.  
  1519. BEGIN
  1520.  
  1521.  
  1522.   With AVRF^DO
  1523.   BEGIN
  1524.  
  1525.     Text := '';
  1526.  
  1527.     ID := UpperString( ID );
  1528.  
  1529.  
  1530.     Z := GetStartLine( ID );
  1531.  
  1532.     If Z > NumLines Then
  1533.       VRF_Error( 'Could Not Find Integer "' + ID + '"' );
  1534.  
  1535.     Text := GetHeapString( MenuText^[Z ] );
  1536.  
  1537.     Text := Copy( Text,
  1538.                   Pos( '=', Text )+1,
  1539.                   255                );
  1540.  
  1541.     Text := TrimChar( Text, ONLEFT, ' ' );
  1542.     Text := TrimChar( Text, ONCENTER, '"' );
  1543.  
  1544.     VRF_GetInt := StrToInt( Text );
  1545.  
  1546.  
  1547.   END; { with }
  1548.  
  1549. END;  { VRF_GetInt }
  1550.  
  1551. {────────────────────────────────────────────────────────────────────────────}
  1552.  
  1553. (*-
  1554.  
  1555. [FUNCTION]
  1556.  
  1557. Function  VRF_GetInt(                  ID        : ST80      ) : LONGINT;
  1558.  
  1559. [PARAMETERS]
  1560.  
  1561. ID          Resource File Integer ID Name
  1562.  
  1563. [RETURNS]
  1564.  
  1565. Integer Value associate with the Integer ID Name
  1566.  
  1567. [DESCRIPTION]
  1568.  
  1569. Searches the resource file data for the boolean value identified by the
  1570. ID name, and returns the value.
  1571.  
  1572. [SEE-ALSO]
  1573.  
  1574. VFR_GetMenu
  1575. VFR_GetDialog
  1576. VFR_GetText
  1577. VFR_GetColorNumber
  1578.  
  1579. [EXAMPLE]
  1580.  
  1581. -*)
  1582.  
  1583.  
  1584. Function  VRF_GetBoolean(              ID        : ST80      ) : BOOLEAN;
  1585.  
  1586.  
  1587. Var
  1588.  
  1589.   Z    : INTEGER;
  1590.   S    : ST80;
  1591.   Text : ST80;
  1592.  
  1593. BEGIN
  1594.  
  1595.  
  1596.   With AVRF^DO
  1597.   BEGIN
  1598.  
  1599.     Text := '';
  1600.  
  1601.     ID := UpperString( ID );
  1602.  
  1603.  
  1604.     Z := GetStartLine( ID );
  1605.  
  1606.     If Z > NumLines Then
  1607.       VRF_Error( 'Could Not Find Boolean "' + ID + '"' );
  1608.  
  1609.     Text := GetHeapString( MenuText^[Z ] );
  1610.  
  1611.     Text := Copy( Text,
  1612.                   Pos( '=', Text )+1,
  1613.                   255                );
  1614.  
  1615.     Text := TrimChar( Text, ONLEFT, ' ' );
  1616.     Text := TrimChar( Text, ONCENTER, '"' );
  1617.     Text := UpperString( TEXT );
  1618.  
  1619.     If (Copy(Text, 1, 1)='T') or
  1620.        (Copy(Text, 1, 1)='Y') or
  1621.        (Text='ON') Then
  1622.       VRF_GetBoolean := TRUE
  1623.     ELSE
  1624.       VRF_GetBoolean := FALSE;
  1625.  
  1626.   END; { with }
  1627.  
  1628. END; { VRF_GetBoolean }
  1629.  
  1630.  
  1631. {────────────────────────────────────────────────────────────────────────────}
  1632.  
  1633. (*-
  1634.  
  1635. [FUNCTION]
  1636.  
  1637. Function  VRF_GetReal(                 ID        : ST80      ) : REAL;
  1638.  
  1639. [PARAMETERS]
  1640.  
  1641. ID          Resource File Integer ID Name
  1642.  
  1643. [RETURNS]
  1644.  
  1645. Real Value associate with the real ID Name
  1646.  
  1647. [DESCRIPTION]
  1648.  
  1649.  
  1650. Searches the resource file data for the real value identified by the
  1651. ID name, and returns the value.
  1652.  
  1653. [SEE-ALSO]
  1654.  
  1655. VFR_GetMenu
  1656. VFR_GetDialog
  1657. VFR_GetText
  1658. VFR_GetColorNumber
  1659.  
  1660. [EXAMPLE]
  1661.  
  1662. -*)
  1663.  
  1664.  
  1665. Function  VRF_GetReal(                 ID        : ST80      ) : REAL;
  1666.  
  1667. Var
  1668.  
  1669.   Z    : INTEGER;
  1670.   S    : ST80;
  1671.   Text : ST80;
  1672.  
  1673. BEGIN
  1674.  
  1675.  
  1676.   With AVRF^DO
  1677.   BEGIN
  1678.  
  1679.     Text := '';
  1680.  
  1681.     ID := UpperString( ID );
  1682.  
  1683.  
  1684.     Z := GetStartLine( ID );
  1685.  
  1686.     If Z > NumLines Then
  1687.       VRF_Error( 'Could Not Find Real "' + ID + '"' );
  1688.  
  1689.     Text := GetHeapString( MenuText^[Z ] );
  1690.  
  1691.     Text := Copy( Text,
  1692.                   Pos( '=', Text )+1,
  1693.                   255                );
  1694.  
  1695.     Text := TrimChar( Text, ONLEFT, ' ' );
  1696.     Text := TrimChar( Text, ONCENTER, '"' );
  1697.  
  1698.     VRF_GetReal := StrToReal( Text );
  1699.  
  1700.  
  1701.   END; { with }
  1702.  
  1703. END; { VRF_GetReal, Man. }
  1704.  
  1705. {────────────────────────────────────────────────────────────────────────────}
  1706.  
  1707. (*-
  1708.  
  1709. [FUNCTION]
  1710.  
  1711. Function  VRF_GetColorNum(             ID        : ST80      ) : BYTE;
  1712.  
  1713. [PARAMETERS]
  1714.  
  1715. ID          Resource File Color ID Name
  1716.  
  1717. [RETURNS]
  1718.  
  1719. Color Value associate with the Color ID Name
  1720.  
  1721. [DESCRIPTION]
  1722.  
  1723. Searches the resource file data for the color value identified by the
  1724. ID name, and returns the value.
  1725.  
  1726. [SEE-ALSO]
  1727.  
  1728. VFR_GetMenu
  1729. VFR_GetDialog
  1730. VFR_GetText
  1731. VFR_GetInt
  1732.  
  1733. [EXAMPLE]
  1734.  
  1735. {NOTE: All Examples use Above Demo Resource File}
  1736.  
  1737. BEGIN
  1738.  
  1739.   VRF_New( 'Program.mnu' );
  1740.  
  1741.   WriteLn( 'Red   = ', VRF_GetColorNum( 'Red' ) );
  1742.   WriteLn( 'Blue  = ', VRF_GetColorNum( 'Green' ) );
  1743.   WriteLn( 'Green = ', VRF_GetColorNum( 'Blue' ) );
  1744.  
  1745.   WriteLn( VRF_GetText( 'PressKey' ) );
  1746.   While NOT WKeyPressed Do;
  1747.  
  1748.   VRF_Dispose;
  1749.  
  1750. END;
  1751.  
  1752. -*)
  1753.  
  1754. Function  VRF_GetColorNum(             ID        : ST80      ) : BYTE;
  1755.  
  1756. Var
  1757.  
  1758.   Z    : INTEGER;
  1759.   S    : ST80;
  1760.   Text : ST80;
  1761.  
  1762. BEGIN
  1763.  
  1764.   With AVRF^ Do
  1765.   BEGIN
  1766.  
  1767.  
  1768.     Text := '';
  1769.  
  1770.     ID := UpperString( ID );
  1771.  
  1772.  
  1773.     Z := GetStartLine( ID )-1;
  1774.  
  1775.     Repeat
  1776.       Inc( Z );
  1777.     Until ( Pos( 'COLOR "' + ID + '"=',
  1778.             UpperString( GetHeapString( MenuText^[Z] ) ) ) <> 0 ) OR
  1779.           ( Z > NumLines );
  1780.  
  1781.     If Z > NumLines Then
  1782.       VRF_Error( 'Could Not Find Color "' + ID + '"' );
  1783.  
  1784.     VRF_GetColorNum := ColorFromString( GetHeapString( MenuText^[Z] ) );
  1785.  
  1786.   END;
  1787.  
  1788. END;  { VRF_GetColorNum }
  1789.  
  1790. {────────────────────────────────────────────────────────────────────────────}
  1791.  
  1792. {$IFDEF VUI}
  1793.  
  1794. (*-
  1795.  
  1796. [FUNCTION]
  1797.  
  1798. Function VRF_DoMenu(                   Opts      : ST80;
  1799.                                        ID        : ST80;
  1800.                                        X         : INTEGER;
  1801.                                        Y         : INTEGER;
  1802.                                        FC        : INTEGER;
  1803.                                        BC        : INTEGER    ) : INTEGER;
  1804.  
  1805. [PARAMETERS]
  1806.  
  1807. Opts        Menu Options
  1808. ID          Resource File Menu ID Name (Also used as Window Name)
  1809. X           Menu X Coordinate
  1810. Y           Menu Y Coordinate
  1811. FC          Overriding Foreground Color (-1 = Use data from File)
  1812. BC          Overriding Background Color (-1 = Use data from File)
  1813.  
  1814. [RETURNS]
  1815.  
  1816. User Menu Item Selection
  1817.  
  1818. [DESCRIPTION]
  1819.  
  1820. Searches the Pre-Loaded Resource File Data for the Menu identified by
  1821. the ID Name.  When this is found, loads and executes the Menu,
  1822. returning the User Menu Selection.
  1823.  
  1824. This Function does not Remove the Created Menu Window from the Screen,
  1825. which must be removed by the programmer manually.  The Window Name is
  1826. the same as the Resource File Menu ID Name.  So be sure that those
  1827. Names are what you would want displayed at the top of a Menu Window.
  1828.  
  1829. [SEE-ALSO]
  1830.  
  1831. VRF_GetMenu
  1832. VRF_DoMenu_Kill
  1833.  
  1834. [EXAMPLE]
  1835.  
  1836. {NOTE: All Examples use Above Demo Resource File}
  1837.  
  1838. Uses VGen,VWinHigh,VResFile;
  1839.  
  1840. VAR
  1841.   I : INTEGER;
  1842.  
  1843. BEGIN
  1844.  
  1845.   WOpen( '▒',BLACK,BLUE,'SHADOW' );
  1846.   VRF_New( 'PROGRAM.MNU' );
  1847.  
  1848.   I := VRF_DoMenu( '', 'Menu Name', 20, 5, -1, -1 );
  1849.  
  1850.   WMessage( 'Selection : '+IntToStr(i)+'|'+VRF_GetText('PressKey'),
  1851.             WHITE, CYAN );
  1852.   While NOT WKeyPressed Do;
  1853.  
  1854.   WDispose( 'Menu Name' );
  1855.   VRF_Dispose;
  1856.   WClose;
  1857.  
  1858. END;
  1859.  
  1860. -*)
  1861.  
  1862. Function VRF_DoMenu(                   Opts      : ST80;
  1863.                                        ID        : ST80;
  1864.                                        X         : INTEGER;
  1865.                                        Y         : INTEGER;
  1866.                                        FC        : INTEGER;
  1867.                                        BC        : INTEGER    ) : INTEGER;
  1868.  
  1869.  
  1870. Var
  1871.  
  1872.   Menu       : TMenu;
  1873.   NumChoices : INTEGER;
  1874.   Rows       : INTEGER;
  1875.   Cols       : INTEGER;
  1876.   Message    : ST80;
  1877.   Keys       : ST80;
  1878.   FC2        : INTEGER;
  1879.   BC2        : INTEGER;
  1880.   FStart     : WORD;
  1881.  
  1882. BEGIN
  1883.  
  1884.  
  1885.   VRF_GetMenu( Id, Menu, Keys, NumChoices, Rows, Cols, FC2, BC2, Message );
  1886.  
  1887.   If FC = -1 Then
  1888.     FC := FC2;
  1889.  
  1890.   If BC = -1 Then
  1891.     BC := BC2;
  1892.  
  1893.   FStart := 1;
  1894.  
  1895.   WMessage( Message, WHITE, BLUE );
  1896.  
  1897.   VRF_DoMenu := WAutoMenu( Addr( Menu ),
  1898.                        NumChoices,
  1899.                        Cols,
  1900.                        Rows,
  1901.                        Keys,
  1902.                        X, Y,
  1903.                        FC, BC,
  1904.                        FC, BC,
  1905.                        Opts + Id,
  1906.                        FStart );
  1907. END;  { VRF_DoMenu }
  1908.  
  1909. {────────────────────────────────────────────────────────────────────────────}
  1910.  
  1911. (*-
  1912.  
  1913. [FUNCTION]
  1914.  
  1915. Function VRF_DoMenu_Kill(              Opts      : ST80;
  1916.                                        ID        : ST80;
  1917.                                        X         : INTEGER;
  1918.                                        Y         : INTEGER;
  1919.                                        FC        : INTEGER;
  1920.                                        BC        : INTEGER   ) : INTEGER;
  1921.  
  1922. [PARAMETERS]
  1923.  
  1924. Opts        Menu Options
  1925. ID          Resource File Menu ID Name  (Also used as Window Name)
  1926. X           Menu X Coordinate
  1927. Y           Menu Y Coordinate
  1928. FC          Overriding Foreground Color (-1 = Use data from File)
  1929. BC          Overriding Background Color (-1 = Use data from File)
  1930.  
  1931. [RETURNS]
  1932.  
  1933. User Menu Item Selection
  1934.  
  1935. [DESCRIPTION]
  1936.  
  1937. Searches the Pre-Loaded Resource File Data for the Menu identified by
  1938. the ID Name.  When this is found, loads and executes the Menu,
  1939. returning the User Menu Selection.  Also removes the Created Menu
  1940. Window from the Screen before returning.
  1941.  
  1942. [SEE-ALSO]
  1943.  
  1944. VRF_GetMenu
  1945. VRF_DoMenu
  1946.  
  1947. [EXAMPLE]
  1948.  
  1949. {NOTE: All Examples use Above Demo Resource File}
  1950.  
  1951. Uses VGen,VWinHigh,VResFile;
  1952.  
  1953. VAR
  1954.   I : INTEGER;
  1955.  
  1956. BEGIN
  1957.  
  1958.   WOpen( '▒',BLACK,BLUE,'SHADOW' );
  1959.   VRF_New( 'PROGRAM.MNU' );
  1960.  
  1961.   I := VRF_DoMenu_Kill( '', 'Menu Name', 20, 5, -1, -1 );
  1962.  
  1963.   WMessage( 'Selection : '+IntToStr(i)+'|'+VRF_GetText('PressKey'),
  1964.             WHITE, CYAN );
  1965.   While NOT WKeyPressed Do;
  1966.  
  1967.   VRF_Dispose;
  1968.   WClose;
  1969.  
  1970. END;
  1971.  
  1972. -*)
  1973.  
  1974. Function VRF_DoMenu_Kill(              Opts      : ST80;
  1975.                                        ID        : ST80;
  1976.                                        X         : INTEGER;
  1977.                                        Y         : INTEGER;
  1978.                                        FC        : INTEGER;
  1979.                                        BC        : INTEGER   ) : INTEGER;
  1980.  
  1981. Var
  1982.  
  1983.   Z : INTEGER;
  1984.  
  1985. BEGIN
  1986.  
  1987.   Z := VRF_DoMenu( Opts, ID, X, Y, FC, BC );
  1988.  
  1989.   WDispose( Opts + ID );
  1990.  
  1991.   VRF_DoMenu_Kill := Z;
  1992.  
  1993. END;  { VRF_DoMenu_Kill }
  1994.  
  1995. {$ENDIF} {ifdef vui}
  1996.  
  1997. {────────────────────────────────────────────────────────────────────────────}
  1998.  
  1999. (*-
  2000.  
  2001. [FUNCTION]
  2002.  
  2003. Procedure VRF_Dispose;
  2004.  
  2005. [PARAMETERS]
  2006.  
  2007. (None)
  2008.  
  2009. [RETURNS]
  2010.  
  2011. (None)
  2012.  
  2013. [DESCRIPTION]
  2014.  
  2015. Deallocates all data Previously Loaded by the
  2016. [SEE-ALSO]
  2017.  
  2018. VRF_New
  2019.  
  2020. [EXAMPLE]
  2021.  
  2022. {NOTE: All Examples use Above Demo Resource File}
  2023.  
  2024. Uses VGen,VWinHigh,VResFile;
  2025.  
  2026. VAR
  2027.   S : STRING;
  2028.   I : INTEGER;
  2029.  
  2030. BEGIN
  2031.  
  2032.   WOpen( '▒',BLACK,BLUE,'CLOCK' );
  2033.   VRF_New( 'PROGRAM.MNU' );
  2034.  
  2035.   S := VFR_GetDialog( 'AbortRetry' );
  2036.  
  2037.   I := WGemDialogBox( S );
  2038.  
  2039.   WMessage( 'Selection : ',IntToStr(i)+'|Press any key to Quit',
  2040.             WHITE,CYAN );
  2041.   While NOT WKeyPressed Do;
  2042.  
  2043.   WDispose;
  2044.   WClose;
  2045.  
  2046. END;
  2047.  
  2048. -*)
  2049.  
  2050. Procedure VRF_Dispose;
  2051.  
  2052. Var
  2053.  
  2054.   Z : INTEGER;
  2055.  
  2056. BEGIN
  2057.  
  2058.   With AVRF^ Do
  2059.   BEGIN
  2060.  
  2061.     For Z := Numlines DownTo 1 Do
  2062.     BEGIN
  2063.  
  2064.       Dispose( MenuText^[Z] );
  2065.       MenuText^[Z] := NIL;
  2066.  
  2067.     END;   { Of For }
  2068.  
  2069.     NumLines := 0;
  2070.  
  2071.   END;
  2072.  
  2073.   Dispose( AVRF );
  2074.  
  2075.   AVRF := NIL;
  2076.  
  2077. END;  { VRF_Dispose }
  2078.  
  2079. {────────────────────────────────────────────────────────────────────────────}
  2080.  
  2081. (*-
  2082.  
  2083. [FUNCTION]
  2084.  
  2085. Procedure VRF_NewInMem(    P         : Pointer;
  2086.                            Size      : Word;
  2087.                            NMaxLines : INTEGER   );
  2088.  
  2089. [PARAMETERS]
  2090.  
  2091. P         :  Pointer to where the VRF is in memory
  2092. Size      :  When doing a DIR *.VRF the size of it, you put here.
  2093. NMaxLines :  Maximum number of lines in VRF.
  2094.  
  2095. [RETURNS]
  2096.  
  2097. (None)
  2098.  
  2099. [DESCRIPTION]
  2100.  
  2101. Reads the Resource File Data from the given memory location and Loads all
  2102. the Data in RAM for Quick Access.
  2103.  
  2104. [SEE-ALSO]
  2105.  
  2106. VNew
  2107.  
  2108. [EXAMPLE]
  2109.  
  2110. {NOTE: All Examples use Above Demo Resource File}
  2111.  
  2112. Uses VGen,VWinHigh,VResFile;
  2113.  
  2114. VAR
  2115.   I : INTEGER;
  2116.  
  2117. BEGIN
  2118.  
  2119.   WOpen( '▒',BLACK,BLUE,'CLOCK' );
  2120.   VRF_NewInMenu( @VRFFILE, 21107 ,2000 );
  2121.  
  2122.   I := WGemDialogBox( VRF_GetDialog( 'AbortRetry' ) );
  2123.  
  2124.   WMessage( 'Selection : ' + IntToStr(i) + '|' + VRF_GetText('PressKey'),
  2125.             WHITE,CYAN );
  2126.   While NOT WKeyPressed Do;
  2127.  
  2128.   WDispose;
  2129.   WClose;
  2130.  
  2131. END;
  2132.  
  2133. -*)
  2134.  
  2135. Procedure VRF_NewInMem(    P         : Pointer;
  2136.                            Size      : Word;
  2137.                            NMaxLines : INTEGER   );
  2138.  
  2139. Type
  2140.    pBuffer = ^TBuffer;
  2141.    TBuffer = Array[0..64000] of Char;
  2142.  
  2143. Var
  2144.  
  2145.   F      : TEXT;
  2146.   S      : STRING;
  2147.   S2     : STRING;
  2148.  
  2149.   Sec    : STRING;
  2150.   Buff   : pBuffer;
  2151.   Offset : Word;
  2152.  
  2153.  
  2154.   Function ReadALineFromMem : STRING;
  2155.   Var
  2156.      S : STRING;
  2157.   Begin
  2158.      S := '';
  2159.      Repeat
  2160.         if buff^[Offset]<>#13 then
  2161.         Begin
  2162.            s := s + buff^[Offset];
  2163.            Inc(Offset);
  2164.         end;
  2165.      Until (Offset > Size) or (Buff^[Offset] = #13);
  2166.      Inc(Offset);
  2167.      if buff^[Offset] = #10 then
  2168.         inc(Offset);
  2169.      ReadALineFromMem := s;
  2170.  
  2171.   End;
  2172.  
  2173.   Function EOFile : Boolean;
  2174.   Begin
  2175.      Eofile := (Offset >= Size);
  2176.   End;
  2177.  
  2178.   Function CleanUpLine( S : STRING ) : STRING;
  2179.  
  2180.   BEGIN
  2181.  
  2182.     {--------------}
  2183.     { Zap the tabs }
  2184.     {--------------}
  2185.  
  2186.     S := SR( S, #9, ' ' );  { !^! maybe dis problem later, eh? }
  2187.  
  2188.     {-------------------------------}
  2189.     { Get rid of unnecessary spaces }
  2190.     {-------------------------------}
  2191.  
  2192.     S := TrimChar( S, ONCENTER, ' ' );
  2193.  
  2194.     CleanUpLine := S;
  2195.  
  2196.   END;
  2197.  
  2198. BEGIN
  2199.  
  2200.   Offset := 0;
  2201.   Buff   := pBuffer( p );
  2202.  
  2203.   {----------------------}
  2204.   { get memory for a VRF }
  2205.   {----------------------}
  2206.  
  2207.   New( AVRF );
  2208.  
  2209.   {-------------------------------------------------}
  2210.   { get memory for the array of pointers to strings }
  2211.   {-------------------------------------------------}
  2212.  
  2213.   GetMem( AVRF^.MenuText, 4*NMaxLines );
  2214.  
  2215.   { do the do }
  2216.  
  2217.   With AVRF^ Do
  2218.   BEGIN
  2219.  
  2220.  
  2221.     MaxLines   := NMaxLines;
  2222.  
  2223.     NumLines   := 0;
  2224.     IndexLines := 0;
  2225.  
  2226.  
  2227.     {-------------------------}
  2228.     { look for RESOURCE_BEGIN }
  2229.     {-------------------------}
  2230.  
  2231.     Repeat
  2232.       S := ReadALineFromMem;
  2233.     Until (EOFile) or (CleanUpLine( S )='RESOURCE_BEGIN');
  2234.  
  2235.  
  2236.     If EOFile Then
  2237.       VRF_Error('No RESOURCE_BEGIN found.');
  2238.  
  2239.  
  2240.     {---------------------}
  2241.     { default section = \ }
  2242.     {---------------------}
  2243.  
  2244.     Sec := '\';
  2245.  
  2246.     {--------------------------------}
  2247.     { loop until EOF or RESOURCE_END }
  2248.     {--------------------------------}
  2249.  
  2250.     Repeat
  2251.  
  2252.       s := ReadALineFromMem;
  2253.  
  2254.       S := CleanUpLine( S );
  2255.  
  2256.       {-------------------------------------------}
  2257.       { If anything is ONLEFT in the line, store it }
  2258.       {-------------------------------------------}
  2259.  
  2260.       If S <> '' Then
  2261.       BEGIN
  2262.  
  2263.         Inc( NumLines );
  2264.  
  2265.         If NumLines > MaxLines Then
  2266.           VRF_Error( 'Exceeded Maximum Menu File Size.' );
  2267.  
  2268.         MenuText^[NumLines] := VStrNew( S );
  2269.  
  2270.  
  2271.         {------------------------------------}
  2272.         { Now we check to see if the line is }
  2273.         { a section marker or the beggining  }
  2274.         { of a resource.                     }
  2275.         {------------------------------------}
  2276.  
  2277.         S  := UpperString( S );
  2278.  
  2279.         { is it a section marker? }
  2280.  
  2281.         If Copy( S, 1, 13) = 'SECTION_BEGIN' Then
  2282.         BEGIN
  2283.  
  2284.           Sec := Sec + GetQuote( S ) + '\';
  2285.  
  2286.         END
  2287.         ELSE
  2288.         If Copy( S, 1, 11) = 'SECTION_END' Then
  2289.         BEGIN
  2290.  
  2291.  
  2292.           {---------------------------------------------}
  2293.           { Truncate everything after the 2nd ending \  }
  2294.           { in other words, go back one dir or section. }
  2295.           { Could have used PredDir but didnt feel like }
  2296.           { using VDOSHIGH                              }
  2297.           {---------------------------------------------}
  2298.  
  2299.           Sec := TruncAfterEnd( TruncAtEnd( Sec, '\' ),
  2300.                                 '\'                      );
  2301.  
  2302.           If Sec='' Then
  2303.             VRF_Error('More SECTION_ENDS than SECTION_BEGINS.' );
  2304.  
  2305.  
  2306.         END
  2307.         ELSE
  2308.         BEGIN
  2309.  
  2310.           {----------------------------------}
  2311.           { Should we put it in the index?   }
  2312.           { (is it the start of a resource?) }
  2313.           {----------------------------------}
  2314.  
  2315.           S2 := Copy( S, 1, 4 );
  2316.  
  2317.           If Length( S2 ) = 4 Then
  2318.           BEGIN
  2319.  
  2320.             If (S2='MENU') or
  2321.                (S2='DIAL') or
  2322.                (S2='TEXT') or
  2323.                (S2='INTE') or
  2324.                (S2='VIEW') or
  2325.                (S2='BOOL') or
  2326.                (S2='REAL') or
  2327.                (S2='COLO') Then
  2328.             BEGIN
  2329.  
  2330.               {-----------------------------------------}
  2331.               { it is the start of a resource.  Get the }
  2332.               { resource name from the quotes, and      }
  2333.               { put it into the index.                  }
  2334.               {-----------------------------------------}
  2335.  
  2336.               S := GetQuote( S );
  2337.  
  2338.               IF Byte(S[0])>0 Then
  2339.               BEGIN
  2340.  
  2341.                 Inc( IndexLines );
  2342.  
  2343.                 IndexText[ IndexLines ] := VStrNew( Sec+S );
  2344.                 IndexAt  [ IndexLines ] := NumLines;
  2345.  
  2346.               END;  { If Bytes(S[0]) }
  2347.  
  2348.             END;  { If S2='MENU' }
  2349.  
  2350.           END;  { If Length(S2) }
  2351.  
  2352.         END; { if section marker / else }
  2353.  
  2354.       END;  { If S <> '' }
  2355.  
  2356.     Until (EOFile) or (S='RESOURCE_END');
  2357.  
  2358.     LastStartLine := IndexLines;
  2359.  
  2360.     CurSec := '\';
  2361.  
  2362.   END; {with}
  2363.  
  2364. END;  { VRF_New }
  2365.  
  2366. {────────────────────────────────────────────────────────────────────────────}
  2367. {────────────────────────────────────────────────────────────────────────────}
  2368.  
  2369. BEGIN
  2370.  
  2371.   AVRF := NIL;
  2372.  
  2373. END.
  2374.