radio button group matlab - user-interface

i have two set of button groups.
first button groups has two radio buttons and second group has four radio buttons.
if button 1 is selected in group1 and any one from the group 2. similarly for button2 in group 1 and any one from group2, respective function calls must be made on click of push button with these combinations. how to do it. there will be 8 separate function calls for their respective combinations. how to do the combination of button groups. switch case or if else statement did not work out?? kindly help.

Here is an idea.
First you create 2x4 cell array of your functions.
fnc_array = {fcn11, fcn12, fcn13, fcn14; fcn21, fcn22, fcn23, fcn24};
Then do switch case for each radio button in a group and return an index (say fcn_index1 for 1st group, and fcn_index2 for the 2nd group), which button selected.
Then you can call a function from your array with those indexes:
fcn_array{fcn_index1,fcn_index2}(arguments)

Switch and if..else should certainly work out, but you need to nest them, i.e. there's no way to switch on a pair of values.
switch valA
case 1
if isB
out = fcn11(args{:});
else
out = fcn12(args{:});
end
case 2
if isB
out = fcn21(args{:});
else
out = fcn22(args{:});
end
case 3
if isB
out = fcn31(args{:});
else
out = fcn32(args{:});
end
case 4
if isB
out = fcn41(args{:});
else
out = fcn42(args{:});
end
end

Not the greatest of style, but if they all use the same arguments then you could get away with dynamically building the call with the eval function based on which buttons were selected (using sprintf and the 'SelectedObject' field of the radio groups and a tag such as:eval(sprintf('func%s%s(args)',get(get(handles.group1,'SelectedObject'),'Tag'),get(get(handles.group2,'SelectedObject'),'Tag')))
(Could be combined with indexing the children using find(get(handles.group1,'Children')==get(handles.group2,'SelectedObject'))
and taking note of which is which)

Related

Oracle Forms comparing two checkboxes status

I have a form that has two checkboxes, one is dup and one is sum. They both take values, add them up, and display the total in a display item. I have that part covered in an if statement on both checkboxes. What I need some assistance with, is a third if statement that, if sum is checked and the user checks dup, oracle forms pops up a message, uncheck the dup checkbox, and does nothing else. Here is the code I have so far :
IF :mn_outstanding_trans.cb_duplicate_activity ='Y' THEN
:mn_outstanding_trans.activity_cd := 'SUM';
:bl_control.gross_sum_of_trxs := :bl_control.gross_sum_of_trxs + :mn_outstanding_trans.gross_amt;
:bl_control.net_sum_of_trxs := :bl_control.net_sum_of_trxs + :mn_outstanding_trans.net_amt;
:bl_control.previous_activity_cd := :mn_outstanding_trans.activity_cd;
ELSIF :mn_outstanding_trans.cb_duplicate_activity ='N' THEN
:mn_outstanding_trans.activity_cd := ' ';
:bl_control.gross_sum_of_trxs := :bl_control.gross_sum_of_trxs - :mn_outstanding_trans.gross_amt;
:bl_control.net_sum_of_trxs := :bl_control.net_sum_of_trxs - :mn_outstanding_trans.net_amt;
:bl_control.previous_activity_cd := :mn_outstanding_trans.activity_cd;
END IF;
if sum is checked and the user checks dup, oracle forms pops up a message, uncheck the dup checkbox
It seems that you want to allow either DUP or SUM checkbox set, but never both. If that's so, then you should use a radio button instead of two checkboxes (which are supposed to exclude each other).
Also, maybe it would be easier to understand what you're talking about if you posted a screenshot of that form.

Editing and Capturing new option from optionMenu Tkinter

I created a list of optionMenus via a for loop. I need to tie my optionMenu selection to the optionMenu it came from. The for loop, I think, is making it so I am unable to tie the two values together.
def get_selection(choice):
popUp_list.append(choice)
if num >= 1 and num <5:
for num in range(1,5):
choice = StringVar(root2)
choices = {'Application', 'File', 'Website'}
choice.set('Choose Type')
popUpMenu = OptionMenu(root2, choice, *choices, command = Controller.get_selection)
popUpMenu.grid(row=num, column=0)
I know it would be easier to hard code the option menus, but for reasons I don't want to get in to, the for loop is necessary. Not for this part specifically, but for another part of my code. It's just easier to use this example here.
When an option is selected from the menus, I am able to pull the values and that works great. However, if a user makes a first selection and then wants to update their selection, I have no way to capture that. It creates a "new" selection, not tied to the optionMenu. So the new option does not replace the old option. It just creates a new selection.
Is there a way to pass the popUpMenu number through the Controller .get_selection function? When trying to pass another variable doing something on the lines of:
def get_selection(choice, num):
popUp_list.append(choice)
print(num)
popUpMenu = OptionMenu(root2, choice, *choices, command = lambda: Controller.get_selection(choice, num))
I get the error below and I'm not able to get the option selection. I'm not sure what to put as the first value. Inputting choice does not work.
self.__callback(self.__value, *args)
TypeError: () takes 0 positional arguments but 1 was given
I was able to solve this. I updated my code to :
if num >= 1 and num <5:
for num in range(1,5):
choice = StringVar(root2)
choices = {'Application', 'File', 'Website'}
choice.set('Choose Type')
popUpMenu = OptionMenu(root2, choice, *choices, command = lambda choice = choice, num = num: (Controller.get_selection(choice, num)))
So, making your command statement like:
command = lambda choice = choice, num = num: (Controller.get_selection(choice, num)))
allows you to pass variables into your function.

