What programming language would I need to know to write a text generator?

I’m looking to cut down on the time spent editing and rewriting responses to inquiries sent to us by e-mail and I thought a text-generator application might be just the thing. Something along the lines of the “Tom Clancy Plot Generator” (Seen here.) where I could have an entry field for dates, an entry field for price point, number of adults, number of children, number of rooms, that kind of thing. (I work in a hotel and a lot of our orders are done per e-mail as we have many regular guests)

ETA: This would optimally just be a small application I could run from the desktop, not website based.

You could do this in any number of languages…

C++
C#
VB
VB.NET
Java
(the list continues on and on and on)

Anyway, I personally think VB.NET is one of the easier languages to learn.

Thanks for the reply! :slight_smile:

How long a time (do you think) it would time to learn sufficient parts of the language to write the program? I’m asking because I’m considering calling in a few favours and get one of my smarter friends to do this for me :p)

Just because you used the word ‘text’ when describing this app you might want to consider PERL or PHP. And also, if you also happen to already know some HTML, writing this as a web based app will simply implementing the interface.

I’m passable in HTML - I.e. I’ve written a few basic home pages in notepad a decade or so ago :stuck_out_tongue: - but haven’t the faintest idea of where to begin with PHP or PERL. With your last sentence, do you mean I could just write the application in HTML/PHP/PERL and save it as a online document accessed locally? (Like the files you get when you “save” a page from a browser) So it would open in the browser and work independently of being connected to the net?

I ask because the management doesn’t want gratuitous internet traffic on the workstation and it’d be nice if I could at all avoid it.

I think the only way to do it in a total browser-based environment without having to install anything (perl, PHP, etc) or turning on IIS (if you have a Windows machine) is to use Javascript.

Look up help with Javascript and forms. It’s pretty simple. You can very easily set up a form, fill in the form, click a button and have it output some formatted text with the values of your form fields.

And it would all be contained in one HTML page.

This looks like the way to go - I’ll look up some Javascript tutorials and try to get some help from a webmaster buddy of mine when I get off work.

Thanks for the suggestions, everyone! :slight_smile:

(Though if anyone remember some examples they’ve seen that could easily be modified instead of writing the thing from scratch, or even a specific tutorial dealing with this kind of thing, I’d be much obliged.)

Yeah, that’s how it would work. I use PHP all the time for little tools and widgets that require text diddling and/or some type of field driven user interface. But as ZipperJJ points out, PHP will have to have been installed on your machine.

Depending on how you want this to work, the simplest thing might be using Mail Merge in Word. Set up your template with merge fields, then you could use a spreadsheet for the variables, or create a form with VBA.

I was going to try to find you an example by googling “javascript mad libs” but everything I found was an actual game, not a script source. I didn’t click through to any of the games but I bet that would be a good starting point. Javascript is completely transparent and you can gank any code you can find.

I bet you could do this easily in Excel. Just type the number of rooms, etc. you want in fields and then use the concatenate function in Excel to get it all done. All without having to learn any other languages. However, Excel may impose limitations on the number of cells you can concatenate, etc so I don’t know if it’s feasible, but it would be really easy to try and find out.

I second the Word Mail Merge idea. The time you spend fighting with Word and the source data to get it to work will be slightly less than the time you spend learning Perl and writing the app.

Ideally a flexible language generating app would be written in Common LISP or PROLOG, but that may involve more pain than the OP really wants :wink:

Si

I was going to suggest LISP or SNOBOL, but then I just figured I was old. :wink:

So old you still capitalise Lisp :stuck_out_tongue:

A true masochist would do this in Haskell.

Nahh - that would be hand-compiled machine code… :smiley:

There are worse languages than machine code. Brainf*ck, for example.

But I was only semi-joking with LISP and PROLOG - LISP is a List handler, and is ideal for processing or assembling textual output. PROLOG is a logical declarative language, designed for assembling and inferring the appropriate output based on the input conditions.

The fact that they are non-trivial languages to learn (and you can really break LISP code by missing one of the many parenthesis required) and the defined task is also fairly trivial mean that in reality, no one would use either of them even though they are an appropriate solution.

Si

You and me both. Either one would be my GOTO choice for something like this, since it’s what they were designed for. Some variation of C? Not so much.