Jump to content
Macro Express Forums

how to get user input after user edits string


margaret
 Share

Recommended Posts

Is there a way to show a string to the user, allow the user to edit it, and then store the resulting edited string? I've been looking at the dialog box options and haven't found this so far.

Hi Meg,

 

Maybe I'm reading this too simplistically, but it sounds like you would want to use a simple "Set Text Variable from Prompt"

command.

// Establish a value for the Text Variable you're planning to use:
Variable Set String %T1% "Enter Your Input Here"
// Prompt the user for the information (will replace "Enter Your Input Here"):
Variable Set String %T1% from Prompt
// Now you use the Text Variable wherein the user's input has been stored wherever necessary.
Text Box Display: Madlib

<REM2:Establish a value for the Text Variable you're planning to use:><TVAR2:01:01:Enter Your Input Here><REM2:Prompt the user for the information (will replace "Enter Your Input Here"):><TVAR2:01:02:FPlease provide a noun in the space provided.FFCenter:Center><REM2:Now you use the Text Variable wherein the user's input has been stored wherever necessary.><TBOX4:T:1:CenterCenter000278000200:000:MadlibI can't believe you're going to eat that whole %T1% all by yourself!!!  You must be a raging %T1%-aholic!>

 

If you want other macros to be able to access the information provided by the user, then you will need to use the Variable

Save command (at the end of this macro) and the Variable Restore command (at the beginning of any macro you want to be

able to access this information).

 

Keep in mind that if you use T1 in this macro for this particular input, and then use T1 in another macro where the information

is not the same as it was in this macro, the Variable Restore command will restore whichever T1 was saved last.

 

In other words:

 

Macro A: T1 = Chocolate bunny rabbits. <Variable Save>

Macro B: T1 = Pensacola, Florida <Variable Save>

Macro C: <Variable Restore> T1= Pensacola, Florida

 

However:

Macro A: T1 = Chocolate bunny rabbits. <Variable Save>

Macro B: T1 = Pensacola, Florida <NO Variable Save>

Macro C: <Variable Restore> T1= Chocolate bunny rabbits

 

Of course there is the possibility that I completely misunderstood what you are trying to do, in which case I would simply ask

for a bit of clarification.

Link to comment
Share on other sites

Is there a way to show a string to the user, allow the user to edit it, and then store the resulting edited string? I've been looking at the dialog box options and haven't found this so far.

Another thought is to save the "string" to a variable and use that variable as the Prompt, with instructions informing the user

what part of the "string" is going to be replaced.

 

// Establish a Text Variable containing the "string" to be modified.
Variable Set String %T2% "Orange County, California, has seen a population increase of more than XX% over the past two decades."
// Establish a value for the Text Variable you're planning to use:
Variable Set String %T1% "Your Input"
// Prompt the user for the information (will replace "Your Input"):
Variable Set String %T1% from Prompt
// Now you use Variable Modify to replace the text in T2 with the Text the User Provided.
Replace "XX" with "%T1%" in %T2%
// Now you use the Text Variable wherein the user's input has been stored wherever necessary.
Text Box Display: End Result

<REM2:Establish a Text Variable containing the "string" to be modified.><TVAR2:02:01:Orange County, California, has seen a population increase of more than XX% over the past two decades.><REM2:Establish a value for the Text Variable you're planning to use:><TVAR2:01:01:Your Input><REM2:Prompt the user for the information (will replace "Your Input"):><TVAR2:01:02:F%T2% 

(User: please replace XX with the figures your research has uncovered).FFCenter:Center><REM2:Now you use Variable Modify to replace the text in T2 with the Text the User Provided.><TMVAR2:21:02:00:000:000:XX%T1%><REM2:Now you use the Text Variable wherein the user's input has been stored wherever necessary.><TBOX4:T:1:CenterCenter000278000200:000:End Result%T2%>

 

You can use Text File Process commands to retrieve data for inputting into the Text String to be modified, as well as save the

Text Variable information right into a .txt file (or other format).

 

Without knowing exactly what it is you're trying to do, I can only offer limited advice.

Link to comment
Share on other sites

Another thought is to save the "string" to a variable and use that variable as the Prompt, with instructions informing the user

what part of the "string" is going to be replaced.

 

[<snip>

Without knowing exactly what it is you're trying to do, I can only offer limited advice.

 

Hi Scasper,

 

Both of your suggestions work perfectly! I think the first one is all I need for my current purpose, but I am certainly saving both of them. Yes, I know about saving the variables. What I was trying to do is to have the user delete unwanted characters in a string. so that the string would work correctly with the string-manipulation routines that follows. The content of the strings and the placement of the unwanted characters are almost all unpredictable, so there was no way for the macro to determine what to delete.

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...