Having problems compiling

Started by Martin Francom, May 24, 2012, 10:51:21 PM

Previous topic - Next topic

Martin Francom

I am getting a "Parameter Mismatches Definition" on this statement:

     DeleteURLCacheEntry(URLPath)

The program is a conversion of a small BP10 test program that I am trying to convert to FF3.5   The PB version
compiles and runs fine.  But the FF version won't compile.  The PB version uses:
#INCLUDE "Win32API.inc"
#INCLUDE "WinINET.inc"
So must be a conflix with Jose's Includes.   Any suggestions?

I have attached the FF project, if that is of any help.

José Roca

#1
Either declare URLPath as ASCIIZ or use DeleteURLCacheEntryW, since FF does not support %UNICODE yet.

Martin Francom

#2
Jose,
   Thanks for the help. Using DeleteURLCacheEntryW got me past that error.

But now I get a "Variable Expected" error on the URLDownloadToFile statement.
I have tried both URLDownloadToFile and URLDownloadToFileW  both get the "Variable Expected" error.
Here's the code that's having problems.


Sub GetLexiURL
   Local URLPath As wStringZ * %MAX_PATH
   Local LocalPath As wStringZ * %MAX_PATH
   Local temp As String
   Local ff As Long
   Local fl As Long

  temp = "http://www.google.com"

   'Control Get Text hDlg, 101 To URLPath
   URLPath = temp
   LocalPath = Exe.PATH$ + "localcopy.htm"
   DeleteURLCacheEntryW(URLPath)     '1 = success  clear the cache
   If URLDownloadToFile (ByVal 0, URLPath, LocalPath, 0, 0) = 0 Then
      ff = FreeFile
      Open LocalPath For Binary As ff
      temp = Space$(Lof(ff))
      Get #ff, 1, temp
      Close ff
       ' SHELL "Notepad " + "localcopy.htm"
      ? temp
   Else
      MsgBox "Download failed!", %MB_OK Or %MB_ICONEXCLAMATION, "Download URL"
   End If
End Sub


What am I doing wrong?

David Kenny

Marty,

Found your answer on the PB website, in a post by Jose.

URLDownloadToFile (NOTHING, URLPath, LocalPath, 0, NOTHING)


David

José Roca

For more information see:
http://www.powerbasic.com/support/pbforums/showthread.php?t=42036&highlight=urldownloadtofile
My post #4

http://www.powerbasic.com/support/pbforums/showthread.php?t=50193&highlight=urldownloadtofile
My posts #8 and #37

My declare is the correct one, yet PBer's prefer to use an incorrect declaration if it comes from PowerBASIC, Inc., that a correct one if it comes from elsewhere.

Martin Francom

Jose',  I fix one problem then get another.   Now it appears that I am missing the proper
declare for DeleteURLCacheEntryW   

What is the declare statement that I should be using with DeleteURLCacheEntryW ?

This is what I have in the FF_App_Start   and the  GetURL function.


#COMPILE Exe "//PROJECT_NAME//.exe"

' FireFly will automatically replace the JOSEINCLUDES token (DO NOT DELETE THIS TOKEN)
//JOSEINCLUDES//

' Place your user defined Declares, Constants, and #Include files below this line. FireFly will not
' parse any of your defined #Include files - it simply includes it in the final generated code.
' -------------------------------------------------------------------------------------------------
'#INCLUDE "WinINET.inc"

Declare Function URLDownloadToFile Lib "URLMON.DLL" Alias "URLDownloadToFileA" ( _
   ByVal pCaller As IUnknown _                          ' __in LPUNKNOWN pCaller
, ByRef szURL As Asciiz _                              ' __in LPCSTR szURL
, ByRef szFileName As Asciiz _                         ' __in LPCSTR szFileName
, ByVal dwReserved As Dword _                          ' __in DWORD dwReserved
, ByVal lpfnCB As IBindStatusCallback _                ' __in LPBINDSTATUSCALLBACK lpfnCB
) As Long                                              ' HRESULT



Function GetURL Alias "GetURL" (pURLpath As String, lPath As String) As Long
Local URLPath As Asciiz * %Max_Path
Local LocalPath As Asciiz * %Max_Path

