Page 2 of 3
Passing Fox arrays by ref or value
Posted: Mon Oct 25, 2021 6:41 pm
by Karl-Heinz
Robert,
how should a X# APrinters() signature look like ? From the VFP help:
Which X# signature do you prefer ?
Code: Select all
FUNCTION APrinters ( ArrayName , nValue ) AS DWORD CLIPPER
or
Code: Select all
FUNCTION APrinters ( ArrayName AS __FoxArray , nValue := 0 AS DWORD ) AS DWORD
Should INTs be used instead of DWORDs ?
regards
Karl-Heinz
Passing Fox arrays by ref or value
Posted: Mon Oct 25, 2021 9:47 pm
by robert
Karl-Heinz ,
The signature is really not that important I think. This will most likely be used by people that have many, many untyped variables, so whatever you do, there will always be a runtime check needed.
If you declare the parameter as __FoxArray and a USUAL variable is used then there will be an automatic runtime error when the usual is of the incorrect type. When you do not declare it then you can have more control over the error message.
W.r.t. INT or DWORD: I personally prefer INT over DWORD, because signed ints are less likely to cause numeric overflows when you accidentally subtract 1 from a value of 0. This may happen in downto loops.
For unsigned ints you always have to be careful and have to consider if code is being compiled with overflow checking enabled or disabled.
Robert
Passing Fox arrays by ref or value
Posted: Fri Oct 29, 2021 11:26 am
by Karl-Heinz
Hi Robert,
attached is a modified XSharpFoxProAPrinters.viaef with a revised APrinters() function. This is how the params are checked
Code: Select all
FUNCTION APrinters ( ArrayName , nValue) AS INT CLIPPER
LOCAL cPrinterName AS STRING
LOCAL iCount AS INT
LOCAL oSearcher AS ManagementObjectSearcher
Default ( @nValue , 0 )
IF ( iCount := PrinterSettings:InstalledPrinters.Count ) > 0
IF ! IsArray( ArrayName ) .or. ( IsArray ( ArrayName ) .and. ! ArrayName IS __FoxArray )
THROW ArgumentException {"parameter must be a Fox Array", nameof ( ArrayName ) }
ELSEIF ! IsNumeric ( nValue )
THROW ArgumentException {"wrong parameter type, must be numeric", nameof ( nValue ) }
ELSEIF nValue < 0 .or. nValue > 1
THROW ArgumentException {"parameter value must be either 0 or 1", nameof ( nValue ) }
ENDIF
i also added a GetPrinter() function. The VFP GetPrinter() dialog doesn´t show e.g. "print rage" and "copies" groupboxes ás the .net PrinerDialog does. But OOB the .net Printerdialog can´t be customized to get a more VFP compatible appearance. i think: "better that than nothing"
regards
Karl-Heinz
Passing Fox arrays by ref or value
Posted: Fri Oct 29, 2021 4:05 pm
by robert
Karl Heinz,
Thanks. I will have a look at this after the weekend.
Robert
Passing Fox arrays by ref or value
Posted: Sat Oct 30, 2021 3:48 pm
by Karl-Heinz
Robert and Chris,
IMO, trying to use the .net PrinterDialog to mimic the dialog that VFP opens when the GetPrinter() is called doesn´t make sence. Attached is a core winform viaef that might be a replacement. Of course the text you see is not yet regionalzied, but as a quick view i attached two images. Fox.png shows the VFP dialog, and mine.png my dialog
. For the moment the "Status" description shows numbers only. It would be interesting to know which other values than 3 do you see when you run the app.
btw. Chris, it´s a real pleasure to build winforms with XIDE !
regards
Karl-Heinz
Passing Fox arrays by ref or value
Posted: Sun Oct 31, 2021 12:05 pm
by Chris
Glad you like it Karl-Heinz! Thanks for the code as well, I'm just not qualified to comment on what should be used, I'll just let Fox designers and/or Robert to decide on this.
.
Passing Fox arrays by ref or value
Posted: Sun Oct 31, 2021 5:10 pm
by Karl-Heinz
Guys,
1. Instead of a number you´ll see now one of the following values. However, I don't know if these descriptions match the descriptions that an english windows displays by default.
_oList:Add( "Stopped:" )
_oList:Add( "Unknown" )
_oList:Add( "Ready" )
_oList:Add( "Printing" )
_oList:Add( "Warmup" )
_oList:Add( "StoppedPrinting" )
_oList:Add( "Offline" )
2. If a printer was stopped, you´ll see now the number of waiting documents.
e.g.
"Stopped: 0 Documents waiting"
"Stopped: 2 Documents waiting"
3. The content of "Where" and "Location" is now handled properly.
regards
Karl-Heinz
Passing Fox arrays by ref or value
Posted: Sun Oct 31, 2021 6:33 pm
by Karl-Heinz
robert wrote:Karl Heinz,
Thanks. I will have a look at this after the weekend.
Robert
i noticed that the APrinters() function uses a wrong property. In the APrinters() sources the property name "Description" must be changed to "Comment".
regards
Karl-Heinz
Passing Fox arrays by ref or value
Posted: Mon Nov 01, 2021 2:51 pm
by Karl-Heinz
a queston to the VFP community.
Is it already known that there´s a VFP GetPrinter() "easter egg" ?
1. start VFP
2. Enter in the command window "? GetPrinter()"
3. As expected, the focus is set to the combobox. Now press the <Tab> and then the <Space> or <Enter> key. Magic, isn't it
. There seems to be a hidden, but not disabled [Properties] button. I tried to open the additional dialog by mouse clicks inside the dialog area, but I did not succeed.
.
regards
Karl-Heinz
Passing Fox arrays by ref or value
Posted: Mon Nov 01, 2021 3:48 pm
by kevclark64
I didn't know about the phantom button. I assume you can't click it because it's located off-screen.
The GetPrinter dialog should have a properties button, though, so if you're recreating it I'd say definitely include it.