22.01.2015 Views

HDevelop User's Manual

HDevelop User's Manual

HDevelop User's Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

90 CHAPTER 4. CODE GENERATION<br />

4.4 General Aspects of Code Generation<br />

In the following, general differences in the behavior of a <strong>HDevelop</strong> program and its exported<br />

versions are described.<br />

4.4.1 Assignment<br />

In <strong>HDevelop</strong> each time a new value is assigned to a variable its old contents are removed automatically,<br />

independent of the type of the variable. In the exported code, this is also the case<br />

for iconic objects (C++: ÀÓØ, Visual Basic: ÀÍÒØÝÔÇØ) and for the class ÀÌÙÔÐ<br />

(C++) and the type ÎÖÒØ (Visual Basic), as they all have a destructor which removes the<br />

stored data. As the language C does not provide destructors, the generated C code calls the<br />

operators ÐÖ Ó and ×ØÖÓÝ ØÙÔÐ to remove the content of iconic output parameters<br />

(ÀÓØ) and control output parameters (ÀØÙÔÐ) before each operator call.<br />

However, problems arise if a tuple (variant) contains a handle, for example for a file, a window,<br />

or for OCR. In this case, the memory of the handle is automatically removed but not the data<br />

which it points at. In the exported programs, this data has therefore to be removed explicitely<br />

by calling the corresponding operators ÐÓ× like ÐÓ× ÓÖ or ÐÓ× ÓÚ. Please insert<br />

the ÐÓ× operators for all handles in use<br />

¯ before a new value is assigned to a handle and<br />

¯ at the end of the program.<br />

In Visual Basic, the ideal way would be to use the specific COM classes for this kind of data in<br />

combination with the member function. This exchange has to be done “by hand” because the<br />

export is not able to generate appropriate code.<br />

4.4.2 ÓÖ - Loops<br />

<strong>HDevelop</strong> and the programming languages have different semantics for loops, which can cause<br />

confusion. Because the problems are so rare and the generated code would become very difficult<br />

to understand otherwise, the code generation ignores the different semantics. These differences<br />

are:<br />

1. In the programming languages, you can modify the loop variable (e.g., by setting it to<br />

the end value of the condition) to terminate the loop. This can’t be done in <strong>HDevelop</strong>,<br />

because here the current value is stored “inside” the ÓÖ-operator and is automatically<br />

updated when it is executed again.<br />

2. In the programming languages, you can modify the step range if you use a variable for<br />

the increment. This is also not possible with <strong>HDevelop</strong> because the increment is stored<br />

“inside” the ÓÖ-operator when the loop is entered.<br />

3. The last difference concerns the value of the loop variable after exiting the loop. In the<br />

programming languages, it has the value with which the condition becomes false for the<br />

first time. In <strong>HDevelop</strong> it contains the end value, which was calculated when the loop<br />

was entered.<br />

<strong>HDevelop</strong> / 2000-11-16

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!