URLPath = pURLpath
localPath = lPath
DeleteURLCacheEntryW(URLPath)     '1 = success  clear the cache

Function = URLDownloadToFile (Nothing, URLPath, LocalPath, 0, Nothing)
' 0 = Success  non-zero = failure
End Function       


I was Including  "WinINET.inc"    but I am assuming that the proper declare is in the "JOSEINCLUDES"   but
maybe I am mistaken.    What INCLUDE files should I be including?   Or, do I need to the declare for the
DeleteURLCacheEntryW ?

José Roca

Remove the declare and add:


#INCLUDE "urlmon.inc"    ' // For URLDownloadToFileW
#INCLUDE "wininet.inc"   ' // For DeleteURLCacheEntryW


Change your function to:


FUNCTION GetURL(BYVAL bstrURLPath AS WSTRING, BYVAL bstrPath AS WSTRING) AS LONG
   DeleteURLCacheEntryW(BYCOPY bstrURLPath)     '1 = success  clear the cache
   FUNCTION = URLDownloadToFileW(NOTHING, BYCOPY bstrURLPath, BYCOPY bstrPath, 0, NOTHING)
   ' 0 = Success  non-zero = failure
END FUNCTION 


Martin Francom

Ok,  figured out what I needed to do.
I added include statements for both of Joses' inc files   "WinINET.inc" and "URLmon.inc"  and now the program will
compile.  I have put this in the FF_AppStart file of the program.
#INCLUDE "WinINET.inc"
#INCLUDE "URLmon.inc"


I thought FF automatically added all of Jose's INC file but apparently not.   
How do I know when I should manually add Jose's INC with an INCLUDE statement
and when FF will automatically include them? 

José Roca

Quote
I thought FF automatically added all of Jose's INC file but apparently not. 

There are almost 1200 include files...

Paul Squires

FireFly will add includes for the controls that you include in your project. If you use any of the many hundreds of api's that are not directly control related, then you need to add an #INCLUDE reference yourself to FF_AppStart.
Paul Squires
PlanetSquires Software

José Roca

#10
These are the files included by default:

WINDOWS.INC
SDKDDKVER.INC
WINDEF.INC
WINNT.INC
BASETSD.INC
GUIDDEF.INC
NTSTATUS.INC
KTMTYPES.INC
WINERROR.INC
WINBASE.INC
WINGDI.INC
WINUSER.INC
TVOUT.INC
WINNLS.INC
WINCON.INC
WINVER.INC
VERRSRC.INC
WINREG.INC
WTYPES.INC
REASON.INC
WINNETWK.INC
WNNC.INC
CDERR.INC
DDE.INC
DDEML.INC
DLGS.INC
LZEXPAND.INC
MMSYSTEM.INC
NB30.INC
RPC.INC
RPCDCE.INC
RPCDCEP.INC
RPCNSI.INC
RPCASYNC.INC
SHELLAPI.INC
WINPERF.INC
WINSOCK2.INC
WS2DEF.INC
INADDR.INC
QOS.INC
WINCRYPT.INC
BCRYPT.INC
NCRYPT.INC
WINEFS.INC
WINSCARD.INC
WINIOCTL.INC
WINSMCRD.INC
WINSPOOL.INC
WINSVC.INC
MCX.INC
IMM.INC
IME_CMODES.INC
CWINDOW.INC
COMMCTRL.INC
OBJIDL.INC
OLE2.INC
OBJBASE.INC
UNKNWN.INC
OAIDL.INC
CGUID.INC
URLMON.INC
OLEIDL.INC
SERVPROV.INC
MSXML.INC
PROPIDL.INC
OLEAUTO.INC
AFXWIN.INC
REGEXP.INC

When controls are used, COMMCTRL.INC and <Control name>Ctrl.inc are included.

If an OCX or the WebBrowser control is used, these additional files are added:

OLECON.INC
OLECTL.INC
OCIDL.INC
DOCOBJ.INC
SHLGUID.INC
ISGUIDS.INC
EXDISP.INC
SHLDISP.INC
KNOWNFOLDERS.INC
VBINTERF.INC
MSHTMDID.INC
MSHTMLC.INC
DIMM.INC
SHTYPES.INC
OLE2UTILS.INC

Other includes must be added manually. If 1200 files had to be parsed, it would take a long time to compile.