common code patterns

Monte Goulding monte at appisle.net
Thu Aug 10 21:14:13 EDT 2017


> On 11 Aug 2017, at 10:53 am, Devin Asay via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> I’d like to see one like this for conditional structures:
> 
> if <condition> then
>  -- do if true
> else
>  -- do if false
> end if
> 
> I always try to use the “full” form of if-then-else. It solves lots of confusion when you end up with nested if-thens. I teach my students to do it this way as best practice, and I think it reinforces the idea of a completely formed and terminated structure.

I agree Devin

The script editor doesn’t do macro completion on return of `if` because we have so many possible variations of that it is near impossible to work out what the user wants however I know I always want `return & indent & cursor selection & return & end if` when I hit return and the last non comment word of the line is then. 

I will occasionally use the single line for things like exit repeat if I’m feeling lazy but it’s likely I only do this because there’s no macro completion here so…

Anyway, as with the macro completion of `case` -> `break` adding `if` macro completion only if the last token is `then` would require some special casing in the current code which only looks at the first token of the statement and only does completion with end <first token>.

Cheers

Monte




More information about the use-livecode mailing list