covertr@gtephx.UUCP (Richard E. Covert) (06/13/89)
I just thought that I would post a few comments about GEM AES/VDI programming and my initial experiences. First, I have been programming in UNIX/K&R C for about 7 years for various companies. I know all about pointers et al. So far I have written a few small CLI driven utilities. Thenice thing about using a CLI (shell) is that you don't need to use AES or VDI. You use printf() to talk to the desktop. The bad thing is that you can't use them from the ST desktop, you need to run a shell, or CLI. Anyway, I started using Michtron's SuperDirectory (SD) floppy disk cataloging program about 2 years ago. I really like. Michtron updated it last Sept to run on Megas. The big feature that I don't like about SD is the format of its printouts. So, I decoded the SD binary databases file and wrote a program to translate it to ASCII. Then I can print it out on my SLM804 using FRONT & BACK, a public domain 2 sided print utility. But, my first version was totally CLI driven. Well, along the way I bought Michtron's WERCS Resource Editor, and then got a update to Mark Williams C (MWC) with also includes a RSC Editor. I decided to use the WERCS editor to build a dialog box containing a bar (G_BOX) to be filled as the SD file is translated. I added several text messages to identify the input and output files, and to display the number of SD records in the SD file. A local C programmer named Alan Hamilton gave me a couple of functions which he uses. One function places a banner above the file selector, thus identifying the use of the file selector. Another function will fill in the bar. Alan also gave me a test file showing how to use his functions. Now, Alan is a sharp programmer and he used the MWC RSC editor to create his original dialog box. Alan then used the MWC 'rescomp' resource compiler program to translate the RSC file into actual C code, which was then "#included" in Alan's sample program. With Alan's (and Mark Williams's) method, you don't use the 'rsc_' functions in the MWC library. You read the C file generated by 'rescomp' and use the identifiers therein in your C program. This method incorporates the RSC file into your final executable file, thus eliminating the RSC file altogether! Well, as I said earlier, I wanted to use the WERCS RSC editor to build my RSC file. And I wanted to keep the RSC file intact and seperate. As this is were I made my big mistake. The WERCS RSC editor uses drop menu bars to select the OBJECT to be created. I proceeded to create some STRING type OBJECTs. STRING objects are not editable, but since I use a file selector for choosing input and out files, I don't have any editable fields in my dialog box. So, I created a bunch of STRING fields and variables using WERCS. Or so I thought!! It turns out that STRING and TEXT OBJECTs have different structures. A STRING has a simple pointer to an area contining the ASCII characters( NULL terminated of course). A TEXT object uses an additional pointer to point to a structure (called a TEDINFO structure) which allows you to set formats, editing characteristics, etc for the TEXT object. Well, in my C program I was using (I though) a STRING variable to contain the input and output file names. So, I copied the actual filenames into the STRING buffers and promptly blasted away my memory!!! I scratched m y head, and read my manuals, and wondered for quite awhile about this. I dumped the STRING buffer, and sure enough it contained the proper filenames. So what was wrong?? Well, there is a field for each object which is the object's type. I dumped this field and found that what I thought wer STRING variables were actual TEXT variables. And since the pointer that I thought was pointing to a buffer in a STRING variable was actaully a pointer to a TEDINFO structure in a TEXT variable, I was blasting away memory!! Quite obvious once I determined the object's type! So, I went back to WERCS and reloaded my RSC file. I was still not able to determine if my variables were STRINGs or TEXTs using WERCS. This is a BIG program. I tried using the MWC RSC editor, and sure enough the variables were TEXT variables. I then proceeded to display the dialog box and to fill in the filenames. And everything worked fine. So, I guess the moral of this story is "Know Your Tools". I didn't and it cost me a lot of time debugging code that was logically correct. We call this "Operator Error" were I work!! P.S. If there is any interest I will upload the executable version of my translator. Richard (gtephx!covertr) Cover