CAPITAL Office Business Software
CAPITAL Support Forum
escaping via .OR.

Post new topic   Reply to topic    CAPITAL Office Business Software Forum Index -> Scripting & Customisation
View previous topic :: View next topic  
Author Message

PostPosted: Sat Oct 21, 2006 2:34 pm    Post subject: escaping via .OR. Reply with quote

In some languages the OR, in Capital the .OR. , operator does not evaluate the right hand argument/arguments if the left one returns TRUE.
Testing this on version 7.4 and 7.41 shows me that Capital Script does escape the .OR. evaluation the same way. I haven't tested .AND. yet however I assume, at this point, that it's similar.
Therefore the following code currently works as expected.

OpenTable("TableName") .OR. Echo("Table failed to open")

Although 'Return' does not actualy return a value to the script that calls it I am wondering if this is allowed by Capital Script in the case of the .OR. and .AND. operators, where it is the final part of the evaluation? If so I could effectively do the following.

OpenTable("TableName") .OR. (Echo("Table failed to open") .AND. Return FALSE)

I would like to use code constructs similar to the above to achieve more compact, and hopefully quicker, code. However, I would also like to be certain that in doing so it won't break on future releases.

I know that conditions where one of those conditions doesn't actualy return anything to evaluate would not be allowed in many languages. However, my reasoning in this regard is that if Captial Script does allow it and there are no unpleasent side effects from calling 'Return' as the last part of such an evaluation, then I will use such constructs.

Soon I will be rewriting quite a large script with the aim of improving it's performance and would be most grateful for an answer to the above.

Thank you also for your previous excellent help.
Back to top
COBS Tech Support

Joined: 09 Sep 2005
Posts: 651

PostPosted: Mon Oct 23, 2006 4:01 pm    Post subject: Reply with quote

Expressions are evaluated from left to right until the outcome is determined by the language processor. So:

a .Or. b

will evaluate (execute) b if a is not TRUE. But it will not evaluate (execute) b if a is TRUE.

Also with:

a .And. b

will evaluate (execute) b only if a evaluates to TRUE.

This type of syntax evaluation is not expected to change in any future release, and will not change for the upcoming CAPITAL V8.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    CAPITAL Office Business Software Forum Index -> Scripting & Customisation All times are GMT + 10 Hours
Page 1 of 1

Jump to:  
You can post new topics in this forum
You can 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

phpBB Template by Vereor
Protected by Anti-Spam ACP