home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a075 / 1.img / TOOLKIT1.EXE / SST338.PRG < prev    next >
Encoding:
Text File  |  1989-08-23  |  2.9 KB  |  94 lines

  1. *******************
  2.  
  3. FUNCTION O_arrays   && Sst338.prg
  4.  
  5.    PARAMETERS _mastar, _thefile, _ismast
  6.  
  7.    IF PCOUNT() < 1
  8.       RETURN(.F.)
  9.    ELSEIF PCOUNT() = 1
  10.       IF TYPE("_mastar") != "A"
  11.          RETURN(.F.)
  12.       ENDIF
  13.       _thefile = ""
  14.       _ismast = .F.
  15.    ELSEIF PCOUNT() = 2
  16.       IF TYPE("_mastar") + TYPE("_thefile") != "CC"
  17.          RETURN(.F.)
  18.       ENDIF
  19.       IF !FILE(_thefile)
  20.          RETURN(.F.)
  21.       ENDIF
  22.       _ismast = .F.
  23.    ELSE
  24.       IF TYPE("_mastar") + TYPE("_thefile") + TYPE("_ismast") != "CCL"
  25.          RETURN(.F.)
  26.       ENDIF
  27.       IF !FILE(_thefile)
  28.          RETURN(.F.)
  29.       ENDIF
  30.    ENDIF
  31.       
  32.    PRIVATE _fhandle, _line, _end, _char, _vals, _count, _elemn
  33.  
  34.    IF _ismast                             && If this is a master array
  35.  
  36.       _cnt = O_Asize(_thefile)
  37.  
  38.       IF !EMPTY(_cnt)                  
  39.          PUBLIC &_mastar.[_cnt]                && Initialize the master array
  40.          AFILL(&_mastar., "")
  41.          O_asize(_thefile, &_mastar.)
  42.       ENDIF
  43.       RETURN(.T.)
  44.    ELSE
  45.       * if one parameter, it is assumed that the array element has the name
  46.       * of the file to read tagged to the individual array element; otherwise,
  47.       * go to the disk with the name of the file that is provided.
  48.       * if <expC> is an array, then the individual elements will be pased
  49.       * and if the listed associated file is available, the array will be
  50.       * created and the information read.  If not an individual array, then
  51.       * the associated file has to be passed to the function.
  52.       IF TYPE("_mastar") = "A"
  53.          FOR _qaz = 1 TO LEN(_mastar)
  54.             _temp = _mastar[_qaz]
  55.             _name = Parsing(@_temp,";")
  56.             _temp = SUBSTR(LTRIM(TRIM(_temp)), 1, 12)
  57.             _mastar[_qaz] = _name  && Since we are re-writing the value of
  58.                                    && the array at this subscript position,
  59.                                    && this may be neccessary to avoid          
  60.                                    && excessive parsing of the original value.
  61.             IF !FILE(_temp)
  62.                RETURN(.F.)
  63.             ENDIF
  64.             _size = O_asize(_temp)
  65.             IF !EMPTY(_size)
  66.                PUBLIC &_name.[_size] 
  67.                AFILL(&_name., "")
  68.                O_asize(_temp, &_name)
  69.             ELSE
  70.                RETURN(.F.)
  71.             ENDIF
  72.          NEXT
  73.       ELSE
  74.          IF TYPE("_thefile") != "C"
  75.             RETURN(.F.)
  76.          ELSEIF !FILE(_thefile)
  77.             RETURN(.F.)
  78.          ENDIF
  79.          _size = O_asize(_thefile)
  80.          IF !EMPTY(_size)
  81.             _name = Parsing(_mastar, ";")
  82.             PUBLIC &_name.[_size]
  83.             AFILL(&_name., "")
  84.             * now fill the array with the elements
  85.             O_asize(_thefile, &_name.)
  86.          ELSE
  87.             RETURN(.F.)
  88.          ENDIF
  89.       ENDIF
  90.    ENDIF
  91.    RETURN(.T.)
  92.  
  93. * End of File
  94.