Click to See Complete Forum and Search --> : Which language to use for an app ... ?


ebaichtal
July 6th, 1999, 12:30 PM
I have to write a program that will take input from a user, and then dump it into an ASCII file that meets a specific format. Each field has to be a fixed # of characters and filled with spaces. For example, two fields - a first and last name, each 20 characters would be "Homer ""Simpson " without the quotes though. Basically the field, then padded with spaces if it doesn't take up 20 characters, and then the next field, etc.

I was going to write this in C/C++ at first because of the string manipulation. Then I tried MS Access and got pretty close, then I thought VB might be the easiest way, but I am not sure what exactly to do.

There are some fields that will never change so I don't want to bother the user with them. But they must repeat in each entry. Each entry being 20 fields or so. (Yes, the data has to match a specific format for a legacy program.) So I'd like to send all the fields to an ASCII file and then let the user keep typing entries and then dump a bunch of entries to a file and save it, and then start over for the next time the person does this. The records don't need to be saved or archived or anything.

So where do I start? What's the best thing to do this project in? I'm a neophyte in VB and would probably have to learn VB to manipulate the ASCII file if I went with Access. So what functions or pieces of code should I be looking at for doing what I want to do? Thanks


edwardb@netcom.com

herbieII
July 6th, 1999, 11:13 PM
C is by far the best language for file and string handling of the early Yuk "BASIC". C++ is even better and Turbo Pascal is my second choice but NOT VB, it sucks.

Roger L. McElfresh

Jason Teagle
July 9th, 1999, 07:59 AM
To get the app running quickly, if you only need to take strings from the user, format them and write them to a file, then VB is the best choice for my money. A simple form with the required text boxes for each field, and a button to enter each entry plus a button to exit the program is all you need for the GUI.

Behind the scenes you need one string array for each field, and those arrays would be big enough for the maximum number of entries you want to 'cache' before writing to disk. You need an integer to count the number of entries stored so far.

When the 'Enter data' button is clicked, collect the text from each text box (using the text box's .Text property), and validate it if necessary to make sure it is not blank, does not contain illegal characters, is not too long, etc. (If it is invalid, call MSGBOX() to give them a warning.) If all fields are OK, use 'padded-string = FORMAT$(user-entered-string,"!@@@@@@@@@@@@@@@@@@@@")' (where there is 1 '@' for each character there must be in the string - for a fixed length of 20, use 20 '@'s) to pad to the required length, and store in the array (use current count value, which would start at 0, to index the array). Then increment the count of entries, and if it has reached the 'cache' limit, use 'OPEN filename FOR OUTPUT AS #1' to open the file, 'PRINT#1, field1 + field2 + field3 + field4' to write the fields out (assuming you want each padded field to sit right next to the next - a carriage return / line feed pair is automatically added to the end for each PRINT statement), and use 'CLOSE#1' to close the file. Then simply set the count of 'cached' entries back to 0 ready for the next one to be entered.

It's that straightforward.

If this is unclear, or you just want some more info, e-mail me (jteagle@geocities.com).

chiuyan
July 12th, 1999, 05:40 PM
If you can use a plain-old-command-line-dos-app (no GUI), I would use perl. You cannot beat perl's string manipulation power, it is very small and quick, and (best of all) it is free.

There are thousands of perl examples/demos/... on the web, just search for it on yahoo or something.

HTH
--michael