[Scilab-users] Start an arrested loop with one keystroke only
Jens
j.s.strom at hslmg.de
Tue Nov 22 16:27:08 CET 2016
Hallo Tim,
I have answered my last question by 'while' instead of 'for':
function k=stopgoclick(k,n)//control a figure loop by mouseclicks
//INPUT
//k: figure loop counter
//n: length of figure loop
//left mouse click: continue loop i. e. next figure (b(1)=3)
//middle mouse click: abort script (b(1)=4)
//right mouse click: break loop (b(1)=5)
//OUTPUT
//k; n after right mouse click to break loop, else: k from input
//Example: i=1; while i<=n; plot(x,i*x); i=stopgoclick(i,n); i=i+1; end
b=xclick()
if b(1)==3//left mouse: next image
return
elseif b(1)==4//middle mouse: end script
abort
elseif b(1)==5//break loop
k=n+1
end
endfunction
x=0:1;
n=10;
i=1;
while i<=n
plot(x,i*x)
i=stopgoclick(i,n);
i=i+1;
end
'further commands'
I am satisfied with the function. Please advise if a simpler solution
exists.
Cheers
Jens
-------------------------------------------------------------
Am 22.11.2016 12:28, schrieb Jens Simon Strom:
> Hallo Tim,
> Did you mean something like this?:
> function b1=stopgoclick()
> //left mouse: next image,, middle mous: abort
> b=xclick();
> b1=b(1)
> if b1==3//left mouse: next image
> return
> elseif b1==4//middle mouse: end script
> abort
> end
> endfunction
>
> x=0:1
> for i=1:10
> plot(x,i*x)
> b1=stopgoclick()
> if b1==5//right mouse: break loop
> break
> end
> end
> 'further commands'
> If that is o.k. could you help me to handle the loop break case from
> inside the function?
> Cheers
> Jens
> --------------------------------------------
>
> Am 22.11.2016 01:36, schrieb Tim Wescott [via Scilab / Xcos - Mailing
> Lists Archives]:
>> xclick()
>>
>> On Mon, 2016-11-21 at 17:22 -0700, Jens wrote:
>>
>> > Hallo Scilab users,
>> > I am searching for a convenient way to restart a loop with only
>> *one* key
>> > or mouse stroke. The loop may generate and show graphics or not. I
>> tried
>> > xclick, pause, halt, and input with little success. input is
>> closest to the
>> > target but not close enough.
>> >
>> > for i=1:3
>> > plot()
>> > //commands wanted which stops the loop and continues it with
>> ONE key
>> > or mouse stroke only.
>> > //input('click on console and press return')// very close but
>> more
>> > than one stroke
>> > xdel();
>> > end
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> http://mailinglists.scilab.org/Start-an-arrested-loop-with-one-keystroke-only-tp4035053.html
>> > Sent from the Scilab users - Mailing Lists Archives mailing list
>> archive at Nabble.com.
>> > _______________________________________________
>> > users mailing list
>> > [hidden email] </user/SendEmail.jtp?type=node&node=4035055&i=0>
>> > http://lists.scilab.org/mailman/listinfo/users
>> >
>> >
>>
>> --
>>
>> Tim Wescott
>> www.wescottdesign.com
>> Control & Communications systems, circuit & software design.
>> Phone: 503.631.7815
>> Cell: 503.349.8432
>>
>>
>> _______________________________________________
>> users mailing list
>> [hidden email] </user/SendEmail.jtp?type=node&node=4035055&i=1>
>> http://lists.scilab.org/mailman/listinfo/users
>>
>>
>> ------------------------------------------------------------------------
>> If you reply to this email, your message will be added to the
>> discussion below:
>> http://mailinglists.scilab.org/Start-an-arrested-loop-with-one-keystroke-only-tp4035053p4035055.html
>>
>> To unsubscribe from Start an arrested loop with one keystroke only,
>> click here
>> <http://mailinglists.scilab.org/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4035053&code=ai5zLnN0cm9tQGhzbG1nLmRlfDQwMzUwNTN8LTIyMzcxNjc3Ng==>.
>> NAML
>> <http://mailinglists.scilab.org/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
--
View this message in context: http://mailinglists.scilab.org/Start-an-arrested-loop-with-one-keystroke-only-tp4035053p4035059.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20161122/82d7d057/attachment.htm>
More information about the users
mailing list