| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hi all, I need to call a function in the start() method before the exec. In this function there is a call ptrHandle := Fopen2(g_Fullpathfile, FO_READ+FO_SHARED) ptrHandle is always F_ERROR, and I don't understand why. So, I shifted the call to this function in the init() of the shell. Nothing changed. If I call the same function after the exec, and the shell is opened, say, via MainMenu, all works fine. The file is there and g_Fullpatfile is global. Maybe it's too late and I am tired... what can I do to use FOpen before the exec() ? In the libraries sequence the system classes are on top. I'm missing something trivial.. TIA Massimo |
|
#2
| |||
| |||
| Massimo. There is absolutely no relationship between the function use and Exec(). None at all. There is a bug in your code and it must be in the assignment of the global. What is the value of g_fullpathfile at the point you use it? What is this file? Does it exist yet? What is its status? Etc. Geoff "Massimo Bighelli" <info@arcasistemi.it> wrote in message news:48b9b00d$0$18158$4fafbaef@reader3.news.tin.it : > Hi all, > > I need to call a function in the start() method before the exec. > In this function there is a call ptrHandle := Fopen2(g_Fullpathfile, > FO_READ+FO_SHARED) > ptrHandle is always F_ERROR, and I don't understand why. > So, I shifted the call to this function in the init() of the shell. Nothing > changed. > If I call the same function after the exec, and the shell is opened, say, > via MainMenu, all works fine. > The file is there and g_Fullpatfile is global. > Maybe it's too late and I am tired... what can I do to use FOpen before the > exec() ? > In the libraries sequence the system classes are on top. > I'm missing something trivial.. > > TIA > > Massimo |
|
#3
| |||
| |||
| Geoff, > There is absolutely no relationship between the function use and Exec(). > None at all. There is a bug in your code and it must be in the I hope you are right It's an old app ( DBU - <g>) coming from VO1.. the file is there, it's a dbf and it's ok - no one using it. I need FOpen2 in order to set the appropriate RDD for it. the global var is ok, it's not modified and works unchanged few line of code after. The global var is extracted using _GetCmdLine() [doubleclick on a DBF filetype associated to my DBU] BTW it's the FULL pathname of the dbf. Maybe some dll is not loaded at the very beginning... or there is something strange in setdefault() - workdir() - curdir()... still searching... Massimo |
|
#4
| |||
| |||
| Massimo. I don't think this is the case. Try this simple app: Function Start() Local ptrFile as Ptr ptrFile := FOpen("C:\test.dbf") // some debug message for the value of ptrFile // eg. _Debout32(....) FClose(ptrFile) Return NIL Now this works for me without flaw so start with this and add back your global etc. Your fears are not correct. The above will work without any libraries etc. Geoff "Massimo Bighelli" <info@arcasistemi.it> wrote in message news:48ba5bb0$0$1082$4fafbaef@reader2.news.tin.it: > Geoff, > > > > There is absolutely no relationship between the function use and Exec(). > > None at all. There is a bug in your code and it must be in the > > > I hope you are right > > It's an old app ( DBU - <g>) coming from VO1.. > > the file is there, it's a dbf and it's ok - no one using it. > I need FOpen2 in order to set the appropriate RDD for it. > the global var is ok, it's not modified and works unchanged few line of code > after. > The global var is extracted using _GetCmdLine() > [doubleclick on a DBF filetype associated to my DBU] > BTW it's the FULL pathname of the dbf. > Maybe some dll is not loaded at the very beginning... or there is something > strange in setdefault() - workdir() - curdir()... > > still searching... > > Massimo |
|
#5
| |||
| |||
| Massimo > I need FOpen2 in order to set the appropriate RDD for it. That doesn't make sense - FOpen() and it's friends doesn't need an RDD to open files (even DBFs). CYA Steve |
|
#6
| |||
| |||
| Steve I need to know the appropriate RDD before open the DBF i.e. ---------------------------- FUNCTION GetRDD(sFile AS STRING) AS STRING LOCAL sRDDName AS STRING // returned LOCAL pHandle AS PTR LOCAL dwBlock AS DWORD LOCAL pBuffer AS PTR sRDDName := "" dwBlock := 1 pBuffer := MemAlloc(dwBlock) IF pBuffer = NULL_PTR RETURN sRDDName ENDIF IF !Empty(sFile) pHandle := FOpen2(sFile, FO_READ + FO_SHARED + fo_denynone) IF pHandle == F_ERROR ErrorBox{,'Impossibile determinare RDD '+DosErrString(FError())}:Show() MemFree(pBuffer) RETURN sRDDName ENDIF IF FRead3(pHandle, pBuffer, dwBlock) == dwBlock DO CASE CASE BYTE(pBuffer)=0x03 sRDDName := "DBFCDX" CASE BYTE(pBuffer)=0x07 sRDDName := "DBFNTX" CASE BYTE(pBuffer)=0x83 sRDDName := "DBFNTX" CASE BYTE(pBuffer)=0x87 sRDDName := "DBFNTX" CASE BYTE(pBuffer)=0x8B sRDDName := "DBFMDX" CASE BYTE(pBuffer)=0xF5 sRDDName := "DBFCDX" ENDCASE ENDIF FClose(pHandle) ENDIF MemFree(pBuffer) RETURN sRDDName ---------------------------- "Stephen Quinn" <stevejqNO@SPbigpond.AMnet.au> ha scritto nel messaggio news:JByuk.32780$IK1.6391@news-server.bigpond.net.au... > Massimo > >> I need FOpen2 in order to set the appropriate RDD for it. > > That doesn't make sense - FOpen() and it's friends doesn't need an RDD to > open files (even DBFs). > > CYA > Steve > |
|
#7
| |||
| |||
| Geoff restarted from scratch - standard MDI application inserted few line of code and the GetRDD function (see reply to Steve) in order to read the byte before the copletion of the standardshellwindow init() call stack: start (reads the DBF file name = first parameter in global nf) StandardShellWindow:init() GetRDD(nf) <=== here FOpen2 fails Unknown error ??? StandardShellWindow oOpenFile()StdDataWindow():init() Running the app and opening a DBF from menu, all works fine and Infobox displays the sRDD Doubleclicking a DBF in WindowsExplorer, nf is ok, but GetRDD doesn't work because of FOpen2 nf is a FullPathName BTW FileType DBF is associated to my app the modified methods: ---------------------------------- METHOD Start() CLASS App LOCAL oMainWindow AS StandardShellWindow LOCAL nomelancio AS STRING LOCAL nomefile AS STRING LOCAL inizio AS DWORD LOCAL fine AS DWORD SELF:Initialize() nomelancio := Psz2String(_GetCmdLine()) // leggo la riga di comando inizio := At(' ',nomelancio)+1 // primo blank fine := RAt('.',nomelancio)-1 // punto prima dell'estensione file IF inizio > 1 .AND. fine > 0 .AND. fine > inizio // se ho trovato qualcosa... nomefile := SubStr3(nomelancio,inizio,fine-inizio+1) // estraggo nome file nomefile := StrTran(nomefile, '"') // posso avere degli apici intorno al nomefile (WINNT/2000) ENDIF IF !Empty(nomefile) //.AND. File(nomefile+'.dbf') // infine, se ho nomefile ed il file esiste... nf := nomefile +'.dbf' ENDIF DirChange(String2Psz(WorkDir())) SetDefault(WorkDir()) InfoBox{,'DBF','Opening: '+nf+crlf+; 'DBU running in '+CurDir()}:Show() oMainWindow := StandardShellWindow{SELF} oMainWindow:Show(SHOWCENTERED) SELF:Exec() RETURN NIL ----------------------------------------------- METHOD Init( oOwnerApp ) CLASS StandardShellWindow LOCAL oSB AS StatusBar LOCAL wrdd AS STRING SUPER:Init( oOwnerApp ) SetDeleted(TRUE) #IFDEF __APPWIZ__MODDRAGDROP SELF:EnableDragDropClient() #ENDIF oSB := SELF:EnableStatusBar() oSB isplayTime()SELF:Menu := EmptyShellMenu{SELF} SELF:Icon := Icon{ResourceID{IDI_STANDARDICON, _GetInst()}} SELF:IconSm := Icon{ResourceID{IDI_STANDARDICON, _GetInst()}} SELF:Caption := "Standard MDI Application" oPrinter := PrintingDevice{} // se ho ricevuto da linea comandi un nomefile, provo ad attivare subito un browser //--------------------------------------------------------------------------------- IF !Empty(nf) // leggo quale RDD //---------------- wrdd := GetRDD(nf) IF wrdd = 'DBFNTX' // ... ENDIF IF wrdd = 'DBFCDX' // ... ENDIF SELF oOpenFile(nf, .f. , wrdd) nf := '' ENDIF RETURN SELF-----------------------------METHOD DoOpenFile(cFileName, lReadOnly, wrdd) CLASS StandardShellWindowLOCAL oTB AS TextBoxLOCAL oNewChild AS StdDataWindowIF (Len(cFileName) > 3 ) .AND. (Upper(Right(cFileName, 4)) == ".DBF") oNewChild := StdDataWindow{SELF, cFileName, lReadOnly, ,wrdd}<==== 5° par = wRDD oNewChild:ViewAs(#FormView) oNewChild:Show()ELSE oTB := TextBox{SELF, "File Open Error", "Cannot open " + cFileName + " -Not a DBF file"} oTB:Type := BUTTONOKAY oTB:Show()ENDIFRETURN SELF--------------------------METHOD Init(oParentWindow, sFileName, lReadOnly, oServer,wrdd) CLASSStdDataWindow LOCAL sCaption AS STRING SUPER:Init(oParentWindow) SELF:Menu := StandardShellMenu{SELF} SELF:ToolBar:PressItem(IDM_StandardShellMenu_View_ Form_ID) sCaption := "Browse Database: " IF !IsNil(oServer) SELF:Use(oServer) SELF:Caption := sCaption + oServer:Name ELSE SELF:Use(CreateInstance(#DBServer, sFileName, , lReadOnly,wrdd)) SELF:Caption := sCaption + sFileName ENDIFRETURN SELF"Geoff Schaller" <geoffx@softxwareobjectives.com.au> ha scritto nelmessaggio news:48ba68d2$1@dnews.tpgi.com.au...> Massimo.>> I don't think this is the case.>> Try this simple app:>> Function Start()>> Local ptrFile as Ptr>> ptrFile := FOpen("C:\test.dbf")> // some debug message for the value of ptrFile> // eg. _Debout32(....)> FClose(ptrFile)>> Return NIL>> Now this works for me without flaw so start with this and add back yourglobal etc. Your fears are not correct. The above will work without anylibraries etc.>> Geoff> |
|
#8
| |||
| |||
| Why? Don't your apps just one RDD??? This would get terribly confusing. Geoff "Massimo Bighelli" <info@arcasistemi.it> wrote in message news:48bac023$0$1081$4fafbaef@reader1.news.tin.it: > Steve > > I need to know the appropriate RDD before open the DBF > i.e. |
|
#9
| |||
| |||
| Massimo. You are not helping us to help you. Did you try what I said? You know the file name so just use FOpen(".....") (no additional params) and prove to me it doesn't work. You aren't showing us real code so we have no way of helping you debug this. Reduce this down to a 5 line app like I suggested. You have a bug and I suspect it is in resolving the file name. Geoff |
|
#10
| |||
| |||
| Geoff, follwing your suggestion: shifted the call to GetRDD in the start() and all is OK. not a very big task <g> but I don't understand why calling the same function with the same parameter in a method called by the shell init() give me a diffrent behaviour... something go wrong with the filepath (or with a dll path) added bBrowser too and deleted the CATO3... .... I need to recognize the RDD of a DBF doubleclicked by the user These DBF are not of an app of mine, and are mixed, new, old, very old (DB3) with mixed indexes. My app must react accordingly, searching for fields, reindexing, trasferring data elsewhere... THX Massimo Bighelli ARCA Sistemi S.r.l. "Geoff Schaller" <geoffx@softxwareobjectives.com.au> ha scritto nel messaggio news:48bb1650@dnews.tpgi.com.au... > Why? > > Don't your apps just one RDD??? This would get terribly confusing. > > Geoff > > > "Massimo Bighelli" <info@arcasistemi.it> wrote in message > news:48bac023$0$1081$4fafbaef@reader1.news.tin.it: > >> Steve >> >> I need to know the appropriate RDD before open the DBF >> i.e. > |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.