Help - Search - Members - Calendar
Full Version: How To: Multiple Field Input Form Example
Macro Express Forums > Community Forums > Macro Express 3.x Third Party Tools
floyd
Getting input from a user in Macro Express is done through prompting or picking choices from a menu. It is a linear process. Ask a question. Get an answer. Ask the next question. Get the next answer. And so it goes. For example, if you want to get a user's first name, last name, and email address, you would prompt three different times, once for each bit of information. It would be nice if all three fields could be placed on a single form for the user to fill in but there is nothing in native Macro Express that will allow this.

You can, however, use Macro Express to generate and power a multiple-field form built from a script. Here is an example. The form is actually an HTA file, which stands for HTML Application Host. It is essentially a web page without all the baggage and is a feature built directly into Windows. If you look in your system folder you will see a file named mshta.exe, which is used to run HTAs.



The attached example macro is self-contained. It is all you need to run the example because it actually generates the HTA file, which in turn writes string variables back to the macro. You only need to import the attached playable (.mxe) file into any Macro Express library (.mex) file. Nothing else is required. There are no external files to deal with. And it cleans up after itself. Any temporary files that are created in your system temp folder are erased before the macro terminates.

The example form contains:
  • Text fields
  • Radio buttons
  • Check boxes
  • A drop-down combo box
  • A multiple-pick list
  • Command buttons
All of which return the user's choices to Macro Express in the form of string variables.

A word about the script. Don't be shy. Take a look at it. It's just a standard HTML document. In fact, if you were to export it out of Macro Express and change the file extension to .htm, it would run in your browser. There is no doubt that you will need to know how to create an HTML document if you want to create a form like this. It isn't that hard to do if you stick with just the basics. That being said, this example goes beyond the basics by using accelerator keys, button handlers, special formatting, and so forth, but I tend to do that when programming. Our clients love it. But Joe ... well never mind. You are free to use this one as a starting point.

A word about security. The advantage to using HTAs is that they are run as trusted scripts because they are local and carry none of the security baggage requirements of a web page. It is also the kind of thing that will make some anti-virus software scream and rant and rave and carry-on like nobody's business, about running a script file. If you are concerned that this example macro and script file might contain a virus (they do not), then feel free to scan the playable (.mxe) file before doing anything with it. Peace-of-mind is a wonderful thing.

A word about testing. I tested this macro and script using Internet Explorer 6 under Win'XP, Win'2k, and Win'98. I believe (but am not sure) that it will also run under Win'ME and Win'95. If I had, or used, Netscape, Opera, or Firefox I would have tested those also. But I don't. So I didn't. So it goes.
jowensii
That looks great. I have been a ME user for several years and I have been patiently waiting for the ability to do this. Even though it's not just native to ME, this workaround is greatly appreciated.
Nicolas
blink.gif

I sometimes compile C++ exe files to have them launched by Macro Express macros, but I would never have thought to dynamically generate VBScript files or HTML files that will dynamically generate MXE files ... laugh.gif ...

that's GREAT !!! wub.gif

I will probably never use your samples "as is", but they are definitely full of small tips and ideas to create our own (powerful) macros ... many thanks !! biggrin.gif
randallc
Hi Floyd,

Thanks so much for the multiple field input.
For those of us who are not programmers, I thought I would post my attempts to make those scripts usable from Macro Express;

I have posted them as playable, but they need to be imported with the same name to interact; using environment variables to help setup my own forms.

I have not yet set it up to save a text file with my own form field definitions for each task, which would be the next step.

Someone who uses onlyME should be able to set up their own forms using this, without changing the VB sript any further.

can it be simplified or developed further for easier use?

Best, Randall
randallc
this allows 10 input field (minimum zero)

