Page 1 of 1

Successful upgrade from 7.3 to 7.4

Posted: 7 Feb 2014 12:16
by Ferenc Nagy
Gentle Advisors,
I have upgraded my project to be published from 7.3 to 7.4 within 2 days.
I have been able to recompile and rebuild it with small changes.

1) The exception:description has changed. I am glad to see the new programPoint structure

Code: Select all

sourceCursor(                 NameOfSourceFile,                 LineNumberOfSourceFile,             ColumnOfLineOfSourceFile))
2) The new version has introduced some new gui_Native domains like lParam, wParam and others.
They appear in some process and event handling procedures where te version uses integer subtypes.
I have been able to overcome the compiler errors by uncheckedConvert calls.
a)
7.3 original

Code: Select all

Destroy = gui_Native::postMessage(Hwnd,gui_Native::wm_close,0,0),

Compiled in 7.4

Code: Select all

Destroy = gui_Native::postMessage(Hwnd,gui_Native::wm_close,uncheckedConvert(gui_Native::wParam,0),uncheckedConvert(gui_Native::lParam,0)),

b)

Code: Select all

DM_Code=toTerm(integer,DM_Str),                 stdio::writef("Draw mode will be %-15.15s = %2d that is %.",DM_Symbol,DM_Code, Explanation),                 TestWindow=vpi::winCreate(w_TopLevel,rct(0,0,240,240),Explained_Draw_Mode,noMenu,getTaskWindow(),                     plainFigure::plain_flags,                 testWindowHandler,uncheckedConvert(gui_Native::lParam,DM_Code)),
Is this workaround safe? If not, please recommend me a better one.
Anyway, how can I define a variable or constant having domain gui_Native::wParam or lparam and value=1?

Posted: 7 Feb 2014 19:08
by Thomas Linder Puls
wParam and lParam are introduced to make programs compile correctly to both 32 bit and 64 bit.

There is a little problem because one of the domains is signed and the other is unsigned. You should read the Visual Prolog 7.4 Upgrade Notes.

Lparam & Co in Upgrade notes

Posted: 8 Feb 2014 10:07
by Ferenc Nagy
Thomas Linder Puls wrote:wParam and lParam are introduced to make programs compile correctly to both 32 bit and 64 bit.

There is a little problem because one of the domains is signed and the other is unsigned. You should read the Visual Prolog 7.4 Upgrade Notes.
Thank you, Thomas.
For future readers:
The place dealing my lParam problem in the Upgrade Notes is http://wiki.visual-prolog.com/index.php ... 26_lResult
I'll continue with the applied conversion functions and constant as soon as their insertions shall have been compiled.

Code: Select all

predicates     mkW : (integer Integer) -> wParam WParam. [snip] constants     wNull : wParam = uncheckedConvert(wParam, nullHandle).

Unsigned Native

Posted: 10 Feb 2014 20:12
by Ferenc Nagy
Here are some lines using the gui_api:mk? conversion predicates.

Code: Select all

testWindowHandler(H, e_Create(_)) = gui_api::mkR(0) /* uncheckedConvert(gui_Native::lResult,0) */ testWindowHandler(H, e_Update(_Update_Rect)) = gui_api::mkR(3) :- ...     testWindowHandler(H,e_CloseRequest())=gui_api::mkR(0) :-        ... testWindowHandler(_Handler, _Event) = gui_api::mkR(0).  testWindowHandler,gui_api::mkL(DM_Code)), % MkL used according to upgrade notes.        Destroy =gui_Native::postMessage(Hwnd,gui_Native::wm_close,gui_api::mkW(0),gui_api::mkL(0)),   
The following correction shows keyword search tab of the chm help file. The 7.3 version used unchecked conversion to integer domain.. The 7.4 version uses unchecked conversion to unsignedNative domain.

Code: Select all

predicates      % Keyword search.      keywordSearch:(string Key) procedure. clauses % Keyword search.     keywordSearch(Key) :-         _=toBoolean(storeExplainingExpression(Key)), /* Old version: htmlHelp::invoke(vpi::getTaskWindow(), fullFileName, htmlHelp::hh_display_index , uncheckedConvert(integer, Key)), New version: uncheckedConvert(unsignedNative, Key) */         % 2014.02.07. Conversion with "+0" to unsignedNative.         htmlHelp::invoke(vpi::getTaskWindow(), fullFileName, htmlHelp::hh_display_index , uncheckedConvert(unsignedNative, Key)),         succeed().
The above procedure works.
Is unsignedNative a built-in domain? If it is not where is it defined?
Is the pointer to the string Key passed as the last parameter of htmlHelp::invoke?

Posted: 11 Feb 2014 9:45
by Thomas Linder Puls
From top and down.

Notice that there are constants for very common wParam, lParam and lResult values.

Code: Select all

testWindowHandler(H, e_Create(_)) = gui_api::rNull
It is a little more efficient than calling a predicate, but the difference it neglectible, so it is mainly a matter of taste whether to use one or the other.

Yes, unsignedNative is a built in domain. It is a 32 bit unsigned on the 32 bit platform and a 64 bit unsigned on the 64 bit platform.

If pointers have to be transformed into a number (which it have in many API calls) it is very important that the number has sufficient number of bits. This is why wParam, lParam and lResult are necessary. And this is also the reason that the Key (which is a pointer to the characters) must be converted into an unsignedNative.

So the last parameter to htmlHelp::invoke is not a pointer to the string Key, it it is the string Key (which is itself a pointer) seen as an unsigned number (of sufficient size).