OK, it is Friday afternoon and if I do not write something soon the week will be missed. We did not do a seminar this week so I can not just post the notes and some comments from the webinar, bummer. All of the real tech support people at PADT have been busy with training, mentoring and doing tech support, so they did not kick anything out. So that leaves me to come up with something. So, as is usually with me, I looked for something I felt guilty or ashamed of. Because that is the way my brain works.
And I remembered that two posting ago I put out a piece of junk macro that printed out tables, as part of the second article on tables in APDL. Although it worked it was brute force and it used a bunch of *if statements to determine how many columns to write. Ugly.
While I was extruding that particular piece of bodily waste something in the back of my mind said that APDL had an undocumented command that would suppress a line-feed on a *VWRITE. This is what one does with ‘C’ and other languages invented after the 1970’s. If you suppress the line-feed, you can just loop over the number of columns.
Next step, go to the help and see if it is there is some clue as to if that tickle in my brain was valid. I found a posting on XANSYS from 2004… by some guy name Eric Miller… Go figure.
There are two descriptors that are not documented in the help: ‘/’ and ‘$’.
‘/’ adds a newline, and ‘$’ suppresses it. So if I want to write out the values in a 1D array all on one line but I don’t know how long the array is I can do:
myar(1) = 1,2,3,4,5,6,7,8,9,10
So, extrapolating this, we can rewrite the nothing-to-be-proud about old wrttbl.mac with
ttbl = arg1 ! Get the name of the table you want to write
fname = arg2 ! get the name of the file to write to
*get,nrw,parm,%ttbl%,dim,X ! Get the size of the table
*get,xax,parm,%ttbl%,var,1 ! Get the names of the columns
*cfopen,%fname% !Open the file
*vwrite,ttbl,xax,yax ! Write a header (note / to add a line)
('Table: ',A,' ',A,' vs ',A,/)
*vwrite ! write 10 spaces, then don't write a new line by using $
*do,jj,1,ncl ! Loop on each column, writing out the column value ($ again)
*vwrite !You need a line feed now that you are done, just write a space
*vwrite !Write a line of dashes to seperate the header, with a pipe
(10x,'|',$) ! to seperate the row values
*do,ii,1,nrw !Now write the values, looping on each row, then each column
Have a great weekend!