Ask Reuben

per vs 4fd

What is difference between .per and .4fd ? 

Should I use a .per or .4fd ? 

How do I convert between .per and .4fd ? 

Why do most examples, demos etc use .per and not .4fd ?

When working with Genero form files, you will either edit a .per file in any text editor including  the Genero Studio Code Editor, or you may elect to edit a .4fd file in Genero Studio using the Form Designer.  The Form Designer and its GUI IDE gives you a near WYSIWYG experience, whilst using the Code Editor, you have to use a little imagination to think about what the finished screen will look like.

I should point out that using Genero Studio, you can preview what either format will eventually look like by using Build->Preview.

From a functionality point of view, there is no difference between using a .per and a .4fd, the benefit is the time spent with the developer creating a form.  A GUI IDE in theory allowing you to be closer to getting it right first time rather than a cycle of a few refinements as might happen in a text editor.  Also selecting property values allows you to choose a value correctly and quickly using a widget best suited to the datatype.

You should note that you can move easily between the two formats.  By right-clicking on .per in the Project Manager you should see an option “Import text Form …” which will take the .per and create a .4fd file.  To go the opposite way, right-click on .4fd in Project Manager and you should see an option “Export Text Form (.per)” which will take the .4fd and create a .per file.  These two actions can be done from the command line using gsform, they are the equivalent of gsform -import and gsform -keep respectively.

The other point to reinforce the fact that there is no functionality difference, when you compile a .4fd, what Genero Studio does is create a .per and then feeds that through the normal from compiler (fglform) to produce a compiled form .42f.

Underneath a .4fd file, if you open it in a text editor you will see that it is XML.  XML files can suffer at merge times with your version control system / source code repository.  If two or more developers have worked on the same file independently, any merge conflict may have to be resolved by editing the XML manually, rather than in the GUI IDE.  Before moving an organisation from .per to .4fd, I would recommend investigating what happens with any merge conflicts.

Interestingly a compiled form file (.42f) is also XML.  Some other languages just have you editing this raw XML as the equivalent of a form file.

You can script changes to multiple .4fd files by studying the XML and making the change to the underlying XML.  This is what effectively gsform -c does to upgrade .4fd files from one Genero version to another.

As to why do most demos and repositories use .per and not .4fd, historically that was because there was no Export Text Form (.per) option. If a .4fd developer using Genero Studio received a .per it was easy for them to convert to .4fd, but there did not use to be an equivalent to go the other way. With the introduction of Export Text Form (.per) that obstacle has disappeared.

If you want to quickly see difference between Code Editor and Form Designer in action, open a demo such as Hello World and use the Export Text Form (.per) action on the .4fd to create a .per.  Then rename the .per, (you should not have a .per and .4fd with same name in the project).  You should observe that as in these screenshots, with a .per everything is in the Code Editor whilst with a .4fd using Form Designer you will also make use of Form Structure and Properties view and have the widgets/containers in the Toolbar you can drag onto your form.


Editing .per using Code Editor


Editing .4fd using Form Designer