How can I define each case of the choice list in a uitable (GUI) and put IF function for each one? - list

I made a matlab gui that have two uitables, one of them have choice list format on its cells but I dont know how define each case of choice list and put IF function for each one. In other words I want apply numbers to second uitable from another gui with dependency on cases in the choice list of first uitable.

I assume that you use guide to manage your GUI, and that you already have created a uitable with a column in the format of a choice list, and that you have set the ColumnEditable property to true. Is that the case?
Then, create a CellEditCallback function by right clicking on the uitable in the guide window and select "View Callbacks" -> "CellEditCallback". This will create the callback function if it doesn't exist so far.
The automatically created callback function could look like this:
% --- Executes when entered data in editable cell(s) in uitable1.
function uitable1_CellEditCallback(hObject, eventdata, handles)
% hObject handle to uitable1 (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.TABLE)
% Indices: row and column indices of the cell(s) edited
% PreviousData: previous data for the cell(s) edited
% EditData: string(s) entered by the user
% NewData: EditData or its converted form set on the Data property. Empty if Data was not changed
% Error: error string when failed to convert EditData to appropriate value for Data
% handles structure with handles and user data (see GUIDATA)
In this case, the tag of the uitable is uitable1. If your uitable has a different tag, the function name will be according to that tag.
Now, write your if block into this callback function. For example, if the choice list that you want to query is in the first row and first column of your uitable, and you want to check if the selected text of the decision box is "blabla", then your code would look like this:
if strcmp(handles.uitable1.Data{1,1}, 'blabla')
% put here the code that you want to execute if the user selects 'blabla'
end
Hope it helps ...

Related

Is there a way to link a custom property value to a Mtext content?

