XANSYS Message: 41213 [Go back to message list] [bookmark on del.icio.us]
No rating yet Subject: Re: [APDL] *vread with mixed character/number array Author: John Swanson Date: 2002-08-28 09:38:00For those following this thread, here is a demonstration of my proposed improvements.
John Swanson Swanson Analysis Services, Inc.
***** test of /inquire and *vread improvements ***** 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 C*** get the number of lines in the file 21 /inquire,a,line,x,inp 22 C*** get the location of the first 'set' 23 /inquire,b,loc,x,inp,,set,0 24 C*** get the location of the second 'set' 25 /inquire,c,loc,x,inp,,set,b 26 27 *dim,vect,,3 28 C*** read in the data from set 1 29 *vread,vect(1),x,inp,,IJK,3,,,b,1 30 (f6.0) 31 x=_return 32 *stat,vect(1) 33 34 c*** read in the data from set 2 35 *vread,vect(1),x,inp,,IJK,3,,,c,1 36 (f6.0) 37 x=_return 38 *stat,vect(1) 39 40 c*** put the data from lines b+1 (3) to c (8) into character array 41 *sread,a1,x,inp,,,b+1,c 42 x=_return 43 *stat,a1(1,1) 44 45 /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
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
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)