×
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

Extract function return value

Extract function return value

Extract function return value

(OP)
What value extract function returns as in this example?
string_val = abcdef
ret_val=extract(string_val,1,7)

As you can see, extract function should give 7 strings long word but parameter is actually 6 strings long. Is it possible that extract func. returns NULL value?

How can I detect with IF statement the NULL value of ret_val parameter.
Something like this:

if (ret_val==NULL)
   DO_THIS */ex.
else
   DO_THAT */ex.
endif

RE: Extract function return value

Check for the length of string_val before obtaining ret_string.
If the length of sring_value is greater than 7, get the first seven characters.
If the length is 7 or less, use string_value as it is.

"Wildfires are dangerous, hard to control, and economically catastrophic."

Ben Loosli

RE: Extract function return value

(OP)
I wanted to check if variable returns NULL as a value so I do not have to do length check. Thank you.

RE: Extract function return value

string_val = 'abcdef'
ret_val=extract(string_val,1,7)

if (ret_val=='')
   result = 'NULL value'
else
  result = 'value'
endif

If the length of string_val is less than the extract length, ret_val will be blank.

"Wildfires are dangerous, hard to control, and economically catastrophic."

Ben Loosli

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