Use radio button as interface to be used by user to direct resource exit route.
The radio button options will be linked to one of the routs or both of them.
I have used the function radio.getValue(); for enter and enter1.
I would like manually choose resources enter route (enter, enter1 or enter and enter1) before running the model. My methods of introducing variable or parameters failed.
Not sure how to link the exit to the radio button?
You can use this code in the "on exit" code of your exit block:
if (radio.getValue() == 0) {
enter.take(agent);
}
else if (radio.getValue() == 1) {
enter1.take(agent);
}
else if (radio.getValue() == 2) {
// decide yourself which enter block, can use randomTrue(.5)....
}
else {
error("Unexpected radio choice");
}
Related
I am trying to perform text validation on my textFields for user login and sign up and I want to display error text depending on what the user inputs. I have been trying to find if there is any sort of default implementation for displaying error text in or around a textfield that I can build off of but I have not been able to find anything. Is there a solution that doesn't involve relying upon external libraries?
I already have the logic for validating the textFields but I just need to display messages to the user. This is what I have:
#IBAction func signUpButton(_ sender: UIButton) {
if (emailTextField.text == "") {
print("Please enter an email.")
} else if (passwordTextField.text == "") {
print("Please enter a password.")
} else if (confirmPasswordTextField.text == "") {
print("Please confirm your password.")
} else if (confirmPasswordTextField.text != passwordTextField.text) {
print("Please ensure that your passwords are matching.")
} else if (!emailTextField.isEmail()) {
print("Please enter a valid email address.")
} else if (!passwordTextField.isValidPassword()) {
print("Passwords must be at least 8 characters in length and must contain at least one letter and one number.")
}
}
your can use UIAlertController to show the error messages.
For textField use
yourTextfield.text = "Error Message"
If you're looking for a built-in solution that is really low-effort like
inputView.validationErrorMessage = "you must enter an email"
then no, there is no such thing built in to UIKit. However there are many built-in mechanisms that can be very easily used to show error messages.
For example, UIAlertController can show a modal popup with possible options for them to choose from. Another approach is to add labels or imageviews that indicate a validation error and use the isHidden property to show/hide them at the appropriate time.
i made a GUI for a project, it has multiple forms and i don't know how to connect them.....the thing is that the navigation between these forms is not linear.
The user's choice on the first page (radiobuttons) decides what the next form will be, i developed a basic algorithm using if statements, but i don't know the navigation action.
here's the if statement
void InputChoice::on_commandLinkButton_clicked()
{
if (ui->radioButton->isChecked()){
//Go to state vector input;
}
if (ui->radioButton_2->isChecked()){
//Go to orbital element input
}
if (ui->radioButton_3->isChecked()){
//Go to TLE input
}
So i want to know
1- the syntax and/or the principal that we use to link the forms together.
2- How can i put it in a conditional statement.
3- i read in some place that it would be a good option to use the command link button
Thanks alot :))
void InputChoice::on_commandLinkButton_clicked() {
if (ui->radioButton->isChecked()){
//Go to state vector input;
vectorInput = new VectorInput(); // show the form
vectorInput->exec(); // Don't let anything else happen until choice is made on form
//or you could also just use show(); but the user can do other things while form is showing
vectorInput = new VectorInput();// show the form
vectorInput->show();
}
else if (ui->radioButton_2->isChecked()){
//Go to orbital element input
//Same as above
}
else if (ui->radioButton_3->isChecked()){
//Go to TLE input`enter code here`
//same as above
}
else{
//Do something.
}
//Should be something like this. If not, can you elaborate a little more or where can I see the code?
I have two UITextInput controls that I want to count the number of characters in.
For context, I have two inputs: one for email address and one for password. I also have a “Login” button. The button is inactive by default, but as soon as at least one character is entered into both inputs, I’ll programatically enable the button. This is to prevent login attempts until the user has entered a value in both fields.
So far, I’m using this approach:
if count(emailInput.text) > 0 && count(passwordInput.text) > 0 {
// Enable button
} else {
// Disable button
}
Is using the count() function acceptable? Or is there a better way? As I recall there are some gotchas with checking the length of strings in iOS/Swift.
For me personally the following code has worked fine in past.
if (!emailInput.text.isEmpty && !passwordInput.text.isEmpty) {
// enable button
} else {
// disable button
}
if((emailInput.text!.characters.count) > 0 && (passwordInput.text!.characters.count) > 0) {
// Enable button
} else {
// Disable button
}
Swift 4
emailInput.text!.count
Swift 2
self.emailInput.text!.characters.count
but if you need to do something more elegant you can create an extension like this
Nowadays, after putting count directly on text property my guess is to use this directly without extension, but if you like to isolate this sort of things, go ahead!.
extension UITextField {
var count:Int {
get{
return emailInput.text?.count ?? 0
}
}
}
I have a rather large form, that I've broken up into individual sections with "Next" and "Back" buttons for the user to navigate each step.
Here is how I set it up to work for now:
Each section is within its own xp:panel
Each xp:panel is hidden with "display:none". The transition happens when the user clicks on "Next" or "Back" by using JQuery's fade animation
What I am trying to do is, if the user clicks on "Next" I would like to validate only the fields in the current, visible section. If the validation fails, don't transition to the next step. If the validation passes, transition to the next step.
Right now, when I click on the "Next" button, every field is being validated and the transition doesn't happen.
Is there a way, that I can only validate the fields in a certain section or would I have to use something like Don Mottolo's code snippet: http://openntf.org/XSnippets.nsf/snippet.xsp?id=ssjs-form-validation-that-triggers-errormessage-controls
Thank you for your help!
P.S.: I know I could use the CSJS portion of the onClick event of the button to run some validation, but I'd like to use the "Display Error" controls.
You could look at computing the required attribute of each control that is to be validated and have that check which button is submitting the form. Tommy Vaaland has a function that does this:
// Used to check which if a component triggered an update
function submittedBy( componentId ){
try {
var eventHandlerClientId = param.get( '$$xspsubmitid' );
var eventHandlerId = #RightBack( eventHandlerClientId, ':' );
var eventHandler = getComponent( eventHandlerId );
if( !eventHandler ){ return false; }
var parentComponent = eventHandler.getParent();
if( !parentComponent ){ return false; }
return ( parentComponent.getId() === componentId );
} catch( e ){ /*Debug.logException( e );*/ }
}
Link: http://dontpanic82.blogspot.co.uk/2010/03/xpages-making-validation-behave.html
You can look at using a client side form validation framework such as Parsley: http://parsleyjs.org
This can of course be combined with server side validation for at least the final submission.
I don't see an event in the Bing map API v7 that will surface a double click event. Is there a way to do this? Assuming there isn't native support that I missed, I think I will have to write my own double click handler with a timer.
I had also a problem with the click-events. In facts, the normal click-event also fires during a double-click event. That is why I had to implement my own double-click handler. My approach can be translated to the rigth click, because I am only using the single-click event, which is also available for the right mouse button.
//Set up my Handler (of course every object can be the target)
Microsoft.Maps.Events.addHandler(map, 'click', Click);
//count variable, that counts the amount of clicks that belong together
myClick=0;
//A click fires this function
function click (e)
{
//If it is the first click of a "series", than start the timeout after which the clicks are handled
if (myClick == 0)
{
//Target have to be buffered
target= e;
//accumulate the clicks for 200ms and react afterwards
setTimeout("reaction(target)", 200);
}
//count the clicks
myClick = myClick+1;
}
//At the end of timeout check how often a click has been performed and react
function reaction(e)
{
if (myClick==1)
{
alert("Single Click!");
}
else (myClick==2)
{
alert("Double click!");
}
else (myClick==3)
{
alert("Tripple click");
}
//reset ClickCount to zero for the next clicks
myClick = 0;
}
Moreover it might be interesting to remove the standart double-click behaviour of Bing-Maps, to zoom in. This can be realized by the following code:
Microsoft.Maps.Events.addHandler(map, 'dblclick', function(e){
e.handled = true;
});
If you only use double click event
Microsoft.Maps.Events.addHandler(this.map, 'dblclick', functionHandler)
should solve the problem