Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
I am working on a kind of multiple choice quiz sheet and have some questions about the usage of controls in Mathcad version 15.
1) When I recalculate the worksheet (via selfmade button control) a new question is selected by random but the radiobuttons have remembered the answer of the preceding question. How can I achieve that all radio buttons are unchecked (as they are when I load the worksheet the first time).
2) How can I install some kind of counter which counts,how many trys were already made? The idea is to have a solution-button which is triggered automatically after, lets say, three attempts (that is three clicks an a different radio button).
I think both questions basically have to do with how two different controls can interact with each other.
3) I can not use the easier to handle webcontrols, as I need more freedom of placement of the controls. But I like the behaviour of the webcontrols more in some respects. They can be protected and one can still use them if the worksheet ist protected - this is not true for the "regular" controls. You have to unprotect them an so the user is able to show arguments etc. Then I dislike the black border I get around the single radio button when the click it. Is there a way to format the regular radio button controls in a way to behave and look like the webcontrols?
4) How can I change the color of the labels of the radio buttons? Via preferences I can change font, size, italics, bold, etc. but not the color.
Hope someone could shed some light on this, as the usage of controls is not that heavy covered in the documentation.
Maybe you have a sample worksheet I can learn from or point me to some more extensive documentation.
Thanks
WR
Solved! Go to Solution.
I am working on a kind of multiple choice quiz sheet and have some questions about the usage of controls in Mathcad version 15.
1) When I recalculate the worksheet (via selfmade button control) a new question is selected by random but the radiobuttons have remembered the answer of the preceding question. How can I achieve that all radio buttons are unchecked (as they are when I load the worksheet the first time).
2) How can I install some kind of counter which counts,how many trys were already made? The idea is to have a solution-button which is triggered automatically after, lets say, three attempts (that is three clicks an a different radio button).
I think both questions basically have to do with how two different controls can interact with each other.
Controls can only interact with each other via worksheet variables.
The attached file does what you describe above. Apart from one problem, anyway. When you first load the worksheet, if you select a radio button the counter counts more than once. I cannot figure out any way to stop it doing this, and I have spent too much time trying. The problem is not in the script in the counter; the counter is actually being called multiple times, and so logs multiple counts. If you click on the reset button, this behavior goes away, but I have no idea why. The reset button sets a rest flag. When the radio buttons see the reset flag they set their checked state to false, and the output to zero. The trick with the button is that it is written as a function, so it can be called at the end of the sheet to toggle the reset flag back to zero. Note that the Worksheet.recalculate in the button code is necessary. Without it, if the call to the reset function is off the end of the sheet it will not calculate, and the reset flag will not be reset to 0. The counter is based on a function I wrote before that can be used to store data in a worksheet (Saving the state of controls.zip). Since I modified it from that, I don't guarantee the code is optimal for a counter, but it works.
3) I can not use the easier to handle webcontrols, as I need more freedom of placement of the controls. But I like the behaviour of the webcontrols more in some respects. They can be protected and one can still use them if the worksheet ist protected - this is not true for the "regular" controls. You have to unprotect them an so the user is able to show arguments etc. Then I dislike the black border I get around the single radio button when the click it. Is there a way to format the regular radio button controls in a way to behave and look like the webcontrols?
The only properties available are the ones you to via the right click menu. There is no way to change the behavior you describe.
4) How can I change the color of the labels of the radio buttons? Via preferences I can change font, size, italics, bold, etc. but not the color.
You can't.
Hope someone could shed some light on this, as the usage of controls is not that heavy covered in the documentation.
Maybe you have a sample worksheet I can learn from or point me to some more extensive documentation.
There are lots of example controls here: Extra Components.mcd I have some others that are not included in that worksheet, so if you want something that's not there. ask.
I am not much experienced in scripting myself but I did a similar thing a while ago and my workaround was to introduce a "dummy" item (named it "nothing selected") in every block of radiobuttons and set it as startup default by adding the line "If RadioBtn.SelectedButton=0 Then RadioBtn.Check=True" in the Exec-Routine.
The main problem in your case, as I see it, is, that the component should reset to this default every time you recalculate your worksheet. I don't know an easy straightforeward method for doing so. What I could think of is setting a Mathcad variable to a specific value (lets say 1) at the very top of your sheet and set it to another value (0) at the very end of your sheet. You can access Mathcad variables in the scripts of your components. Don't like that method but can not think of another way at the moment.
Looks like your counter could be realized in a similar way.
Concerning your questions about format your radio controls and also the color changing button I think thats simply not possible. You could use a textbox which can change its color, etc. according to the value of a given variable. You will find examples how to do this in this forum, if thats a suitable solution for you.
I am working on a kind of multiple choice quiz sheet and have some questions about the usage of controls in Mathcad version 15.
1) When I recalculate the worksheet (via selfmade button control) a new question is selected by random but the radiobuttons have remembered the answer of the preceding question. How can I achieve that all radio buttons are unchecked (as they are when I load the worksheet the first time).
2) How can I install some kind of counter which counts,how many trys were already made? The idea is to have a solution-button which is triggered automatically after, lets say, three attempts (that is three clicks an a different radio button).
I think both questions basically have to do with how two different controls can interact with each other.
Controls can only interact with each other via worksheet variables.
The attached file does what you describe above. Apart from one problem, anyway. When you first load the worksheet, if you select a radio button the counter counts more than once. I cannot figure out any way to stop it doing this, and I have spent too much time trying. The problem is not in the script in the counter; the counter is actually being called multiple times, and so logs multiple counts. If you click on the reset button, this behavior goes away, but I have no idea why. The reset button sets a rest flag. When the radio buttons see the reset flag they set their checked state to false, and the output to zero. The trick with the button is that it is written as a function, so it can be called at the end of the sheet to toggle the reset flag back to zero. Note that the Worksheet.recalculate in the button code is necessary. Without it, if the call to the reset function is off the end of the sheet it will not calculate, and the reset flag will not be reset to 0. The counter is based on a function I wrote before that can be used to store data in a worksheet (Saving the state of controls.zip). Since I modified it from that, I don't guarantee the code is optimal for a counter, but it works.
3) I can not use the easier to handle webcontrols, as I need more freedom of placement of the controls. But I like the behaviour of the webcontrols more in some respects. They can be protected and one can still use them if the worksheet ist protected - this is not true for the "regular" controls. You have to unprotect them an so the user is able to show arguments etc. Then I dislike the black border I get around the single radio button when the click it. Is there a way to format the regular radio button controls in a way to behave and look like the webcontrols?
The only properties available are the ones you to via the right click menu. There is no way to change the behavior you describe.
4) How can I change the color of the labels of the radio buttons? Via preferences I can change font, size, italics, bold, etc. but not the color.
You can't.
Hope someone could shed some light on this, as the usage of controls is not that heavy covered in the documentation.
Maybe you have a sample worksheet I can learn from or point me to some more extensive documentation.
There are lots of example controls here: Extra Components.mcd I have some others that are not included in that worksheet, so if you want something that's not there. ask.
Richard, thank you for your answer and involving your time. I think your file will help me a lot. Concerning your ExtraComponents - I haven't looked at it so thorough at the moment, but it looks like I can learn a lot from that file. I already know, that I will like and use your scrollbar.
A last (?) question: While juggling around with some components I exported one of them. It was filed as an *.mcm and after deleting that file I still get that object offered when I select "Insert"-"Component". How can I get rid of it completely?
Again many thanks for Your help
WR
While juggling around with some components I exported one of them. It was filed as an *.mcm and after deleting that file I still get that object offered when I select "Insert"-"Component". How can I get rid of it completely?
I'm not sure. When the mcm file is created it is also registered. There is a program in the Mathcad folder callled "mcmreg.exe". When you run the program it asks for an mcm file. Maybe if the file is registered it will unregister it? That's just a guess though.
Thanks for the hint. Just found the solution here: http://communities.ptc.com/thread/30039 (and its also in the Developer's Reference under "Exporting and Registering Components").
Unfortunately I had already deleted the corresponding mcm-Files. But exporting components under the same names as the ones I wanted to get rid of and then unregistering them did the job. Otherwise I would have had to search the registry for traces.
WR