jed-users mailing list

[2002 Date Index] [2002 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: Looping and composite conditions


SANGOI DINO <SANGOID@xxxxxxxxxxxxxxxxx> wrote:

>>    static define untranslated ()
>>    {
>>       bol_fsearch ("msgstr") and fsearch ("\"") and looking_at ("\"\"")
>>         and down_1 () and skip_chars (" \t\n") and looking_at ("#");
>>    }

SD> Uhm, skip_chars() doesn't return a value, so this function
SD> will pop a value from stack not pushed by some of the invoked
SD> functions. You should also remember that slang does not use
SD> short circuit evaluation when using 'and' and 'or', so ALL
SD> the expressions on a condition will be evaluated.

Well, I am not a programmer so there is a certain nature of
haphazardness to some of the things I'm doing. It was my
understanding of the and'ed conditions above that if all of
them were met then the return value of the function would be "1"
and if one or more failed then it would be "0". I was not aware
that skip_chars didn't return a value.


SD> an easy fix may be:

SD> static define untranslated ()
SD> {
SD>    bol_fsearch ("msgstr") and fsearch ("\"") and looking_at ("\"\"")
SD>        and down_1 () and (skip_chars (" \t\n"), looking_at ("#"));
SD> }
SD> (note the ',' instead of 'and').

No, it didn't work.

SD> or maybe you can write:

SD> define find_untranslated ()
SD> {
SD> 	variable found = 0;
SD> 	while (bol_fsearch ("msgstr"))
SD>          {
SD> 		if (andelse { fsearch ("\"") }
SD>                         { looking_at ("\"\"") }
SD> 				{ down_1 () }
SD> 				{ skip_chars (" \t\n"), looking_at ("#"))
SD>                {
SD> 			found = 1;
SD>     		      break;
SD>                }
SD> 		eol();
SD>          }	
SD>       if (not found) 
SD>         {
SD>            message ("Not found");
SD>            bob ();
SD>            return;
SD>         }
SD> }

No go there either ;-) But Guenther provided a solution. Thanks
to both you and Guenther.



Regards,

Morten

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2002 date index] [2002 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]