×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Number to string in APDL

Number to string in APDL

Number to string in APDL

(OP)
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?

RE: Number to string in APDL

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources