Under constructionFrequently Asked Questions about Visual Eiffel

(If you have a new question - send it to us. As soon we get the same question the second time we will include it here ;-). Please also see our buzzword list - maybe you will find the answer there.

See also the Display Machine (DM) FAQ!

How can I How the system

I have a problem:

Why


DLLs

are explained in ....\EXAMPLES\WINLIBS\MULTI.DLL - have a look at this example in your Visual Eiffel installation - and also here.


Speed up the execution time

First, finalize your program. This will enable the compiler to put a lot of optimizations in - especially if you use ARRAYs. We will provide in the near future a profiling option for Visual Eiffel. This will help you to optimize in the right places. Then, make sure that you compiled everything to native code - not to p-code. Finally, use the profiler and the tuner tool we provide. In extreme cases it can be useful to rewrite the most time critical parts using another, specialized language (for example Fortran for numeric applications)

Keep in mind that in Eiffel there is usually a trade off between storage used and speed - if you have not much ram, your application will run slower. Paging will slow down any applications. So, use the appropriate Windows tools to find out about the paging activities. Our tuner application will help you in fine tuning your Visual Eiffel application for maximum speed.


Interface between C and Eiffel

(Applies also to other languages) First it is important to know that Visual Eiffel and the Visual Eiffel linker use the COFF format. So additional object modules must be available in this format. If your C compiler cannot produce COFF object files, you should probably use a third party linker which can link both formats together. As in this case you must link you programs "manually", be aware that the proper linker commands (for the Visual Eiffel linker and MS link) are stored in a .rsp file in the EPROJECT subdirectory of your project. The parameter passing conventions between Eiffel and other languages are described in a special chapter


Make an executable smaller

There are several ways to do this. First, you can use the DLL form of the runtime. This option can be set in the .esd file or by setting the proper toggle in the project option area of the workbench. Next we suggest to use the finalize option or the finalize command in the workbench.

In some special situations it may make sense to break down your application into some small DLLs. We have done this with Visual Eiffel itself.  The compiler itself (about 200,000 source lines) is a DLL of about 3 MB RAM.


Accessing the VE API interface

In order to perform this task we provide a collection of useful examples in the Visual Eiffel delivery. Please look into the examples/misc/ve_api subdirectory.


Expanded Types - C structures

The expanded types are implemented in Visual Eiffel as one would expect: The objects contain no additional information (like a header) and can be used exactly instead of a C structure. The following Eiffel class:

expanded class EXP_TST
feature {NONE}
	i : INTEGER;
	j : INTEGER;
	k : INTEGER;
end

is equivalent to the C structure

typedef struct _EIFFEL_EXPANDED
{
	int i;
	int j;
	int k;
} EIFFEL_EXPANDED;

So it is possible to call an external C routine using a parameter of type EXP_TST. This parameter has the type EIFFEL_EXPANDED on the C side. (there is a complete example available in .. examples\expanded\example1

In this way API parameter blocks can be built in Eiffel without the need to have an additional C layer in between. You can call all Windows API directly from Eiffel - and you can set all parameter blocks in corresponding expanded Eiffel classes. As an (rather big) example we provide the WINLIBS library as part of the Visual Eiffel setup.


Delete Visual Eiffel

This should never be necessary ;-) - only if you sell your computer, but even then it is enough to delete the activation key ve.key from the bin directory.

If you really want to uninstall Visual Eiffel, do it the official way: select add/remove programs in the control panel and select Visual Eiffel. Windows will do the rest for you.


Remove a project

You will see sooner or later that there are to many projects in the repository. This is not bad per se, but it becomes more and more difficult to handle a extremely big repository. In addition the compiler creates a database for each project and each library. This database is not as big as one may expect - typical sizes are between 0.5 Mbytes for a small and 5 Mbytes for a medium sized project.

Visual Eiffel gives you three opportunities. You can release the complete storage used by the project, compress it (using the export facility) and you can unmount a project - keeping all information but dismount it from the repository...


Starting the debugger

First you should be sure that the project has been successfully compiled.

Debug options the debugger is activated by pushing the Go button in the speed bar. If this does not work, check the compiler options. It is necessary to set the toggle to include the debugger information. "Go" button

Why we have two .esd files

The reason is rather simple: it is possible to manipulate the .esd file manually with an editor. But the workbench can also set different options. So we must decide who is right - and whose options are correct.

As this decision will be always wrong, we decided that the workbench will always create a file with the name project.esd and use this file - for compilation and in order to save the options you entered into the workbench dialogs. The first project.esd file will be created based on the esd file you selected when you opened the project for the first time from the workbench.


Get more information about Visual Eiffel?

We suggest that you subscribe the Visual Eiffel mailing list.


Combine classes from more than one folder into one library

We have a special compiler option /fp (for parse path) for this purpose. Go to the folder where you want to create your library and parse all Eiffel classes you want to include into your library. Lets assume the folders are c:\my_lib\folder_1, c:\my_lib\folder_2 and m:\your_lib\folder. The library is to be created in d:\newlib - and there is already a pfd file lib.pdf.

So, go to d:\newlib and issue the following commands:

vec /pf:c:\my_lib\folder_1  /pf:c:\my_lib\folder_2  /pf:m:\your_lib\folder
vec /p:lib.pdf

Question:

Is there any way to read INTEGERs, REALs, etc from a given memory address?