Calculations inside a repeater (new repeat) control

A form in a Orbeon form builder contains a repeater control(new repeat).Suppose there are three text controls on each row(or repeat) of a repeater control(new repeat).first two text controls on each row contains numeric values.I want to bring the product of first two text controls to the third text control at run time without any event.there will be multiple numbers of repeat in the runtime ,i.e the row may increase but for each the calculation much reflect at runtime and for each row product of first two must be viewed on the third one
I used the following codes :
if ($quantity castable as xs:double and $price castable as xs:double)
then $quantity * $price
else 'n/a'
Its ok with this xpath expression when there is only one row in the repeater control.But on adding new rows ,i.e on increasing the repeat at run time, all results in the controls of third column changes to the else value ("n/a"). This is working only for a single row of a repeater control(new repeat). Because for every repeat the value must be calculated for each row separately.
Assume this is your node which repeats for each row
<repeater>
<quantity></quantity>
<price></price>
<product></product>
</repeater>
the Xpath expression for calculating the product would be
if(../quantity castable as xs:double and ../price castable as xs:double)
then ../quantity * ../price
else 'N/A'
This expression when used in calculate for the <product> node results the product on each row and there is no event based action required since this is written on the bind definition of the node.
Hope this answers to all your questions

Visual Basic Function Procedure

I need help with the following H.W. problem. I have done everything except the instructions I numbered. Please help!
A furniture manufacturer makes two types of furniture—chairs and sofas.
The cost per chair is $350, the cost per sofa is $925, and the sales tax rate is 5%.
Write a Visual Basic program to create an invoice form for an order.
After the data on the left side of the form are entered, the user can display an invoice in a list box by pressing the Process Order button.
The user can click on the Clear Order Form button to clear all text boxes and the list box, and can click on the Quit button to exit the program.
The invoice number consists of the capitalized first two letters of the customer’s last name, followed by the last four digits of the zip code.
The customer name is input with the last name first, followed by a comma, a space, and the first name. However, the name is displayed in the invoice in the proper order.
The generation of the invoice number and the reordering of the first and last names should be carried out by Function procedures.
Seeing as this is homework and you haven't provided any code to show what effort you have made on your own, I'm not going to provide any specific answers, but hopefully I will try to point you in the right direction.
Your first 2 numbered items look to be variations on the same theme... string manipulation. Assuming you have the customer's address information from the order form, you just need to write 2 separate function to take the parts of the name and address, take the data you need and return the value (which covers your 3rd item).
To get parts of the name and address to generate the invoice number, you need to think about using the Left() and Right() functions.
Something like:
Dim first as String, last as String, word as String
word = "Foo"
first = Left(word, 1)
last = Right(word, 1)
Debug.Print(first) 'prints "F"
Debug.Print(last) 'prints "o"
Once you get the parts you need, then you just need to worry about joining the parts together in the order you want. The concatenation operator for strings is &. So using the above example, it would go something like:
Dim concat as String
concat = first & last
Debug.Print(concat) 'prints "Fo"
Your final item, using a Function procedure to generate the desired values, is very easily google-able (is that even a word). The syntax is very simple, so here's a quick example of a common function that is not built into VB6:
Private Function IsOdd(value as Integer) As Boolean
If (value Mod 2) = 0 Then 'determines of value is an odd or even by checking
' if the value divided by 2 has a remainder or not
' (aka Mod operator)
IsOdd = False ' if remainder is 0, set IsOdd to False
Else
IsOdd = True ' otherwise set IsOdd to True
End If
End Function
Hopefully this gets you going in the right direction.

QTP narrow a list of ChildObjects

[The description is a bit fudged to obfuscate my real work for confidentiality reasons]
I'm working on a QTP test for a web page where there are multiple HTML tables of items. Items that are available have a clickable item#, while those that aren't active have an item# as plain text.
So if I have a set of ChildObjects like this:
//This is the set of table rows that contain item numbers, active or not.
objItemRows = Browser("browserX").Page("pageY").ChildObjects("class:=ItemRow")
What is the simplest way in QTP land to select only the clickable link-ized item #s?
UPDATE: The point here isn't to select the rows themselves, it's to select only the rows that have items in them (as opposed to header/footer rows in each table). If I understand this correctly, I could then use objItemRows.Count to count how many items (available and unavailable) there are. Could I then use something like
desItemLink = Description.Create
desItemLink("micclass").value = "Link"
objItemLinks = objItemRows.ChildObjects(desItemLink)
To get the links within only the item rows?
Hope that clarifies things, and thanks for the help.
I think I have this figured out.
Set desItemLink = description.create
desItemLink("micclass").value = "Link"
desItemLink("text").RegularExpression = True
//True, Regex isn't really required in this example, but I just wanted to show it could be used this way
//This next part depends on the format of the item numbers, in my case, it's [0-9]0000[0-9]00[0-9]
For x = 0 to 9
For y = 0 to 9
For z = 0 to 9
strItemLink = x & "0000" & y & "00" & z
desItemLink("text").value = strItemLink
Set objItemLink = Browser("browser").Page("page").Link(desItemLink)
If objItemLink.Exist(0) Then
//Do stuff
End If
Next
Next
Next
Thanks for your help anyways, but the code above will iterate through links with names in a given incrementing format.

Resources