Discussions related to Visual Prolog
VPExplorer
Active Member
Posts: 25
Joined: 6 Aug 2012 16:56

Row equivalent to getConsoleWidth()

Unread post by VPExplorer »

Hi,

Got one more question for the week, and that should be enough to play with for the next few days, and learn by trial & error.

I'm trying to build a function similar to the Windows console FillConsoleOutputCharacter(). We have the method of getting the maximum number of characters in a row, the column width ; but I can't locate the function that returns the maximum number of rows, the height.

I think I saw it a couple of days ago, but cannot locate it anymore.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1431
Joined: 28 Feb 2000 0:01

Re: Row equivalent to getConsoleWidth()

Unread post by Thomas Linder Puls »

I don't know how to get the number you are looking for (and I don't even thing the Width is necessarily what you are looking for either).

A console has a Window which shows part of the Screen Buffer:
Console Layout properties
Console Layout properties
console-properties.png (22.56 KiB) Viewed 18566 times
The Width you can get is the Screen Buffer Width (which in Windows 10 is the same as the Window width, but in earlier versions of Windows I remember that the numbers could differ).

Similar to that number you can could also obtain the Screen Buffer Height, but that is most likely not at all the size of the window.
Regards Thomas Linder Puls
PDC
VPExplorer
Active Member
Posts: 25
Joined: 6 Aug 2012 16:56

Re: Row equivalent to getConsoleWidth()

Unread post by VPExplorer »

Thanks Thomas,

I'm familiar with the Properties dialog, but don't know how to get the maximum number of rows programatically. This is clear in other languages ; sometimes it's something like MaxColumn() and MaxRow() or something similar.

If we're doing a grid for example, we need to know the maximum **visible** number of rows, so that it can be scrolled down.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1431
Joined: 28 Feb 2000 0:01

Re: Row equivalent to getConsoleWidth()

Unread post by Thomas Linder Puls »

As mentioned there is no function for this in the console class (I am not sure why not, I have added one for future releases).

This is trivially similar to getConsoleWidth:

Code: Select all

clauses     getConsoleWidth() = Columns :-         bufferInfo(coord(Columns, _) | _) = getConsoleScreenBufferInfo().   clauses     getConsoleHeight() = Rows :-         bufferInfo(coord(_, Rows) | _) = getConsoleScreenBufferInfo().
But that does not help you in your version.

The recommended way to deal with modifications to pfc, is to have some directory which shadows the official pfc directory and place modified files there:
  • you place a copy of console.cl and console.pro in <myPath>\pfc\console and
  • make <myPath> an include directory (in Project -> Settings -> Directories -> Include Directories) higher in the list than $(ProDir) (but lower than ".").
Regards Thomas Linder Puls
PDC
VPExplorer
Active Member
Posts: 25
Joined: 6 Aug 2012 16:56

Re: Row equivalent to getConsoleWidth()

Unread post by VPExplorer »

Perfect, thanks Thomas.
Post Reply