Jump to content
Macro Express Forums

Variable (promp for value) - Limit / force / specify an entry


Sunnyboy
 Share

Recommended Posts

Good day,

 

In often uses in my macros variables such as VARIABLE > VARIABLE SET STRING > PROMPT FOR VALUE.

 

I would like to know if it's possible within the prompt, to force/verify that only letters or numbers are punched it?

Exemple:

I have an address form to fill. I will prompt a user for a value for the field "street number". My form allows only numbers. I expect the prompt for value to acept only numbers

 

Is it possible to limit the number of caracters of the prompt value?

Exemple:

I have a form to fill with a comment box that can hold 80 caracters (letters & numbers). I expect the prompt for value to limit the numbers of entry.

 

Can we force a certain number of caracters in the prompt for value?

Exemple:

I have a form to fill. I will prompt a user for a value for the field "YEAR". My form expect 4 digits. I expect the prompt for value to force the user to provide with 4 digits.

 

And finaly if a field of my form to fill can hold let's say 5 caracters but any values can be set (from 0 ro 99999) can the variable be saved once the prompt is over with spaces?

Exemple:

PROMPT (T1) = "250" // ONCE PROCESSED IT WOULD GIVE ME A VARIABLE T1= "2 5 0 _ _" (I added spaces to ease understanding).

 

Thanks for the help. :rolleyes:

Link to comment
Share on other sites

The Variable Set String from Prompt command does not have verification built in. You can, however, verify the content by placing the Variable Set String from Prompt command within a repeat loop. Something like this might get you started:

Repeat Until %T3% = "DONE"
 Variable Set String %T1% from Prompt

 Variable Set Integer %N1% from Length of Variable %T1%
 If Variable %N1% = 4
Variable Set String %T3% "DONE"
 End If

Repeat End

Link to comment
Share on other sites

Good day,

 

I would like to know if it's possible within the prompt, to force/verify that only letters or numbers are punched it?

Exemple:

I have an address form to fill. I will prompt a user for a value for the field "street number". My form allows only numbers. I expect the prompt for value to acept only numbers

Use integer variables (%N1% for example) for the prompts where you only want numbers.

 

Is it possible to limit the number of caracters of the prompt value?

Exemple:

I have a form to fill with a comment box that can hold 80 caracters (letters & numbers). I expect the prompt for value to limit the numbers of entry.

In the prompt you can remind the user how many chracters are permitted, and that if their input exceeds that number, then the response will be truncated to fit. Then write some code that looks like this:

Variable Set Integer %N1% from Length of Variable %T1%
If Variable %N1% > 80
 Variable Modify String: Copy Part of %T1% to %T1%
End If

In this code the Macro checks the length of the User's input. If the input is longer than 80 characters, the macro automatically removes all the extra

characters in that resposne.

 

Can we force a certain number of caracters in the prompt for value?

Exemple:

I have a form to fill. I will prompt a user for a value for the field "YEAR". My form expect 4 digits. I expect the prompt for value to force the user to provide with 4 digits.

This will be similar to the last one. Prompt the user for the 4 digit year, and if the user doesn't enter it correctly, then you make them do it over (this code

assumes you are using the Integer variable to force the user to use numbers only):

Repeat Until %N2% = 4
 Variable Set Integer %N1% from Prompt
 Variable Modify Integer: Convert %N1% to text string %T1%
 Variable Set Integer %N2% from Length of Variable %T1%
 Variable Set String %T2% "Your input was only %N2% digits. We require a 4-digit year."
Repeat End

The Direct Editor Text for my example looks like this:

<REP3:08:000001:000002:0002:0:01:4><IVAR2:01:02:FPlease provide the 4-digit year.
%T2%FFCenter:Center><NMVAR:05:01:0:0000001:0:0000000><IVAR2:02:12:1><TVAR2:02:01:Your input was only %N2% digits. We require a 4-digit year.><ENDREP>

 

And finaly if a field of my form to fill can hold let's say 5 caracters but any values can be set (from 0 ro 99999) can the variable be saved once the prompt is over with spaces?

Exemple:

PROMPT (T1) = "250" // ONCE PROCESSED IT WOULD GIVE ME A VARIABLE T1= "2 5 0 _ _" (I added spaces to ease understanding).

This is easy enough to do. Assuming you just want to make sure the input is at least 5 characters wide, you simply use the Modify String "Pad Right"

command. Set the padding to the total width you require (if you need it 5 characters wide, set the padding to 5, regardless of how many characters the

User inputs).

 

If, on the other hand, you're trying to add spaces between each character, that will require a bit more logic and the macro will be more complicated, but it

is still doable.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...