MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Is There a Way to See Whether a Variable is Defined?

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
RoyKMathur
Beginner


Joined: 05 Jan 2012
Posts: 47
Topics: 11

PostPosted: Fri Mar 14, 2014 1:02 pm    Post subject: Is There a Way to See Whether a Variable is Defined? Reply with quote

I have a very large and overly complicated rexx program where the code is combining multiple variable values into a stem name. Is there a way to determine whether the variable name is already defined? For example:

If variableexists(env.table.index) then ...
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12377
Topics: 75
Location: San Jose

PostPosted: Fri Mar 14, 2014 1:52 pm    Post subject: Reply with quote

RoyKMathur,

Assuming you don't have any special characters in the stem variable you can use VALUE to check if it existed

Code:

CKSTR = 'ROY'                         
IF VALUE(VALUE(CKSTR)) = 'YES' THEN   
   SAY 'DATA IS ALREADY THERE'         
ELSE                                   
   SAY 'ADD IT TO THE STEM'           


http://www.ibm.com/support/knowledgecenter/SSZND2_6.0.0/com.ibm.etools.iseries.orxw.doc/orxw_ref576.htm
Back to top
View user's profile Send private message Send e-mail Visit poster's website
RoyKMathur
Beginner


Joined: 05 Jan 2012
Posts: 47
Topics: 11

PostPosted: Mon Mar 17, 2014 9:03 am    Post subject: Reply with quote

Thanks kolusu!
Back to top
View user's profile Send private message
arnold57
Beginner


Joined: 01 Oct 2004
Posts: 30
Topics: 0

PostPosted: Mon Mar 31, 2014 3:31 pm    Post subject: Reply with quote

Why not use SYMBOL('env.table.index') which will be 'VAR' if defined and 'LIT' if not.

P.S. For me VALUE(VALUE(CKSTR)) yields 'ROY' in Kolusu's example.
Back to top
View user's profile Send private message
RoyKMathur
Beginner


Joined: 05 Jan 2012
Posts: 47
Topics: 11

PostPosted: Thu Apr 03, 2014 12:37 pm    Post subject: Reply with quote

Nice solution!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group