Help with using variables

Hi

Is there a way I can use part of a variable? The variable I have is admin/employee name. I need the user to input the full amount but I only want the variable to be the employee’s name. Any ideas?

Thanks

Cheers. You might want to read Axure Substring Functional Method. It shows you how to isolate specific parts of a string (here: the variable) via substring method.

Can you give an example of how the input will be formatted?

Thanks for getting back to me. I’ve done it with a substring.

Next question! :slight_smile: Can I put a character limit on a note box?

Hi BecksParso,

If you’re using a text field widget, you can limit the number of max number of characters that can be entered using the “Max Length” field. You can find this option in the “Properties” tab of RP’s “Inspector” pane when the text field is selected:

Text area widgets don’t have this option, however you may be able to simulate this function by either using the “OnTextChangeEvent” to set the text area’s text to a limited substring as the user types or by placing a hidden text field widget with a max length over the text area. If you’re interested, jlhelmers posted these approaches here:

Hopefully this helps! I’ll also go ahead and submit a feature request to our PM team for the ability to have character limits on text area widgets.

That’s very helpful thank you.

Final question! How can I get the date to appear in the format 23 Feb 2018?

Thanks

[[now.getDate()]] [[now.getMonthName().substr(0,3)]] [[now.getFullYear()]]

:smile: Yay! Thanks for your help.

Very last question!! How can I always get it to be 1 month ahead?

[[now.getDate()]] [[now.getMonthName().addMonths(1).substr(0,3)]] [[now.getFullYear()]]

However there’s now a bug introduced here so you might need to change more things, if you care. If someone ran this prototype in December of this year, the month would show January but the year would still show 2018. If you care about this bug, then you need to store the (modified) date variable separately first, then use this the previous expression. For example:

Set variable MyDate: [[Now.addMonths(1)]]
Set text: [[MyDate.getDate()]]
[[MyDate.getMonthName().substr(0,3)]] [[MyDate.getFullYear()]]

Thanks, that’s perfect.

This really is the last question. :stuck_out_tongue_winking_eye:

I want my user to be able to input a date as 25/02/2018 but then convert to 25 Feb 2018. How can I do that?

Thanks

Hi BecksParso,

You should be able to do this by following Nathan’s same method, but instead of setting the value of the “MyDate” variable to “[[Now.addMonths(1)]]” you would set it to be equal to the text on the text field where the user has selected the date. Then setting the text of another widget to “[[MyDate.getDate()]] [[MyDate.getMonthName().substr(0,3)]] [[MyDate.getFullYear()]]” should display the date in that format.

I’d like to mention that there is a bug where hint styles would prevent values from text fields from being accessed/stored, so you’ll want to make sure that all hint styles have been removed your fields. You can do that by selecting the field, clicking “Hint Style” in the Properties tab, and then de-selecting all of the style options enabled there.

I hope this helps!