XANSYS Message: 41271 [Go back to message list] [bookmark on del.icio.us]
No rating yet Subject: Re: [APDL] *vread with mixed character/number array Author: Fernand Thomassy Date: 2002-08-29 11:02:00John,
Maybe I missed this but I would suggest /INQUIRE,,LOC,, return a zero if the string is not found.
Kind regards . . . Fern
Fernand A. Thomassy, P.E. Principal Engineer Engine Design Section Southwest Research Institute mailto:fernand.thomassy@s... http://enginedesign.swri.org
> -----Original Message----- > From: John Swanson [mailto:john.swanson@a...] > Sent: Wednesday, 28 August, 2002 5:57 PM > To: 'xansys@yahoogroups.com' > Subject: RE: [xansys] [APDL] *vread with mixed character/number array
> Here is a documented version of the demonstration problem.
> ***** demo of *vread, /inquire, and *sread enhancements ***** jas
> 1 /BATCH,list > 2 > 3 *create,x,inp > 4 ! test input file > 5 !set 1 > 6 1.0 > 7 ! > 8 2.0 > 9 ! this is a blank line > 10 3.0 > 11 !set 2 > 12 11.0!comment allowed > 13 just text > 14 12.0 > 15 ! > 16 13.0 > 17 *end > 18 *list,x,inp > 19 > 20 /com > 21 /com ********** /INQUIRE addition of LOC for location > of string > in file > 22 /com /INQUIRE, Parameter, LABEL, Fname, Ext, > Directory,String32,nSkip > 23 /com LABEL = 'EXIST' - 0, file does not exist 1, exists > 24 /com 'DATE' - yyyymmdd.hhmmss > 25 /com 'SIZE' - size in MB > 26 /com 'WRITE' - 0, no permission 1, write > permission > 27 /com 'READ' - 0, no permission 1, read > permission > 28 /com 'EXEC' = 0, no permission > 1, execute > permission > 29 /com 'LINE' - Number of lines in > text file > 30 /com (NEW) 'LOC ' - Line number contining first > String32 after nSkip > 31 > 32 C*** get the number of lines in the file > 33 /inquire,a,line,x,inp > 34 C*** get the location of the first 'set' > 35 /inquire,b,loc,x,inp,,set,0 > 36 C*** get the location of the second 'set' > 37 /inquire,c,loc,x,inp,,set,b > 38 > 39 /com > 40 /com *vread documentation change ***** (add nPer) ***** > 41 /com 1 2 3 4 5 6 7 > 8 9 10 > 11 > 42 /com *vread,ParR(1),file,ext,dir,{IJK|JKI|KIJ|etc},n1,n2,n3, > nskip, nPer > 43 /com (((ParR(i,j,k),k=1,n1),i=1,n2),j=1,n3) (for (KIJ) > 44 /com if nPer gt 0, then (NEW) > 45 /com nPer is the number of items to read per line > (consistant > with fmt) > 46 /com Blank lines are ignored > 47 /com ! is a comment character > 48 /com Invalid data (characters) in a numeric field > causes line > to be > 49 /com ignored > 50 > 51 *dim,vect,,3 > 52 C*** read in the data from set 1 > 53 *vread,vect(1),x,inp,,IJK,3,,,b,1 > 54 (f6.0) > 55 x=_return > 56 *stat,vect(1) > 57 > 58 c*** read in the data from set 2 > 59 *vread,vect(1),x,inp,,IJK,3,,,c,1 > 60 (f6.0) > 61 x=_return > 62 *stat,vect(1) > 63 > 64 /com > 65 /com *SREAD,StrArray,Fname,Fext,Fdir,[nchar],nSkip,nLines > 66 /com ***** *SREAD documentation change (add nSkip,nLines)
> 67 > 68 c*** get the data from nSkip+1 (b+1) for 8 lines into character > array a1 > 69 *sread,a1,x,inp,,,b,8 > 70 x=_return > 71 *stat,a1(1,1) > 72 > 73 /eof
> START CREATE BY COPY FROM INPUT TO x.inp
> END FILE CREATE
> LISTING OF THE DATA ON FILE x.inp > ! test input file > !set 1 > 1.0 > ! > 2.0 > ! this is a blank line > 3.0 > !set 2 > 11.0!comment allowed > just text > 12.0 > ! > 13.0
> ********** /INQUIRE addition of LOC for location of string in file > /INQUIRE, Parameter, LABEL, Fname, Ext, Directory,String32,nSkip > LABEL = 'EXIST' - 0, file does not exist 1, exists > 'DATE' - yyyymmdd.hhmmss > 'SIZE' - size in MB > 'WRITE' - 0, no permission 1, write permission > 'READ' - 0, no permission 1, read permission > 'EXEC' = 0, no permission 1, execute permission > 'LINE' - Number of lines in text file > (NEW) 'LOC ' - Line number contining first String32 > after nSkip
> C*** get the number of lines in the file
> PARAMETER A = 13.000000
> C*** get the location of the first 'set'
> PARAMETER B = 2.000000
> C*** get the location of the second 'set'
> PARAMETER C = 8.000000
> *vread documentation change ***** (add nPer) ***** > 1 2 3 4 5 6 7 8 9 10 11 > *vread,ParR(1),file,ext,dir,{IJK|JKI|KIJ|etc},n1,n2,n3, nskip, nPer > (((ParR(i,j,k),k=1,n1),i=1,n2),j=1,n3) (for (KIJ) > if nPer gt 0, then (NEW) > nPer is the number of items to read per line (consistant with fmt) > Blank lines are ignored > ! is a comment character > Invalid data (characters) in a numeric field causes line to be > ignored
> SET PARAMETER DIMENSIONS ON VECT TYPE=ARRA DIMENSIONS= 3 > 1 1
> C*** read in the data from set 1
> VECTOR READ OPERATION *VREAD > VECT READ FROM FILE x.inp > VECTOR LENGTH= 3 > LOOP DIRECTIONS=IJK COUNTS= 3 1 1 > NUMBER OF LINES TO SKIP AT START OF FILE= 2 > NUMBER OF FIELDS PER LINE= 1 > FORMAT=(f6.0)
> VECTOR READ OPERATION *VREAD > VECT READ FROM FILE x.inp > VECTOR LENGTH= 3 > LOOP DIRECTIONS=IJK COUNTS= 3 1 1 > NUMBER OF LINES TO SKIP AT START OF FILE= 8 > NUMBER OF FIELDS PER LINE= 1 > FORMAT=(f6.0)