If the first field has "hi", re-running allows re-naming the buttons.; see thee pictures in the word document
best, Randall
randallc
Woops, if you have bothered to look, I had intended to make my 2 forms able to accept the buttons without input in the fields; corrected main macro only attached.
(btw, the macro not used in the zip download above ("ChangeMultiOrig") defines all the environment variables for the form labels in the original macro from Floyd (disabled as scrip1 in my "VarMultipleFieldForm" macro)
Randall
randallc
Hi, Floyd,

Win98 with IE5.0 does not show the subcategory names ("Halogen" etc), and nor does Win 95 (as I can't update IE 5.5 in Win 95?)

If anyone wants the single playable macro (hard to read), please let me know; it now also makes the text files to load whichever form you have previously made)

Can we call VBA Word macros directly like this too?

Thanks, Randall
floyd
randallc,

Thanks for the feedback on IE 5.0.

I ran the macros that you posted in order to determine an answer to your question "... can it be simplified or developed further for easier use?". I think so, although your idea of running a macro to develop field names has some uniqueness to it.

I think a tool should be designed which allows developers to generate forms from the ground up. It will need to gather specific information about each Control. And the controls themselves might need to be limited to Text fields, Check boxes, and Radio buttons. Obviously I am thinking small to begin with. Data to be gathered would include positioning for all the controls in addition to Labels for Text boxes and fields.

Once all the information is assembled the macro would generate the necessary Macro Express code and the required HTA code, combine both into an MXE, and as a final step, import it all into an MEX library. ... *poof* a self-generated macro.

As to the "Can we call VBA Word macros directly like this too?" question ... the answer is, yes, and it is not something that requires an HTA. A VBScript will suffice. It would, in fact, replace the Word or Excel VBA macros, rather than just run it. VBScript (.vbs) files can be generated by Macro Express in the same manner that it generates HTA files.

Again, thanks for your feedback. And thanks to jowensii and Nicolas, too.
randallc
Here is my update for people who would like to be able to use multiple field input from MacEx;

It is not done by a programmer!

Anyway, the zip now has 4 macros to import.

1. VarMultipleFieldForm
2. inputFieldChangeMulti
3. InputChangeMulti
4. Copy of Copy of ChangeMulti


After running “Varmultiplefield” once, cancel.
Then run again. Write “hi” in the top field.

Re-run, re-name your buttons if you wish (by inserting field entries)

By then, 2 text files will be in your “c:\program files\macro Express3” directory;

1. One for the form with 10 button names “Buttonsform1.txt” (edit these directly, and/or save them with various text file names for later use if you wish) You need never do this if you only wish to develop the one form.
2. One for the form with 10 field input names “fieldsform1.txt”

I guess it will be a while before Floyd evolves his fully fledged macro for specifying what fields are needed.

If anyone makes any forms to use by using his other buttons, could you please post them?
If anyone finds this is not working as expected, please let me know!

Best, Randall

(PS Floyd – Opera and Firefox work for the “Halogens” etc; but do not re-size or “submit”
floyd
G'Day Randallc

Thanks for the new macros. I like the concept of having a form generate a form, but I am confused as to the end result. If the form that I want generated just required text input fields, could I do that? My assumption from the instructions is that the VarMultipleField macro generates a form, or it generates the 2 text files contained within the Macro Express home folder, or both. But how do I actually use them?

-----------
So, do you mean that the Submit button does not work at all in Opera and Firefox, or do you mean that it does not get enabled or disabled? To a larger question: are you running the HTA from within Firefox and Opera by renaming to HTM? Or are you running it using mshta.exe from the macro?
randallc
Hi, Floyd.

QUOTE
"If the form that I want generated just required text input fields, could I do that? "


yes; Sorry I have not been clear.

Once you would run that macro and name the buttons, the field text file will be generated as well as the button text file;

Then use only the appropriate HTA %T1% .

In "VarMultipleField " macro, I have set up the field form to run only if "hi" in firstname field; but you could then just use that in your own macro as a text input form, using that hta script;

CODE
Variable Set String %T1% from Environment Variable
   If Variable %T1% = "hi"
    Macro Run: inputFieldChangeMulti
    // radioscript8
    Variable Set String %T1% "<html>PGMCRLF<head>PGMCRLF    <meta http-equiv=
    // radioscript7
    Variable Set String %T1% "<html>PGMCRLF<head>PGMCRLF    <meta http-equiv=
   Else
    // ScriptButtons2 - still allows option to bring up renaming form
    Variable Set String %T1% "<html>PGMCRLF<head>PGMCRLF    <meta http-equiv=
    // ScriptButtons3 - scrip to use once stable, renamed
    Variable Set String %T1% "<html>PGMCRLF<head>PGMCRLF    <meta http-equiv=
   End If
   Variable Set %T2% to ASCII Char of 10
   Variable Set %T3% to ASCII Char of 13




So "Macro Run: inputFieldChangeMulti" imports the field names for the text field input form, then you can run "radioscript7" %T1% by itself as your new form for text entry (change the field names for text entry using the text file first). I know I have confused things by giving an example to re-name the buttons,; especially as Icould be using multiple check boxes using the macroExpress input for this!


QUOTE
"are you running the HTA from within Firefox and Opera by renaming to HTM?"

Yes; even setting Firefox as default does not start HTA with a firefox window, that I can see?

Best, Randall
floyd
Okay, I will give it a try using your instructions.
------------

QUOTE
Yes; even setting Firefox as default does not start HTA with a firefox window, that I can see?

This is how it is meant to be. An HTA file is mostly nothing more than a renamed HTM file. So, if you launch it as an HTA, via Macro Express for example, then the Windows mshta.exe program will run it without all the baggage of a web page. And it should run as expected no matter which browser you use, or which is the default. Please let me know if it does not.

If you rename it to an HTM or HTML file, then whichever browser you use will launch it as a web page, complete with all the nightmares of how different browsers parse the same HTML code.
randallc
Hi, Floyd,

I have added an option to save the text field names instead; perhaps that makes my undocumented changes easier - sorry,

I don't understand the HTA thing well enough; i presume you were expecting there to be problems with firefox etc, from what you have said?

Randall
floyd
QUOTE
I don't understand the HTA thing well enough; i presume you were expecting there to be problems with firefox etc, from what you have said?

There is no difference between HTA and HTM or HTML files. You can generate an HTM file from a web page designer like those provided by Macromedia, Adobe, and Microsoft, and then rename it to have an HTA extension. If you do this, and if you double-click on it from say, Windows Explorer, it will be launched by the mshta.exe program. If, on the other hand, it remains as an HTM or HTML file, then it will be launched by your default browser.

I suspect, but am far from sure, that an HTA file will run as programmed no matter which browser you use because it is being controlled by mshta.exe and (I assume) the built-in-to-Windows portion of Internet Explorer. There is a good chance that my assumption is wrong, which isn't the first time and will surely not be the last time.
Bernd.Frisch
Under Dialogs I found a Multiple Choice Menue creating a List of different choices. I do not use this, as I find it is too much work to do 2 clicks instead of just one:
1. Select choice by marking
2. Push OK

Instead I often just open a list of choices as e.g. the Windows Explorer and add a "wait for right mouse click command" to continue. Don't you think such a solution would be simpler ?
floyd
Bernhard -

Can you explain further? I am not sure what you mean.
Bernd.Frisch
Assume I want to choose one of the files I see in a Windows Explorer in the middle of a macro.

I just enter the command "Wait for a right Mouseclick"

If I start this macro, it will open the Windows Explorer and wait
till I have marked the file I have selected and as soon as I click
with my right mouse, the macro will continue and automatically
load the file I selected.

That's the way I prefer to create a Multiple Choice.
Just mark & rightclick, that's all.

I have often tried also to show a floating textbox explaining:
"Please take your choice and continue with a right Mouseclick"
but, unfortunately, the mark on "Keep Focus" doesn't work
reliably. Kevin should keep an eye on this bug !

With this simple way of multiple choice, the only problem is to get
a good list of the choices.

In fact you could use the macro express
command "Create a multiple choice Menu" (from Dialogs)
just to show the list of choices and, instead of let people place a mark
and push OK, you should be able to continue and wait for the right
mouseclick, but I am afraid this doesn't work.
randallc
Hi, Floyd,

Here is another simple form as an example using multiple text input and the date calculator (hidden fairly much in "MacroRun" statements.)

The option to use the calendar to use 2 dates for the difference instead too, which I hadn't found before.

What do you think?

Best, Randall

(PS - Only requirement is IE6, I think! - IE5 crashes vbscript in this, then ME- RUNS ON WinME, BUT PERHAPS NOT WIN98?)

Please note also Form Making Library in separate post;

Form Making Library
iceman
Floyd,
Just as jowensii posted, I too "have been a ME user for several years and I have been patiently waiting for the ability to do this. Even though it's not just native to ME, this workaround is greatly appreciated."

Thank you so so much. biggrin.gif

The work you did is amazing.

iceman
floyd
Iceman -

We are working on adding both HTAs and data mining macros as additions to the PGM Functions library. Joe is adamant that these are going to be useful tools ... and I agree. Another user in this forum, Randall, has also taken steps in this direction.
Cory
This looks really cool and is something I really like but I get the feeling this isn’t ready for newbie prime time. I played with it a bit and started getting the creeping suspicion that if I wanted to make this work specifically for me it was going to take a lot of learning by trial and error.

Here’s my Q: I’m not an alpha geek or a programmer, is this something I can do easily?

I can make web forms, is there a way I could create a webform in FrontPage and save it to this mystical HTA format by some ‘idiots guide’ so I could use it as input in ME?
randallc
QUOTE (Cory @ Jun 9 2005, 09:56 PM)
I can make web forms, is there a way I could create a webform in FrontPage and save it to this mystical HTA format by some ‘idiots guide’ so I could use it as input in ME?

Hi,

I have no idea! - Don't know Web forms very well or FrontPage at all!
Probably possible, but you would be the alpha developer, I suspect!
Randall

PS Were you looking at the HTA formbuilder that I wrote or Floyd's original? - I can talk about mine; if so, it was still very rough when I stopped doing anything with it. The forms were really just a starter, and not easy if you've been used to a "proper" program; really I was just exploring for minor applications with a few inputs.
Graeme
Thanks for this script - I've just put it to good use taking a load of motherboard specifications, converting them to variables and then plugging them into a huge blob of html code we use as a product description template.

Quick question though - the comments say that you can return the "variant" data type the HTA uses to a integer or decimal - what is the actual syntax for doing this?

I would assume it is something along the lines of

intWrite = _
"<IVAR2:11:01:" & intStockCode & Chr(01) & ">"

or

decWrite = _
"<DVAR2:12:01:" & decPrice & Chr(01) & ">"

However, i'm really new to all this and have no idea if i'm right with that.
randallc
Hi,
Yes, but those commands (as opposed to string setting) don't seem to need the "& Chr(01) "
(In script editor, just copy the "Set Decimal" command line into an editor or "Text type" screen) and you will see there is no "unusual" character near the end as opposed to "Set String"
Best, Randall
floyd
Randall is correct (as usual) cool.gif

Variants are variables not declared specifically as integers, bytes, strings, and so forth. It is left up to the parser to decide how to convert them to run a specific operation. Parsers have rules for this of course, which allows you to take, what is usually a number, and treat it like a string as in: "<IVAR2:11:01:" & intStockCode & Chr(01) & ">". If intStockCode were really a number, you would have had to convert it to string before doing this.

QUOTE
plugging them into a huge blob of html code

Could not have said it any better. Love it!
MacroPolo
QUOTE (floyd @ Dec 28 2004, 03:48 PM)
A word about the script. Don't be shy. Take a look at it. It's just a standard HTML document. In fact, if you were to export it out of Macro Express and change the file extension to .htm, it would run in your browser.

Hello,

I have WindowsXP, and am using ME v 3.4b.

I downloaded the example, and I was unable to import the standalone into my MEX file. When I ran the standalone example, I did see the "Macro Express and HTML" window. But then I got following ME error:

An error occurred in the HTA script:

T11 - First name = Error
T12 - Last name =
T13 - Email address =
T14 - Color =
T15 - Metals =
T16 - Auto =
T17 - Tuners =

I really would like to take a look at the script to see how it passes variables back and forth between HTA and ME. Can the script be posted on the site or emailed to me?

Thanks!
floyd
QUOTE
I was unable to import the standalone into my MEX file

Was there an error of some sort during the import?

QUOTE
Can the script be posted on the site or emailed to me?

Sure ... once I figure out why all of a sudden I can't upload zip files.

In the mean time, you already have the script. Load the mxe file into a text editor and do a "search and replace" all "PGMCRLF"s with real CR/LFs.
MacroPolo
QUOTE (floyd @ Oct 24 2005, 04:25 PM)
In the mean time, you already have the script. Load the mxe file into a text editor and do a "search and replace" all "PGMCRLF"s with real CR/LFs.

Was there an error of some sort during the import?

When I imported the script, ME did not recognize the following:

<REP3:08:000002:000002:0001:1:01:N1>

(The above showed up in the scripting editor as a text type).

I wonder if this repeat is the new "repeat with process" from 3.5+? (I'm only using 3.4b at the moment).
kevin
The line
CODE
<REP3:08:000002:000002:0001:1:01:N1>
is the command
CODE
Repeat Until %N1% <> %N1%
The problem that converted it to a Text Type could have been a conversion issue from either that line or the line above it.

I am sure the macro was written with a later version of Macro Express. From time to time we have to make a change to fix a command. When we do, we are able to ensure that a newer version of Macro Express will properly read both the old and new form of the command but we cannot ensure that an older version of Macro Express will be able to understand the new version of a command.

We recommend that you upgrade to the latest version.
aoz
to all,
these utilities look very interesting. I've explored the code, and do see how it is structured.

What I wanted was a way to have several drop-down lists, with about 50 values in each; single items selected from each list.
I select one item from each drop-down, and concatenate them to create file names
example
account number _date _type of form_Sequence number

12242_20060315_statement_001
etc

I could use ME, but limitation of choice box is 36 per each.

I came across, in EXCEL, ability to do lists (excel 2003, use DATA, Validation; allows creation of lists)

Is there any easy way to take the form designs of this thread,and make a quick page of several dropdowns, with multiple selections per dropdown?

Since I ahve the Excel method working, I've put off exploring this further, but any feedback appreciated.
thanks
Nick
sunilvedula
Can someone let me know how to open this mxe file as it does not open with meproc. pls give me knowledge as i sound very naive, but could not help it
Minna
QUOTE (sunilvedula @ Jan 21 2008, 05:15 PM) *
Can someone let me know how to open this mxe file as it does not open with meproc. pls give me knowledge as i sound very naive, but could not help it


Open a macro library file (.mex) and import the playable macro (.mxe) there: File -- Import -- Import a Playable Macro...

Minna
Rustywinger
Just a few quick questions...

-Does the macro have to be playing while the HTML window is open?

-Can other macros be running in the meantime?

-Can buttons on the html form launch other macros? (ie- return a keystroke combination)

I am assuming that you can't do scripting with this, ie- JS, PHP, Server side, etc.



Thanks!
alexlimbert
Hi,

Is there any chance something like this will ever be built into Macro Express?

It's exactly what I need, but I too, and not a programmer and I am not sure how to make changes to Floyd's example to make the form fit my needs.

Alex
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.