time delay within a loop
20 posts
• Page 1 of 2 • 1, 2
time delay within a loop
Is there a way to introduce a delay into a program so that if the program generates a series of pictures or other graphics you can have a pause to allow each display to remain on the screen for a while before the next one is shown? (Hopefully, the method would be something other than a do-nothing loop that just wastes time.)
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: time delay within a loop
Great, it does exactly what I wanted! I didn't realize it would be that easy.
Thanks.
Thanks.
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: time delay within a loop
If your code to display images involves creating forms etc, you might like to consider using a Timer object. Then you could have both a button which changes image when you click it, and a Timer event callback which changes the image too .. bit more complex, since you probably want to reset the timer if you've just clicked the button, but it might make for a nicer front-end. This would mean that you can manually change images sooner than the delay that you specify ..
-
AndyS|Dyalog - Posts: 257
- Joined: Tue May 12, 2009 6:06 pm
Re: time delay within a loop
The button idea will be really nice if I ever learn how to make a GUI for my program, which is a sort of Spirograph on steroids. With the current version of the program, I've found that I have to be fairly careful about the rate at which the display changes. If I allow less than about 4 seconds per picture, the interpreter will sometimes hang. Many of the pictures are quite intricate, so I imagine that the computation of one picture may be incomplete when the program tries to start computing the next one.
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: time delay within a loop
I've got my first GUI up and running, using edit fields to enter data. But there's one edit field that should really be a button, where up means 0 and depressed means 1. I started looking at the Dyalog Interfaces Guide, and it appears I need something like
'F'⎕WC'Form' 'ToolControl: Radio Buttons'
'F.TB'⎕WC'ToolControl'
but I'm not sure what else I need to make the button work.
'F'⎕WC'Form' 'ToolControl: Radio Buttons'
'F.TB'⎕WC'ToolControl'
but I'm not sure what else I need to make the button work.
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: time delay within a loop
Hi Stu,
A good resource for our GUI is wtutor and wtutor95. They are quite old workspaces though.
)load wtutor
or
)load wtutor95
A radio button is usually part of a group and you can only select one.
wtutor has this example:
Do you need it to be part of a toolcontrol?
Regards,
Vince
A good resource for our GUI is wtutor and wtutor95. They are quite old workspaces though.
)load wtutor
or
)load wtutor95
A radio button is usually part of a group and you can only select one.
wtutor has this example:
'MEAL' ⎕WC 'Form' 'The Star of India' (64 38)(30 60)
'MEAL.CUR' ⎕WC 'Group' 'Curries' (5 5)(90 40)
'MEAL.CUR.CM' ⎕WC 'Button' 'Chicken Madras' (15 10) ('Style' 'Radio')
'MEAL.CUR.LP' ⎕WC 'Button' 'Lamb Pasanda' (30 10) ('Style' 'Radio')
'MEAL.CUR.PV' ⎕WC 'Button' 'Pork Vindaloo' (45 10) ('Style' 'Radio')
'MEAL.CUR.PD' ⎕WC 'Button' 'Prawn Dhansak' (60 10) ('Style' 'Radio')
'MEAL.CUR.RG' ⎕WC 'Button' 'Rogan Josh' (75 10) ('Style' 'Radio')
Do you need it to be part of a toolcontrol?
Regards,
Vince
- Vince|Dyalog
- Posts: 413
- Joined: Wed Oct 01, 2008 9:39 am
Re: time delay within a loop
Hi Vince,
What I need is a single button that will change the value of a variable, whose default value is 0, to 1. The button should remain down, like a radio button, until it is pressed again, which sets the variable back to zero. The button should be like an ON/OFF switch. I also couldn't see how to associate a radio button with the function that changes the value of a variable (I do know how to do that for a "regular" button).
If you have time to look at my program, I could send it to you. You could run it to see how it works and why I'd like to have that button.
-Stu
P.S.: Is there really an Indian dish called "Josh Rogan"?
What I need is a single button that will change the value of a variable, whose default value is 0, to 1. The button should remain down, like a radio button, until it is pressed again, which sets the variable back to zero. The button should be like an ON/OFF switch. I also couldn't see how to associate a radio button with the function that changes the value of a variable (I do know how to do that for a "regular" button).
If you have time to look at my program, I could send it to you. You could run it to see how it works and why I'd like to have that button.
-Stu
P.S.: Is there really an Indian dish called "Josh Rogan"?
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: time delay within a loop
Radio buttons are usually used in groups of two or more - something like the following:
A set of Radio buttons needs to have the same parent, so I have used a group here to achieve that.
I think you actually need a Check button .. that displays a tick (or not) to indicate whether it's "on" or "off".
So something like the following will do ..
Then when you repeatedly click on the button, you'll see that its State changes.
Rogan Josh is one of the staples of Indian restaurants here in the UK - and the love of curry is in the DNA of Dyalog Ltd. Actually, the love of good food in general is in the DNA of Dyalog, but a beer and a Ruby come near the top of the list !
- Code: Select all
⎕fx'cb msg' 'msg'
'f'⎕wc'form'
'f.g1'⎕wc'Group'
'f.g1.b1'⎕WC'Button' 'Vindaloo'('Posn' 60 20)('Style' 'Radio')('Event' 'Select' 'cb')
'f.g1.b2'⎕WC'Button' 'Rogan Josh'('Posn' 20 20)('Style' 'Radio')('Event' 'Select' 'cb')
A set of Radio buttons needs to have the same parent, so I have used a group here to achieve that.
I think you actually need a Check button .. that displays a tick (or not) to indicate whether it's "on" or "off".
So something like the following will do ..
- Code: Select all
'f'⎕wc'Form'
⎕fx'cb2 msg' '⎕←myvar←(⊃msg)⎕wg''State'''
'f.b'⎕wc'Button' 'Pressed' ('Style' 'Check')('Event' 'Select' 'cb2')
Then when you repeatedly click on the button, you'll see that its State changes.
Rogan Josh is one of the staples of Indian restaurants here in the UK - and the love of curry is in the DNA of Dyalog Ltd. Actually, the love of good food in general is in the DNA of Dyalog, but a beer and a Ruby come near the top of the list !
-
AndyS|Dyalog - Posts: 257
- Joined: Tue May 12, 2009 6:06 pm
Re: time delay within a loop
The interface I have working currently is below. I'd like to replace the last two lines with a check button, but I haven't been able to figure out how to substitute your code for those lines (I'm still learning how to make a GUI).
TITLE←'xshapes'
'APP'⎕WC'Form'TITLE(68 50)(30 33)
⍝
'APP.LD'⎕WC'Label' 'Delay'(10 10)
'APP.D'⎕WC'Edit' ''(10 17)(⍬ 20)('FieldType' 'Numeric')
'APP.LI'⎕WC'Label' 'Iterations'(25 10)
'APP.I'⎕WC'Edit' ''(25 17)(⍬ 20)('FieldType' 'Numeric')
'APP.LR'⎕WC'Label' 'Random'(40 10)
'APP.R'⎕WC'Edit' ''(40 20)(⍬ 3)('FieldType' 'Numeric')
⍝
GB←'Button' 'GO'(70 27)('Event' 'Select' 'loop')
'APP.GO'⎕WC GB
⍝
IB←'Button' ' ? '(40 17)('Event' 'Select' 'RAND')
'APP.IR'⎕WC IB
===========================================================================================
I make my own curried dishes with supermarket "curry powder." I also bought bottles of "Vindaloo Curry Seasoning" and "Balti Curry Seasoning," but I didn't like the flavor of those. If you've eaten out in the USA, you've undoubtedly observed that the tastes of Americans generally run to very bland food (enormous portions of meat accompanied by overcooked vegetables).
TITLE←'xshapes'
'APP'⎕WC'Form'TITLE(68 50)(30 33)
⍝
'APP.LD'⎕WC'Label' 'Delay'(10 10)
'APP.D'⎕WC'Edit' ''(10 17)(⍬ 20)('FieldType' 'Numeric')
'APP.LI'⎕WC'Label' 'Iterations'(25 10)
'APP.I'⎕WC'Edit' ''(25 17)(⍬ 20)('FieldType' 'Numeric')
'APP.LR'⎕WC'Label' 'Random'(40 10)
'APP.R'⎕WC'Edit' ''(40 20)(⍬ 3)('FieldType' 'Numeric')
⍝
GB←'Button' 'GO'(70 27)('Event' 'Select' 'loop')
'APP.GO'⎕WC GB
⍝
IB←'Button' ' ? '(40 17)('Event' 'Select' 'RAND')
'APP.IR'⎕WC IB
===========================================================================================
I make my own curried dishes with supermarket "curry powder." I also bought bottles of "Vindaloo Curry Seasoning" and "Balti Curry Seasoning," but I didn't like the flavor of those. If you've eaten out in the USA, you've undoubtedly observed that the tastes of Americans generally run to very bland food (enormous portions of meat accompanied by overcooked vegetables).
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
20 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group