Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Number to string in APDL

Status
Not open for further replies.

Grancha

Industrial
Aug 19, 2011
9
I'm trying to save a bitmap of the ANSYS screen using /IMAGE each time a loop in my program runs. I would like to use a couple of variable values in the filename so the correct image can be found later. The following code does exactly that, but causes an error dialog box to appear, meaning the code will not run through without user intervention every loop:

/IMAGE,SAVE,%var1%_%var2%,bmp,

where var1 and var2 are the variable names (doubles).

The error reads "Missing separator between fields", but the images are saved correctly, and as long as the error messages are dismissed each loop the code runs correctly.

As a workaround I tried saving the variables as strings first, then concatenating them as below, however this does not work and I think it is because the way I am converting the numbers to strings is incorrect:

str1 = %var1%
str2 = %var2%
str3 = strcat(str1,str2)
/IMAGE,SAVE,str3,bmp,

What is the best way to convert numbers to strings in APDL?
 
Replies continue below

Recommended for you

I've figured this out already, the number can be converted to string using CHRVAL(), so the code below works:

str1 = strcat(chrval(var1),'_')
str2 = strcat(str1,chrval(var2))
/IMAGE,SAVE,str2,bmp

/IMAGE does not need the % operator to read the value of the string, it will use the string value instead of the string name anyway. CHRVAL() gives the number without scientific notation however, i.e. 3e-03 is output as 0.003.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor