RE Varaibles 
Author Message
 RE Varaibles

Hi again

I no under Rexx to find a null varaible one can do the follwoing,

If Myvariable = ' '
then do
say "Myvariable is null"
else
say "MyVariable is" Myvariable

But how do you do the oposite, that is if the variable
has an unknown return

I tried

If My variable = '!'
then do......

and

If Myvariable='?'....

any ideas

Please email me
--
Regards

Adrian Suri
**************


http://www.*-*-*.com/

The Home of OS/2 Zipmag......
   the mag on the net



Sun, 04 Feb 2001 03:00:00 GMT  
 RE Varaibles


[...]

% If Myvariable = ' '
% then do

[...]

% But how do you do the oposite, that is if the variable
% has an unknown return

How about
  if MyVariable ?= ''
(or \=)
--

Patrick TJ McPhee
East York  Canada



Sun, 04 Feb 2001 03:00:00 GMT  
 RE Varaibles

Quote:
>Hi again

>I no under Rexx to find a null varaible one can do the follwoing,

>If Myvariable = ' '
>then do
>say "Myvariable is null"
>else
>say "MyVariable is" Myvariable

>But how do you do the oposite, that is if the variable
>has an unknown return

I'm not quite sure what you want here.  A special NULL value does not exist
in REXX.  However, a variable may or may not have a value.  Your code checks
whether a variable contains an empty string.  To check whether a variable
has been assigned a value, you can use the SYMBOL built-in function:
   If symbol('Myvariable') = 'VAR' then
      say "MyVariable is" Myvariable
   else
      say "Myvariable does not have a value"

--
Regards,
Vidar Tysse    -   aka  "vtsystem AT bgnett DOT no"



Sun, 04 Feb 2001 03:00:00 GMT  
 RE Varaibles
Quote:



> >Hi again

> >I no under Rexx to find a null varaible one can do the follwoing,

> >If Myvariable = ' '
> >then do
> >say "Myvariable is null"
> >else
> >say "MyVariable is" Myvariable

> >But how do you do the oposite, that is if the variable
> >has an unknown return

> I'm not quite sure what you want here.  A special NULL value does not exist
> in REXX.  However, a variable may or may not have a value.  Your code checks
> whether a variable contains an empty string.  To check whether a variable
> has been assigned a value, you can use the SYMBOL built-in function:
>    If symbol('Myvariable') = 'VAR' then
>       say "MyVariable is" Myvariable
>    else
>       say "Myvariable does not have a value"

> --
> Regards,
> Vidar Tysse    -   aka  "vtsystem AT bgnett DOT no"

Hi thatnks for that I will give it a try
--
Regards

Adrian Suri
**************


http://users.powernet.co.uk/vpub

The Home of OS/2 Zipmag......
   the mag on the net



Sun, 04 Feb 2001 03:00:00 GMT  
 RE Varaibles

on 19 Aug 98  09:44:39 about Re: RE Varaibles...

Quote:


>>Hi again

>>I no under Rexx to find a null varaible one can do the follwoing,

>>If Myvariable = ' '
>>then do
>>say "Myvariable is null"
>>else
>>say "MyVariable is" Myvariable

>>But how do you do the oposite, that is if the variable
>>has an unknown return
> I'm not quite sure what you want here.  A special NULL value does not
> exist in REXX.  However, a variable may or may not have a value.  Your
> code checks whether a variable contains an empty string.  To check
> whether a variable has been assigned a value, you can use the SYMBOL
> built-in function: If symbol('Myvariable') = 'VAR' then
> say "MyVariable is" Myvariable
> else
> say "Myvariable does not have a value"

That's not terribly useful.  Many functions return the null string for
failure, and it most certainly does exist as a specific value in REXX.

It's two quotes (single or double) right next to each other.

For example:

newdir='x:\something\somewhere'
check=directory(newdir)
if check='' then say 'Directory doesn't exist.'
else say 'Full path of directory is '||check

Mike Ruskai SA/AG #1106

... Beavis & Butthead: MST3000 for morons.



Tue, 06 Feb 2001 03:00:00 GMT  
 RE Varaibles

on 18 Aug 98  21:53:08 about RE Varaibles...

Quote:
> Hi again
> I no under Rexx to find a null varaible one can do the follwoing,
> If Myvariable = ' '
> then do
> say "Myvariable is null"
> else
> say "MyVariable is" Myvariable

No, the null value is '' or "", two single or double quotes right next to
each other.  What you typed above is checking if the variable is equal to
the space character.

Quote:
> But how do you do the oposite, that is if the variable
> has an unknown return
> I tried
> If My variable = '!'
> then do......
> and
> If Myvariable='?'....
> any ideas

I'm not sure what you're asking.  Perhaps if you put it into context for a
specific goal.

Mike Ruskai SA/AG #1106

... Windows: Where Inferior Needless Designs Operate When STOLEN!



Tue, 06 Feb 2001 03:00:00 GMT  
 RE Varaibles

Quote:
>> If Myvariable = ' '
>No, the null value is '' or "", two single or double quotes right next to
>each other.  What you typed above is checking if the variable is equal to
>the space character.

Except that the = comparison operator strips blanks, so the instruction is
actually checking whether Myvariable is empty or contains only blanks.
--

------ http://www.comlab.ox.ac.uk/oucl/users/ian.collier/imc.html

New to this group?  Answers to frequently-asked questions can be had from
http://rexx.hursley.ibm.com/rexx/ .



Tue, 06 Feb 2001 03:00:00 GMT  
 RE Varaibles
Too true!
A single equality symbol "=" can match strings that are similar but have
different numbers of leading / trailing blanks.  At least this is true under
TSO/MVS.
A double "==" means "EXACTLY equal" and \== means NOT EXACTLY equal.

To answer the question, the reverse of the example would be :-

If MyVariable \= '' then,           /* If not blank or null */
  say 'Not blank!'

To do a check for a TRUE null :-

If MyVariable \== '' then,       /* If not null */
  say 'Not null'

If MyVariable == ''  or if length(MyVariable) = 0 then,      /* if null */
  say 'Null'

Rupert

----------

Quote:

>Sent:  21 August 1998 06:30
...
>> But how do you do the oposite, that is if the variable
>> has an unknown return



Tue, 06 Feb 2001 03:00:00 GMT  
 RE Varaibles

Quote:
> ...To check
> whether a variable
> has been assigned a value, you can use the SYMBOL built-in function:
>    If symbol('Myvariable') = 'VAR' then
>       say "MyVariable is" Myvariable
>    else
>       say "Myvariable does not have a value"

Since uninitialized variables have their own value, you can simply check:

if MyVariable <> "MYVARIABLE" then say "MyVariable is" Myvariable
else say "No value yet"

--I would expect this to be quicker than the function call, and it seems to
be.  However, it looks as though if you do it 200000 times you would save a
second, so it's probably moot.



Tue, 06 Feb 2001 03:00:00 GMT  
 RE Varaibles
Try Length(Myvariable) = 0 or the strictly equal comparitor "" eg
Myvariable == ""

Quote:

> Hi again

> I no under Rexx to find a null varaible one can do the follwoing,

> If Myvariable = ' '
> then do
> say "Myvariable is null"

SNIP


Sat, 10 Feb 2001 03:00:00 GMT  
 RE Varaibles


Quote:
>> ...To check
>> whether a variable
>> has been assigned a value, you can use the SYMBOL built-in function:
>>    If symbol('Myvariable') = 'VAR' then
>>       say "MyVariable is" Myvariable
>>    else
>>       say "Myvariable does not have a value"

>Since uninitialized variables have their own value, you can simply check:

>if MyVariable <> "MYVARIABLE" then say "MyVariable is" Myvariable
>else say "No value yet"

The only problem with that is that MyVariable may actually contain the
string "MYVARIABLE", and you can't tell the difference.  Maybe not a serious
problem in most cases, but it could be (as I've experienced).

--
Vidar Tysse    -   aka  "vtsystem AT bgnett DOT no"



Sun, 11 Feb 2001 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Using system varaibles with clarion

2. Passwing varaibles To Report Writer Engine

3. How to pass varaibles from Tk application to C program invoked from TK

4. OraTcl: How do i bind varaibles when using oraplexec?

 

 
Powered by phpBB® Forum Software