Answer:

Use 'mem_copy' from class MEMORY (kernel cluster), or if your structures are 4 bytes long you can alternatively use 'ptrval_to_int' from class MACRO (WinLib cluster). For example, to read a value from a memory address into an INTEGER, use:

i: INTEGER
address: INTEGER
p: POINTER
...
address := ...
p.from_integer (address)
i := macro.ptrval_to_int (p)

You can replace the last line by this one:

mem_copy ($i, p, 4)

This generates a compiler warning (because Eiffel is very strict about where the address operator "$" may be used) but Visual Eiffel allows it to be used more freely. You have to use the second form if you want to read other than 4 bytes (e.g. one character at a time).

You can freely convert between INTEGER, POINTER and BIT 32 in Visual Eiffel.


Question:

Is there any way to read/write data from/to a binary file?

Answer:

The following approaches can be used:

Mapping the file into memory
The Windows API is used to to open a memory-mapped file, so that the contents of the file can be addressed as if they were memory. Then the requires value(s) is(are) obtained as described above.
Using features read_stream and put_string from the class FILE
The other approach is to use read_stream from class FILE (cluster Kernel). The data will be available as a STRING object through the last_string feature. To complicate the things one can access the binary data from the internal storage area of last_string using feature to_c from the class STRING. Feature put_string of class FILE may be used to output a sequence of bytes, taken from the supplied STRING argument.
Using PERSISTENT_ARRAY
Class PERSISTENT_ARRAY [G] from the cluster Pool allows to treat a file as an array - for example PERSISTENT_ARRAY [CHARACTER] for character-by-character access. For this puprpose, G should be substituted with an expanded type without reference attributes. Elements of the file can be accessed in any order by their index. Both predefined expanded types and user-defined expanded types are applicable. E.g., PERSISTENT_ARRAY[INTEGER] can be used to read and write binary sequences of INTEGERs. PERSISTENT_ARRAY [BAR], where
expanded class BAR
   feature
      length: DOUBLE;
      color: CHARACTER;
   end -- class BAR
can be used to access a file containing 5-bytes long fixed records.
Using TEXTFILE (cluster Pool)
The class allows to read-write text files randomly. This may be used in the case when the records appear to be of text nature and are stored in one record per one line way.
Accessing the file through a raw Win32
"WINAPI" external features may be used to access the Win32 API directly from Eiffel and to perform a low-level file I/O. This requires some knowledge of the Win32 API, so, probably, you'll have to get out a Win32 API manual or be familiar with the Win32 calls. The features are partially wrapped in the cluster WinLib.

Question:

I've got a fixed sized structure that I would like to send to a device. The structure represents a device command, and the only point of commonality between the commands is the structure's size. What might be an integer value in one case is a bit field in another. Is there a class which would offer me such low level control over this structure?

Answer:

No problem. Define your structure as an expanded class. Where your structure maps to Eiffel types (e.g. if you have a 4-byte INTEGER), use the Eiffel types. In other cases, use BIT 8, BIT 16 or BIT 32. You can copy bits to and from Eiffel attributes (INTEGER, CHARACTER etc), then use the shift and rotation operators of the BIT class to put them into the right part of your structure. Finally, use 'mem_copy' to copy the entire contents of the structure to and from your device (or simply pass a pointer to your structure to your device driver - see class WAPI_POINT in cluster WIN_LIB for an example of how to add a feature 'ptr' that returns a pointer to the start of your structure.


Creation of a new project:

Please follow this step by step description:

  1. From the "Project" menu, select "New".
  2. In the "Project Name" field choose a descriptive name of up to 8 characters, e.g. "my-proj". You can use hyphens and underscores.
  3. In the "Directories" control, navigate to a directory where you want to put the new project. Each VE project needs a directory of its own.
  4. If you have not already got a spare empty directory, navigate to the parent directory then type a directory name in the "New Subdirectory" field. I usually make the "New Subdirectory" name the same as the "Project Name".
  5. Select a project type from the drop-down box: console application, windows application, DLL, etc.
  6. Type the executable name in the "Executable Name" box, but don't add the trailing ".exe". I usually make the "Executable Name" the same as the "Project Name".
  7. Leave the default root class of MAIN, and the default creation procedure of 'make'.
  8. Leave "Create template for the root class" checked.
  9. Click "Create".
  10. You are now presented with a list of available clusters, with two already inserted into your project: one with the name of your project, and the other being the KERNEL. Unless you intend to use one of the other library clusters, just click OK.
  11. You are now presented with a window containing some code, with a heading "New Source File". From the "File" menu, select "Save As" and for the "Name" field type "main" then click OK. Your window should now be renamed to "main.e" in your project directory.
  12. The MAIN class is pre-filled with some standard stuff that Object Tools use in their own code, but it's easier to just delete it and type in your own stuff: (you can also change the templates !)
    class MAIN
    creation make
    feature
    	make is
    		do
    			print("My new program...press a key to exit!")
    			io.read_character
    		end
    	end
  13. Click the "Build" button - it's a yellow lightning bolt icon. Use the "Tooltips" to find the right button. Compilation and linking takes about five seconds on a Pentium.
  14. If it compiles without errors, click the "Go" button (again, use the tooltips) and your application should run.

Copyright © Object Tools -- info@object-tools.com
Last updated: 2005/02/02 11:51:33