Most Informix 4GL programs and screen forms have the database name hard coded as the first executable statement. (Yes, Informix 4GL is old technology and it's brain dead). However, you can close the database and reopen it early in your MAIN function:
Code:
DATABASE standard
MAIN
DEFINE db_stmt CHAR(80)
WHENEVER ERROR CONTINUE
LET db_stmt = fgl_getenv("DBASE")
CLOSE DATABASE
DATABASE db_stmt
IF sqlca.sqlcode <> 0
THEN
DISPLAY "can not open database: ", db_stmt
END IF
END MAIN
In the above code, the program executes by getting the new database name, closing standard db, and opening the new database. Now, the program can go about it's business with the new database.
In production, the standard database only has to exist and be readable. It could be completely empty.
When I made a living as a 4GL programmer selling apps to other customers, my shop would develop in the standard database, and then name our customer's database something else using exactly this technique. Of course, the customer's database had to be a copy of standard or the programs would fail.
On the customer's unix box, we always had a null copy of standard.
Screen forms were a different matter. You really can not change the database name. At the time, this wasn't a hard ship because we knew what the customer's database name.
What you can do is define the database as formonly:
database formonly
Of course, this would limit the form's functionality. This forces you to define the variables with the form such as this:
attributes
f01 = formonly.jet_filter type char;
I can probably scare up an example of a screen form using database formonly.
Let me know if you have any questions.