×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-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!

*Tek-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

How to evaluate (EVAL) only a part of a block ?

How to evaluate (EVAL) only a part of a block ?

How to evaluate (EVAL) only a part of a block ?

(OP)
Good morning,

I'm checking dates, day per day, against a cursor of festive days.
I would like to write a dynamic IF, like this:

If _calendar.DayType<ind> == 3 Then
(expected output for the engine, with ind=1: "If _calendar.DayType1 == 3 Then")

Where ind is the dynamic day of the week that I have to check in my loop.
I don't want to EVAL (or &) the whole IF block if possible, but only the row (IF ...) where I have the dynamic value.

I tried (with DATE()+1 for tests)

IF &('_calHonda.DayType' + ALLTRIM(TRANSFORM(DOW(DATE()+1)))) == 3 THEN

and similars, nothing


I tried to just print the content of the cursor, dynamically:

? &('_calHonda.DayType' + ALLTRIM(TRANSFORM(DOW(DATE()+1))))

But this gives an error too.


If I write the whole IF block inside a string, from begin to EndIf, and evaluate the string, it's probably going to work, like it's supposed to do, but I don't really like this idea very much.
Is there a way to EVAL only the row I need?

Thank you very much.

RE: How to evaluate (EVAL) only a part of a block ?

Hi

I think you would probably be right to use an EVALUATE() in this instance

CODE

IF EVALUATE("_calendar.DayType"+ALLTRIM(TRANSFORM(DOW(DATE()+1))))+"=3")
  && do something
ELSE
  && do something else
ENDIF 

This assumes the DayTypeN field is a numeric otherwise

CODE

IF EVALUATE("_calendar.DayType"+ALLTRIM(TRANSFORM(DOW(DATE()+1))))+"='3'")
  && do something
ELSE
  && do something else
ENDIF 

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0

RE: How to evaluate (EVAL) only a part of a block ?

(OP)
Thank you so much Griff, exactly what I was looking for, works like a charm.

Before you answered I added an EVAL to assign the content of the cursor on a variable and then checked the variable on the IF below, because I didn't know you can use EVAL in conjunction with "real" code, but your solution is way better, thanks a lot, have a great day.

RE: How to evaluate (EVAL) only a part of a block ?

Likewise

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0

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 Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

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

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close