I would like to link the value of a custom property to the contend of a specific Mtext.
Here's what I got so far:
i = 0
while(i<len(Cpro)):
doc.header.custom_vars.append(Cpro[i][0],Cpro[i][1]) # creating new custom properties list
i = i+1
Number = doc.header.custom_vars.__iter__()
for e in Number:
print(e)
I can get the whole list printed and even used to fill an MText(but the text is not linked to the Property value, it's only a copied string). But the goal is to set it in a way that the user of the dxf generated could change the Mtext contend by only changing the custom property value.
On BrisCAD you can use the "Field" command to choose one the custom properties to fill the text.

Django - How to check multiple variables in the view or in the template

I have a site that the user selects a drop-down menu item, inputs some JSON, and then clicks "Parse". Then the JSON data is checked against certain properties based on the drop-down menu item. Basically I have a list that looks like this.
myList = [{'Prop1': ['asdf', 'wefef']}, {'prop3': ['ss']}, {'prop2': ['d']}]
This is all the data I am checking against. It is the property name and then a list of expected values for that property name. Then in the JSON I have to compare those properties against the JSON properties in the list above.
Right now I am not sure where the best way to go about checking these. Should I do it in my views.py or should I do it in the page.html?
Basically I will need to look through myList and check if that property is in the JSON. If so then I need to check it against the expected property. And then I need to print things in a row so that you can view the info like:
Property Excepted Value Actual Value P/F
prop1 asdf, wefef apple F
prop2 d d P
prop3 ss sd F
My issue is, this will be a bunch of logic to build out to parse correctly. I am new to Django and not sure if the amount of code should be done in the HTML file. Else, I would need to build a large string in the views.py that contains all the data and the HTML, then pass to the HTML file and just display a single variable that displays all the data.
It is a good practise not to put too much logic in your page.html - it should just display your data. Therefore, put the logic into your view.
It also has the advantage that you can test the functionality way easier.

Pass values between pages in Oracle Apex

I am developing a mobile application that should allow a student to search for job vacancies. I have used the wizard to create a form with a list view. The list view will only show job titles which are not past their closing date (available jobs)
When a job title is clicked it redirects to the form where the student can view further job details. These values are passed automatically by the wizard.
Now while this whole thing is great I need information from 3 different tables and the wizard won't help me with that.
I have created a list view based on an sql query and also a form based on an sql query. I have tried to create automatic fetch processes to pass the values from my list view to the form view but nothing I have tried has worked. I carefully analysed the forms created by the wizard to see how it could be done but nothing worked for me and I would really love to do it in this way.
For reference this is the sql code I used for the list view (and it's the same for the form view except for the where clause )
T1.JOB_TITLE,
T1.SALARY,
T1.JOB_DESCRIPTION,
T1.START_DATE,
T1.CLOSING_DATE,
T1.METHOD_ID,
T3.METHOD_NAME,
T1.SITE_ID,
T2.CITY,
T2.ADDRESS_FIRST_LINE,
T2.EMAIL,
T2.COMPANY_NAME
FROM JOB T1
JOIN SITE T2 ON (T2.SITE_ID = T1.SITE_ID)
JOIN APPLICATION_METHOD T3 ON (T3.METHOD_ID = T1.METHOD_ID)
Where (T1.Closing_Date >(Select Current_Date from dual))
There are really two ways you could solve this:
1) If you can simply pass the values you need to the form page, edit the values of your Form region, and open up the "Link Target" attribute (this is assuming you're using APEX 5 Page Designer). There, you will be able to pass in multiple values to items on your Form page.
2) If, instead, you need to derive these values on your Form page, add an After Header process on your form page and do the lookups from your other tables in this process, using PL/SQL. You can use the bind variable syntax to reference your items and update session state. For example:
begin
for c1 in (select val1, val2 from my_other_table where id = :P3_ID) loop
:P3_ITEM1 := c1.val1;
:P3_ITEM2 := c1.val2;
exit;
end loop;
end;
I managed to add the additional columns by adding more items and selecting an Sql-query that returns a single row from the item attributes (Source).
So in order to get method_name rather than an ID which would be irrelevant for the end user I used this code:
SELECT METHOD_NAME FROM APPLICATION_METHOD
WHERE (METHOD_ID = :P3_METHOD_ID)
I am fairly certain that it might not be a great solution if you have a lot of columns that need to go through but it was easy to understand and implement for a few additional columns.

How to compare select options with database values?

I have a class called State in my model and a states select (combo box) in my page. I need to create the step definition that compares the values in the database to the values in the combo box.
I've been able to find the combo box by its ID, but I couldn't find a way to compare each option.
expect(page.find_by_id('patient_state_id'))
How can I do this?
I've been able to solve this with the following code:
Given(/^I am an application user$/) do
end
When(/^I display the patient registration form$/) do
visit('/patients/new')
end
Then(/^I should be able see the list of registered states$/) do
states = State.pluck(:description)
page.find_by_id('patient_state_id').all('option').each do |el|
expect(states).to include(el.text)
end
end

How to create linked (associated) automatically updated form fields in GAE Django

I am new to Django and GAE. I would like to create two input fields, where the first one is a drop-down menu (let name it select), which decides the values in the second one (let name it val).
For example, once 'A' is chosen from 'select', field 'val' will show '1'. similarly, 'B' is associated to '10'. I have written several lines below, but it does not work. Two issues:
The second field ('val') always equals 0.
It seems like my second field ('val') does not 'listen' to the choice made by the first one ('select'), which means those two fields are not linked.
Can anyone give me some suggestions (or recommend books on using Django on GAE)? Thank you!
select_CHOICES=(('A','A'),('B','B'),('Other','Other'))
select = forms.ChoiceField(choices=select_CHOICES, initial='A')
def get_choices(select):
if select=='A':
r= 1
elif select=='B':
r= 10
else:
r= 0
return r
val=forms.FloatField(initial=get_choices(select))
I think you have understood how django works a bit wrong. The code that you input is run before the page is rendered, so no selection is made yet. If you want the input field to dynamically change as user makes the choise on page, you should use Javascript.
Also you are comparing a Field (select) to a string ('A'), which naturally always is unequal.
Read more documentation and tutorials and you'll soon get how it works.