fbpx
Welcome, Guest
Username: Password: Remember me
This public forum is meant for questions and discussions about Visual FoxPro
  • Page:
  • 1

TOPIC:

SET DEFAULt TO <xxx> behaviour 06 May 2021 15:22 #18349

  • Karl-Heinz


  • Posts: 644
  • Guys,

    it´s no final solution, i just collected what i've noticed so far ...

    In the early Foxpro days there's been no CD - (C)hange (D)irectory - command. To achieve this the command 'SET DEFAULT TO <x>' was - and still is - used. The foxpro results of e.g. 'SET DEFAULT TO F:\Test' are:
    ? Set ( "Default" ) -> "F:" - same as Sys(5)   
    ? Curdir() -> "\TEST\"
    It seems that Foxpro doesn't store the full path like VO does.
    SetDefault(F:\Test)
    ? GetDefault() -> F:\Test
    In the already posted VFPSysAndDir.viaef i modified the foxpro dialect behaviour of the X# functions curDir() and curdrive(). So the X# results would be the same.
    ? CurDrive() , Sys(5)  // "F:"  "F:"
    ? curdir() //  "\TEST\"

    A modified X# SetDefault() function might look like:
    FUNCTION SetDefault(cPathSpec AS STRING) AS STRING
    	
    	SetPathArray(NULL)
    	
        IF XSharp.RuntimeState.Dialect == XSharpDialect.FoxPro
    
    		TRY 
    			XSharp.IO.File.ClearErrorState()
    			Directory.SetCurrentDirectory(cPathSpec) 
    
    			cPathSpec := CurDrive()  // this would save the drive name only , e.g. "F:"
    			
    		CATCH e AS Exception
    			XSharp.IO.File.SetErrorState(e)		
    		END TRY
    	
    		IF RuntimeState.FileException != NULL
    			THROW RuntimeState.FileException		
    		ENDIF 	
    
        ENDIF
        
    	SETSTATE STRING Set.Default  cPathSpec 

    Note: Similar to the Foxpro dir commands the SET DEFAULT command throws a exception if a dir selection fails.

    The question is: if the Foxpro dialect is used, what should a SetDefault("F:\Test") do ? Store the given path or the drive name ?

    regards
    Karl-Heinz

    Please Log in or Create an account to join the conversation.

    SET DEFAULt TO <xxx> behaviour 10 Jun 2021 19:43 #18774

    • atlopes


  • Posts: 83
  • Karl-Heinz, I know this is already more than a month old, but I'm reviewing the last forum threads and I have a few comments on this.

    In VFP, SET("Default") returns only the drive letter, but SET DEFAULT TO x:\y stores the full path.

    Also, the path in the command is relative. So,
    SET DEFAULT TO U:\Folder
    SET DEFAULT TO SubFolder
    is equivalent to
    SET DEFAULT TO U:\Folder\SubFolder

    There is an undocumented SET DIRECTORY TO command that has the same functionality as the SET DEFAULT command, and a correspondent SET("Directory") function. The function returns the full path, contrary to SET("Default").

    That is
    SET DEFAULT TO
    SET DIRECTORY TO U:\Folder\SubFolder
    ? SET("Directory")  && displays U:\FOLDER\SUBFOLDER
    ? SET("Default")  && displays U:
    ? CURDIR()  && displays \FOLDER\SUBFOLDER\

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1