[futurebasic] Re: [FB] upgrading from FB^3 release 3 to 5

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 2001 : Group Archive : Group : All Groups

From: Chris Stasny <staz@...>
Date: Tue, 31 Jul 2001 15:40:43 -0500
I can make your version of the routines fail every time. (Yes, it's 
the destructive nature of a redneck.) I can see that it might have 
quit crashing since it no longer restored the STR# resources to the 
file. Problems do not usually occur when the heap is messed up. They 
occur when the resources in a messed up heap are saved.

I also noticed that you changed an old version of the filter. The 
problem that you may have been trying to correct (that of hundreds or 
thousands of saves of the same resource) was corrected quite a while 
back when we switched to FN pGchangedResource(resHndl&) instead of 
CALL CHANGEDRESOURCE.  However, completely eliminating the call means 
that your resource will never be written to disk unless another 
function just happens to call CHANGEDRESOURCE _after_ you make your 
modification and _before_ the next save of the file. This is an 
"iffy" situation at best.

I see you have included a copy of the sort routine. If there is a 
modification that will improve it in some way, send me a note because 
I did not spot a remark relating to whatever change was made.

Also, to anyone that wishes to replace functions in PG or in the 
headers: *DON'T*. The OVERRIDE function will do that nicely, thank 
you very much. You can make all of the mods that you want and your 
application will still be in tip-top shape when the next release 
comes out. If you don't use the override function and resort to 
modifying the include, you either have to re-modify the next version 
of the include or slug along with old routines that may have been 
improved during the upgrade cycle.

I think my head is getting pointy. Is there such a thing as a redneck gnome?


>In a message dated 7/30/01 7:57:37 PM, futurebasic-digest-help@...
>writes:
>
><< I too had repeated problems with the STR# filter. I had to create my own
>and
>not use the filter because I could not find out what needed "fixing" in the
>filter. Could you post what and how you "fixed" the filter? I would much
>appreciate your help. For others info, the problem I had was an unexplained
>corruption of resources which I did not write to after just reading the STR#
>resources and in some cases doing a replace of one STR# resource and then
>after quitting the app, resedit reported a corruption of a different STR#
>resource.
>George Wood >>
>
>I'm on vacation now and I forgot to move my modified str#.incl onto my iMac.
>But I don't know that I corrected any errors, I just wanted to sort
>differently and scroll a list differently.
>
>as far as your resource errors, yes  I have had some of these too and I am
>concerened about the way I open, move and close resorse files. I recently
>learned from this list that I should flush the files that I have written
>resources to, after closng them. This may help both of us. I have not
>incorporated this technique enough to know if my corrupt resource problem is
>over (it never happened much anyway).
>
>Here are a couple of modifed routines I uses with str#:
>
>'=========================================
>LOCAL FN PQapndElement(theID,theTxt$)
>'---------------------------------------
>' Add an element to the end of a STR#
>' resource.
>'---------------------------------------
>DIM resHndl&,err,OSErr
>
>resHndl& = FN GETRESOURCE(_"STR#",theID)
>err = _noErr
>LONG IF resHndl&
>FN HNOPURGE(resHndl&)
>DEF APNDSTR(theTxt$,resHndl&)
>'CALL CHANGEDRESOURCE(resHndl&) this line commented out!
>err = FN chkResErr
>END IF
>END FN = err
>
>'=========================================
>LOCAL FN jobSortStrRes(theID,thenum%)
>'---------------------------------------
>' Sort elements of STR# resource
>' alphabetically. Case is ignored.
>'---------------------------------------
>DIM err,OSErr,elemCnt,ptr&,l,resHndl&
>DIM pLoop,gap,switch,loop
>DIM test,theSize&,newRes&,refill
>XREF @sHndl&(32000)
>
>currentcursor=13001
>err        = _zTrue
>resHndl&   = FN GETRESOURCE(_"STR#",theID)
>
>LONG IF resHndl&
>theSize& = FN GETHANDLESIZE(resHndl&)
>LONG IF theSize&
>FN HLOCK(resHndl&)
>elemCnt  = {[resHndl&]}
>LONG IF elemCnt > 1
>sHndl& = FN NEWHANDLE _clear((elemCnt + 1)*4)
>ptr&   = [resHndl&] + 2
>FOR pLoop = 1 TO elemCnt
>sHndl&(pLoop) = ptr&
>ptr& = ptr& + PEEK(ptr&) + 1
>NEXT pLoop
>'-----------------------------------
>gap         = elemCnt
>DO
>  gap      = gap/1.3
>  IF gap < 1 THEN gap = 1
>  switch   = _false
>  FOR loop = 1 TO elemCnt - gap
>   test  = loop + gap
>'-------------------------------
>' This is the sort's conditional.
>' Change the next line if you
>' want to change the order or
>' type of sort.
>'-------------------------------
>' LONG IF PSTR$(sHndl&(loop)) > PSTR$(sHndl&(test))
>  '  SWAP sHndl&(loop),sHndl&(test)
>'   switch = _zTrue
>  ' END IF
>LONG IF everyforth>800
>currentcursor=FN animatecursor (currentcursor)
>everyforth=1
>END IF
>INC (everyforth)
>
>t1$=PSTR$(sHndl&(loop))
>t2$=PSTR$(sHndl&(test))
>long if thenum%=2
>LONG IF VAL(t1$)<VAL(t2$)
>SWAP sHndl&(loop),sHndl&(test)
>switch = _zTrue
>END IF
>xelse
>LONG IF VAL(t1$)>VAL(t2$)
>SWAP sHndl&(loop),sHndl&(test)
>switch = _zTrue
>END IF
>end if
>  NEXT loop
>
>UNTIL switch = _false AND gap = 1
>'-----------------------------------
>newRes&  = FN NEWHANDLE(theSize&)
>LONG IF newRes&
>FN HLOCK(newRes&)
>% [newRes&],elemCnt
>ptr& = [newRes&] + 2
>
>FOR refill = 1 TO elemCnt
>l = PEEK(sHndl&(refill)) + 1
>BLOCKMOVE sHndl&(refill),ptr&,l
>ptr& = ptr& + l
>LONG IF everyforth>80
>currentcursor=FN animatecursor (currentcursor)
>everyforth=1
>END IF
>INC (everyforth)
>
>NEXT
>
>BLOCKMOVE [newRes&],[resHndl&],theSize&
>CALL CHANGEDRESOURCE(resHndl&)
>FN HUNLOCK(resHndl&)
>FN HNOPURGE(resHndl&)
>err   = FN chkResErr
>DEF DISPOSEH(newRes&)
>END IF
>
>DEF DISPOSEH(sHndl&)
>END IF
>END IF
>END IF
>END FN = err
>
>
>Bruce Moore
>
>--
>To unsubscribe, send ANY message to <futurebasic-unsubscribe@...>



Best,

-STAZ  ~)~

800.348.2623 Orders  http://www.stazsoftware.com
228.255.7086 FAX     mailto:staz@...