Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NO parameter statement error - when creating OOP form 2

Status
Not open for further replies.

JEWELLC77

Programmer
May 21, 2015
4
GB
Hello,

Thank you for taking to the time to look at my question\problem.

In my code below, I pass a list of PDF files as a cursor, the form displays the first field of the Cursor within a grid and also displays the selected PDF in a olecontrol, this works ok, except when I click on the second PDF within the grid, I get a "No PARAMETER statement is found" error. After multiple attempts to try and fix this error myself, I now accept I'm stuck and need help.
I'm fairly new to the world of oop so, I suspect it is something simple I'm doing wrong, but if someone could kindly point me in the right direction that would be greatly appreciated.

I've adapted my code so anyone can simply copy and paste the code below into a PRG and the error will hopefully be reproduced.

If there is anything else I can provide that might help resolve this please let me know?

********************* Copy and paste from here, save as prg and run code
CLOSE DATABASES
SELECT 0
CREATE CURSOR CurPrePDFs (file C(100), fullpath C(250))
insert into CurPrePDFS (file, fullpath) VALUES ("file1.pdf","c:\fox\file1.pdf")
insert into CurPrePDFS (file, fullpath) VALUES ("file2.pdf","c:\fox\file2.pdf")
SELECT CurPrePDFs
GO top
cRetVal = PreViewMultiplePDFs()
WAIT WINDOW cRetVal
use in CurPrePDFs
RETURN

******************************************************
FUNCTION PreViewMultiplePDFs()
******************************************************
Private pcReturnValue
pcReturnValue = ""
Local oPDFView
oPDFView = Createobject("rbPDFView")
oPDFView.Show()
Return pcReturnValue

Define Class rbPDFView As Form
Height = SYSMETRIC(2)-200
Width = SYSMETRIC(1)-310
Left = 102
Top = 5
Caption = "Preview PDF"
ControlBox = .F.
WindowType = 1
Name = "frmPDFView"

Add Object ActxBrowser As olecontrol With ;
oleclass="shell.explorer.2", ;
Height = SYSMETRIC(2)-270, ;
Left = 160, ;
Top = 2, ;
Width = SYSMETRIC(1)-280, ;
Name = "oBrowser"

Add Object gridlist As grid With ;
Height = SYSMETRIC(2)-270, ;
Left = 2, ;
Top = 2, ;
Width = 150, ;
columncount = 1, ;
Name = "Gridlist"

Add Object cmdok As commandbutton With ;
Top = SYSMETRIC(2)-260, ;
Left = SYSMETRIC(1)-580, ;
Height = 50, ;
Width = 92, ;
Caption = "Confirm All OK", ;
Default = .T., ;
TabIndex = 3, ;
BackColor = Rgb(128,255,128), ;
Name = "cmdOK"

Add Object cmdcancel As commandbutton With ;
Top = SYSMETRIC(2)-260, ;
Left = SYSMETRIC(1)-450, ;
Height = 50, ;
Width = 72, ;
Cancel = .T., ;
Caption = "Cancel", ;
TabIndex = 4, ;
BackColor = Rgb(225,0,0), ;
Name = "cmdCancel"


PROCEDURE Load
SELECT CurPrePDFS
GO Top
ENDPROC

Procedure Init
This.Gridlist.Column1.Header1.Caption = "Filename"
This.Gridlist.AutoFit()
Thisform.ShowPDF()
ENDPROC

PROCEDURE ShowPDF
LPARAMETERS uPara1
LCNAVIGATE=ALLTRIM(CurPrePDFs.FullPath)
IF !EMPTY(LCNAVIGATE)
THIS.OBROWSER.NAVIGATE(LCNAVIGATE)
ENDIF
ENDPROC

Procedure Unload
pcReturnValue = Thisform.tag
Endproc

PROCEDURE gridlist.afterrowcolchange
Thisform.ShowPDF()
ENDPROC

Procedure cmdok.Click
Thisform.Tag="YES"
Thisform.Release()
Endproc

Procedure cmdcancel.Click
Thisform.Tag="NO"
Thisform.Release()
Endproc

Enddefine
*
*-- EndDefine: rbPDFView
**************************************************
 
Change this in your code:

Code:
PROCEDURE gridlist.afterrowcolchange
[highlight #FCE94F]LPARAMETERS nColIndex[/highlight]
Thisform.ShowPDF()
ENDPROC

(even if you don't use them, you need to declare the parameters the parent methods expect).
 
That fixed it, I'll keep that in mind in future, thank you very much atlopes :)
 
Very simple. When you click on a row in the grid, the grid's AfterRowColChange event is fired. That events needs a parameter to contain the colunn number. If you look in the Help for AfterRowColChange, you wll see that the header should look this is:

[tt]PROCEDURE Grid.AfterRowColChange
LPARAMETERS nColIndex[/tt]

So just add that second line to your AfterRowColChange code, and all should be well.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thank you Mike, the quick response by yourself and atlopes is greatly appreciated.
Apologies for the simplicity of my question, it seems obvious now I know the answer :)
 
No need to apologise. The solution is not really that obvious.

By the way, don't get too hung up on your lack of OOP knowledge. An event-handler, such as AfterRowColChange, is not all that different from an ordinary procedure. And the passing of parameters is pretty much the same, regardless of whether they are being passed to a procedure, function, method or event.

Keep working at it, at the OOP will come naturally after a while.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Everything is said, except perhaps: This becomes much more apparent, if you develop your visual classes with the visual class designer, because it adds the native parameterizations of methods and events even to methods and events considered unchanged according to the property window.

I wonder whether you designed your code as prg or got it from a faq here. If the latter, you may let the FAQ writer know about an error.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top