home *** CD-ROM | disk | FTP | other *** search
- *******************
-
- FUNCTION O_arrays && Sst338.prg
-
- PARAMETERS _mastar, _thefile, _ismast
-
- IF PCOUNT() < 1
- RETURN(.F.)
- ELSEIF PCOUNT() = 1
- IF TYPE("_mastar") != "A"
- RETURN(.F.)
- ENDIF
- _thefile = ""
- _ismast = .F.
- ELSEIF PCOUNT() = 2
- IF TYPE("_mastar") + TYPE("_thefile") != "CC"
- RETURN(.F.)
- ENDIF
- IF !FILE(_thefile)
- RETURN(.F.)
- ENDIF
- _ismast = .F.
- ELSE
- IF TYPE("_mastar") + TYPE("_thefile") + TYPE("_ismast") != "CCL"
- RETURN(.F.)
- ENDIF
- IF !FILE(_thefile)
- RETURN(.F.)
- ENDIF
- ENDIF
-
- PRIVATE _fhandle, _line, _end, _char, _vals, _count, _elemn
-
- IF _ismast && If this is a master array
-
- _cnt = O_Asize(_thefile)
-
- IF !EMPTY(_cnt)
- PUBLIC &_mastar.[_cnt] && Initialize the master array
- AFILL(&_mastar., "")
- O_asize(_thefile, &_mastar.)
- ENDIF
- RETURN(.T.)
- ELSE
- * if one parameter, it is assumed that the array element has the name
- * of the file to read tagged to the individual array element; otherwise,
- * go to the disk with the name of the file that is provided.
- * if <expC> is an array, then the individual elements will be pased
- * and if the listed associated file is available, the array will be
- * created and the information read. If not an individual array, then
- * the associated file has to be passed to the function.
- IF TYPE("_mastar") = "A"
- FOR _qaz = 1 TO LEN(_mastar)
- _temp = _mastar[_qaz]
- _name = Parsing(@_temp,";")
- _temp = SUBSTR(LTRIM(TRIM(_temp)), 1, 12)
- _mastar[_qaz] = _name && Since we are re-writing the value of
- && the array at this subscript position,
- && this may be neccessary to avoid
- && excessive parsing of the original value.
- IF !FILE(_temp)
- RETURN(.F.)
- ENDIF
- _size = O_asize(_temp)
- IF !EMPTY(_size)
- PUBLIC &_name.[_size]
- AFILL(&_name., "")
- O_asize(_temp, &_name)
- ELSE
- RETURN(.F.)
- ENDIF
- NEXT
- ELSE
- IF TYPE("_thefile") != "C"
- RETURN(.F.)
- ELSEIF !FILE(_thefile)
- RETURN(.F.)
- ENDIF
- _size = O_asize(_thefile)
- IF !EMPTY(_size)
- _name = Parsing(_mastar, ";")
- PUBLIC &_name.[_size]
- AFILL(&_name., "")
- * now fill the array with the elements
- O_asize(_thefile, &_name.)
- ELSE
- RETURN(.F.)
- ENDIF
- ENDIF
- ENDIF
- RETURN(.T.)
-
- * End of File