Switcheroo

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Switcheroo

dunbarx via use-livecode
I have a list field where each line may contain a number or be empty.

I need a SWITCH statement that checks the state of each line . . .

This is throwing a "bluey":

switch line number of fld "MM" is empty

Where am I going wrong?

Richmond.
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Switcheroo

dunbarx via use-livecode
You aren't actually providing a line number.  Try this..

repeat with i = 1 to the number of lines in field "mm"
switch (line i of fld "mm" is empty)
   case true

   break
   case false

   break
end switch
end repeat

Though if you have a LOT of lines you'd be better off adjusting it to use
repeat for each and running a separate counter...

put 1 into tCounter
repeat for each line tLine in field "mm
     switch (tLine is empty)
           case true
               -- the line is empty, tcounter contains the number of the
line
           break
           case false
                -- the line is NOT empty, tcounter contains the number of
the line
           break
end switch
add 1 to tCounter -- increment to keep tCounter in sync with the line number
end repeat

On Sun, Jan 21, 2018 at 9:09 AM, Richmond Mathewson via use-livecode <
[hidden email]> wrote:

> I have a list field where each line may contain a number or be empty.
>
> I need a SWITCH statement that checks the state of each line . . .
>
> This is throwing a "bluey":
>
> switch line number of fld "MM" is empty
>
> Where am I going wrong?
>
> Richmond.
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Switcheroo

dunbarx via use-livecode
Thank you very much: I'll get back to work.

Richmond.

On 21/1/2018 6:35 pm, Mike Bonner via use-livecode wrote:

> You aren't actually providing a line number.  Try this..
>
> repeat with i = 1 to the number of lines in field "mm"
> switch (line i of fld "mm" is empty)
>     case true
>
>     break
>     case false
>
>     break
> end switch
> end repeat
>
> Though if you have a LOT of lines you'd be better off adjusting it to use
> repeat for each and running a separate counter...
>
> put 1 into tCounter
> repeat for each line tLine in field "mm
>       switch (tLine is empty)
>             case true
>                 -- the line is empty, tcounter contains the number of the
> line
>             break
>             case false
>                  -- the line is NOT empty, tcounter contains the number of
> the line
>             break
> end switch
> add 1 to tCounter -- increment to keep tCounter in sync with the line number
> end repeat
>
> On Sun, Jan 21, 2018 at 9:09 AM, Richmond Mathewson via use-livecode <
> [hidden email]> wrote:
>
>> I have a list field where each line may contain a number or be empty.
>>
>> I need a SWITCH statement that checks the state of each line . . .
>>
>> This is throwing a "bluey":
>>
>> switch line number of fld "MM" is empty
>>
>> Where am I going wrong?
>>
>> Richmond.
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Switcheroo

dunbarx via use-livecode
In reply to this post by dunbarx via use-livecode
Not a biggie but I like to simply add 1 to tCounter at the top of the loop

-- put 1 into tCounter (don't need this here)
repeat for each line tLine in field "mm
    add 1 to tCounter -- put it here instead. It creates the variable on the fly
    switch (tLine is empty)
...

Bob S


> On Jan 21, 2018, at 08:35 , Mike Bonner via use-livecode <[hidden email]> wrote:
>
> put 1 into tCounter
> repeat for each line tLine in field "mm
>     switch (tLine is empty)


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode