| ECS-L Home Automation and Security Archives |
| Subject: From: Date: | Re: [ECS] IF, THEN, ELSE....OR MAYBE NOT? Mark Gilmore Wed, 15 Nov 2000 09:03:18 -0500 |
DOs ALWAYS execute (unless contained in a "false" BEGINIF block). -- Mark Gilmore Omnipotence (ECS home automation software) http://omnipotencesoftware.com 423-745-0026 Hours: Mon-Sat, 9AM-8PM/EST Kevin Trainor wrote: > > Thanks for your advice. > > Two questions: > > 1. Are DO's and THEN's interchangeable? They seem to be in your example. > > 2. How do you represent a block of statements that are to be executed in > the ELSE case? Are ELSE and DO interchangeable? > > Kevin > ----- Original Message ----- > From: <bgprager@mindspring.com> > To: <ecs-list@netbloc.com> > Sent: Wednesday, November 15, 2000 7:26 AM > Subject: Re: [ECS] IF, THEN, ELSE....OR MAYBE NOT? > > > Take heart, they do work. > > If you're imbedding If's within If's, use beginIF > > BeginIF A is true > > DO ----common code---- > > If B is true > > then > > then > > then > > elseif C is true > > then > > then > > ENDIF > > > > Alternatively, > > If A is true > > > > BEGINIF B is true > > Do > > Do > > Do > > If D is true > > then > > then > > ENDIF > > > > BEGINIFs are very useful and provide the means to easily nest mutilple IF > statements and can preclude of use of the Exit statement (if you're an > oldtime programmer like me, Exit's were death.). It is also useful when > combining ANDs and ORs in a logical statement. I will admit the ECS is > harder than other HA software I've used when constructing complex logical > conditions however I used the BeginIF statement to break up a complex > logical. Ex. If (A or B) and C becomes : > > Beginif A is true or B is true > > If C is true then > > then > > .... > > endif > > My Thermostat code is heavily nested as are some of my other routines and > they work quite reliably. If you'd like to see some examples, let me know. > > Good Luck. > > ecs-list@netbloc.com wrote: > > > > > > > > > > > > > > > > > All: > > > > When you can't even make the IF-AND-ELSE statements work in a > > language, I think you should generally be regarded as a failure. Such is > > my fate with ECS. Oh, I've tried to make them work. And, some > > have. I've had especially good luck with the simple IF-THEN > > construct. I have even had some luck with your basic IF-THEN-ELSEIF > > construct. But, as soon as I try to do something complex, the event goes > > right into the toilet. > > > > I've tried looking at the event code that comes with > > ECS. And, suspiciously, I can't find any examples of IF-THEN-ELSE > > constructs that are more complex than the ones that I described above. The > > proud programmer in me suspects that perhaps even Mark can't get the > complex > > ones to run right. But, the humble programmer in me says that I > > probably am just not getting the language syntax and that it's all my > > fault. > > > > So, on to my questions: > > > > 1. What is the proper way to code a block of > > statements to be executed in the ELSE case? Is > > it: > > > > if condition > > then statement 1 > > then statement 2 > > else statement 3 > > else statement 4 > > else statement 5 > > > > or perhaps is it: > > > > if condition > > then statement 1 > > then statement 2 > > else statement 3 > > do statement 4 > > do statement 5 > > > > 2. When expressing conditions using AND / OR, can you > > create a complex statement that would normally be created using paretheses > in > > more robust languages? Are there rules that determine the order of > > precedence? If not, how do people create complex conditionals in > > ECS? > > > > 3. Can you use an ELSEIF within a BEGINIF-ENDIF > > block? > > > > 4. I have the same question about coding blocks of > > statements for the ELSE case as it applies to BEGINIF-ENDIF. Do all > > statments within the ELSE case begin with ELSE? > > > > 5. Are there limits to how deeply IF-THEN-ELSE > > statements can be nested? > > > > 6. WHY DOESN'T MY CODE EVER DO WHAT I EXPECT IT TO > > UNLESS I MAKE IT SO REPETITIVE AND TEDIOUS THAN I FALL ASLEEP CODING > > IT? > > > > Well...Now that I have all that off my chest, I would like to > > ask for your help. If you have had these kinds of problems and found your > > way through, I would appreciate your advice. > > > > Thanks in advance. > > > > Kevin > > > > > > > > > > > >