[futurebasic] Re: [FB] [FBII] filepath => wdRefNum%

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 1999 : Group Archive : Group : All Groups

From: "Michael Evans" <mikonic@...>
Date: Tue, 14 Dec 1999 09:39:04 -0500
> 
> 
> Michael Evans wrote:
> 
>> > Michael Evans wrote:
>> >
>> >> help...
>> >>
>> >> I'm on the road and I don't seem to have an FN I got from somewhere that's
>> >> something like:
>> >>
>> >> CLEAR LOCAL
>> >> LOCAL FN filePathToWDrefNum%(FullFilePath$)
>> >>   DIM wdrefNumfromFP%
>> >>   '??????
>> >>
>> >> END FN = wdrefNumfromFP%
>> >>
>> >> and called like this:
>> >>
>> >> myWD% = FN filePathToWDrefNum%(FilePath$)
>> >>
>> >> Can anyone supply it or point me to it?
>> >>
>> >> TIA
>> >>
>> >
>> > Michael,
>> >
>> > Have a look at : http://www.pixmix.com/FB/HowTo/DISK/DISK004.html
>> > Cheers
>> >
>> > Alain
>> >
>> >
>> > --
>> > To unsubscribe, send ANY message to <futurebasic-unsubscribe@...>
>> >
>>
>> I tried the second fn. It does not work returning a -120 error. The file
>> path I'm testing is a valid path to a file on a CD. Norton's said The CD is
>> ok
>>
>> and the following fn says the file exists with the identical filepath:
>>
>> '=========================================
>> CLEAR LOCAL
>> LOCAL FN filePathExists(afilePath$)
>>   '---------------------------------------
>>   DIM fileExists
>>   DIM pBlk.ioHFQElSiz
>>
>>   pBlk.ioVRefNum  = 0
>>   pBlk.ioNamePtr& = @afilePath$
>>   LONG IF FN HGETFILEINFO(@pBlk) = _noErr
>>     fileExists = (pBlk.iocompletion% = _noErr)
>>   XELSE
>>     fileExists = _false
>>   END IF
>>
>> END FN = fileExists
>>
>
> Michael,
>
> I went to quickly read again the web page in the pouch, and it appears
> that the
> function you have grabbed was not tested by the poster, Eric Bennett (that's
> what he said). I left it in the page because the general discussion started
> around this function. I left also Ricks' note telling it is more likely
> going to fail
> for some raison.
> Maybe you should try to build a function using Rick's first solution
> with the
> FOLDER statement. It should be something like this:
>
>
> CLEAR LOCAL
> LOCAL FN GetWDFromPath(fullPath$)
>          DIM wdRefNum%,oldDefault%,dummy%
>
>           oldDefault% = FOLDER("", 0) 'Save old default
>           wdRefNum%   = FOLDER(fullPath$, 0)
>           dummy%      = FOLDER("", oldDefault%) 'Restore old default
>
> END FN = wdRefNum%
>
> If you need to work with the mini runtime (the FOLDER statement doesn't work
> with the mini runtime), go to the pouch again, you'll find a function that
> emulates this statement in such a case. That one was sent to the list by Staz,
> last year.
> HTH
>
> Cheers
>
> Alain
>
> --
> To unsubscribe, send ANY message to <futurebasic-unsubscribe@...>
>

Alain:
Once I figured out that providing FOLDER with the folderpath was much better
than providing it with the filepath, everything works:

CLEAR LOCAL
LOCAL FN fldrpathFromFilePath$(afilePath$)
  DIM pathsize%, count%, char$, aFldrPath$

  pathsize% = LEN(afilePath$)
  FOR count% = pathsize% TO 1 STEP -1
    char$ = MID$(afilePath$, count%, 1)
    LONG IF char$ = ":"
      aFldrPath$ = LEFT$(afilePath$, count%)
      count% = 1
    END IF
  NEXT count%

END FN = aFldrPath$

  fldrPath$      = FN fldrpathFromFilePath$(filePath$)
  CurrWDrefNum%  = FOLDER(fldrPath$, 0)

Thanks,


----------------------------------------------------------
Michael Evans
Manager of Software Development * Photo Systems, Inc.
3301 Wood Valley Road, NW * Atlanta, GA, 30327-1515
Voice: (404) 846-9386
Fax: (404) 240-0878 * Cell: (404) 229-3930
E-mail: evans@... * michael_evans@...
----------------------------------------------------------