V4MD - Crash Problem

Michael Bedar mike at bedar.net
Wed Jul 19 21:01:05 CDT 2006


I was thinking that because it was working as intended on OSX, that  
the code was ok, but here it goes.. here is all the code that touches  
the table in question:  No records are present until the user installs..

I realize that this is bad DB design, but I've been trying to make it  
as simple as possible to avoid these crashes..

Table created with:

mMyWords=mDatabase.CreateTable("my_words")
mMyWords.CreateVarCharField( "folder", 1022)
mMyWords.CreateVarCharField( "realword", 1022)
mMyWords.CreateVarCharField( "type", 1022)
mMyWords.CreateVarCharField( "posp", 1022)
mMyWords.CreateVarCharField( "definition", 2044)
mMyWords.CreateVarCharField( "example", 2044)

on addMyFolder me, folderStr
   put "addMyFolder" && folderStr
   tFolderSearch = mDatabase.sqlSelect("SELECT ** FROM my_words WHERE  
folder='"& folderStr &"'")

   if tFolderSearch.recordCount = 0 then
     mMyWords.setBlank()
     mMyWords.Field("folder").value=folderStr
     mMyWords.Field("type").value="myfolder"
     mMyWords.Field("realword").value=" "
     mMyWords.Field("definition").value=" "
     mMyWords.Field("example").value=" "
     mMyWords.Field("posp").value=" "
     mMyWords.addRecord()
   end if
   tFolderSearch=void

end

on removeMyFolder me, folderStr
   put "removeMyFolder" && folderStr
   tFolderSearch = mDatabase.sqlSelect("SELECT recID FROM my_words  
WHERE folder ='"& folderStr &"'")
   tFolderRecs=tFolderSearch.getRecords()
   put tFolderRecs
   repeat with rec in tFolderRecs
     mMyWords.recID=rec[1]
     mMyWords.deleteRecord()
   end repeat
   tFolderSearch=void
end

on removeMyWord me, wordNum
   put "removeMyWord" && wordNum
   wordNum=integer(wordNum)
   mMyWords.recID=wordNum
   mMyWords.deleteRecord()
end

on addMyWord me, folder_str, word_str, def_str , posp_str, exp_str
   put "addMyWord:" &&  folder_str && word_str && def_str && posp_str  
&& exp_str
   if(mMyWords.recordCount = 0) then
     folder_str="My Words"
     me.addMyFolder(folder_str)
   end if

   mMyWords.setBlank()

   mMyWords.Field("folder").value=fixVoid(folder_str)
   mMyWords.Field("realword").value=fixVoid(word_str)
   mMyWords.Field("definition").value=fixVoid(def_str)
   mMyWords.Field("example").value=fixVoid(exp_str)
   mMyWords.Field("posp").value=fixVoid(posp_str)
   mMyWords.Field("type").value="myword"
   mMyWords.addRecord()

   --
end

on fixVoid STR
   put " "
   put "fixVoid"
   put STR
   if voidp(STR) OR STR ="" then
     put "true"
     return " "
   else
     put "false"
     return STR
   end if
end


on updateMyWord me, word_num, word_str, def_str, posp_str, exp_str
   put "updateMyWord"  && word_num && word_str && def_str && posp_str  
&& exp_str
   wordNum=integer(word_num)
   mMyWords.recID=wordNum
   mMyWords.Field("realword").value=fixVoid(word_str)
   mMyWords.Field("definition").value=fixVoid(def_str)
   mMyWords.Field("example").value=fixVoid(exp_str)
   mMyWords.Field("posp").value=fixVoid(posp_str)
   mMyWords.updateRecord()
end



on getMyWordList me
   put "getMyWordList"
   tWordC = mDatabase.sqlSelect("SELECT ** FROM my_words")
   tWordRecords=tWordC.getRecordsAsPropList()
   put tWordRecords
   put "**************************************************"
   tFolders=[]
   --Get Folders
   repeat with tItem in tWordRecords
     if tItem.type = "myfolder" then
       tFolders.add([#fRec:tItem, #itemList:[]])
     end if
   end repeat
   --Get Items
   repeat with tItem in tWordRecords
     if tItem.type <> "myfolder" then
       repeat with fItem in tFolders
         if tItem.folder = fItem.fRec.folder then
           fItem.itemList.add(tItem)
         end if
       end repeat
     end if
   end repeat
   --  put tFolders
   -- put "**************************************************"
   --
   --Make XML
   tXML="<mywords>"
   repeat with fItem in tFolders
     tXML=tXML&"<folder name='"& fItem.fRec.folder &"' id='"&  
fItem.fRec.recid&"'>"
     --
     repeat with wItem in fItem.itemList
       tXML=tXML&"<word name='"& wItem.realword &"' id='"&  
wItem.recID &"' posp='"& wItem.posp &"'>"
       tXML=tXML& "<def>" & wItem.definition &"</def>"
       tXML=tXML& "<exp>" & wItem.example &"</exp>"
       tXML=tXML&"</word>"
     end repeat
     --
     tXML=tXML&"</folder>"
   end repeat
   tXML=tXML&"</mywords>"
   -- put tXML
   -- put "**************************************************"
   tWordC=VOID
   return tXML
end



On Jul 19, 2006, at 8:41 PM, Sean Wilson wrote:

>
>> I'm running into an issue where a Director CD project  (using V4MD
>> 2.2) that I am developing on the Mac is having trouble on the PC.
>> The DB is installed on the users hard drive, at which point the user
>> is able to add data to a table.  On the Mac this works fine, but on
>> the PC, adding/modifying this table eventually, after the app is
>> opened and closed a few times, causes a crash, after which accessing
>> that table always crashes the app.
>
> Perhaps you should post some of your addition/modification code and  
> the field types you're altering.
>
>
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina



More information about the Valentina mailing list