Page 1 of 1

Tool to change path

Posted: Wed Apr 24, 2019 7:17 pm
by Otto
Hello,
I am developing offline my web programs and test online.
I wrote a little tool to change the path from offline to online.
Best regards
Otto


Image

Code: Select all


#include "FiveWin.ch"

static oWnd
static cResultPath := ""
//----------------------------------------------------------------------------//

function Main( cDbfFile )     
    local aFiles := {}
   *----------------------------------------------------------
    IF cDbfFile<>nil
        AADD( aFiles, cDbfFile )
    endif
   
   DEFINE WINDOW oWnd TITLE "Droping Files from FileManager to change path from local to web"

     @ 10,10 ;
      BTNBMP  ;
      PROMPT "Path to Clipboard" ;
          OF oWnd ;
      ACTION ( CopyToClipboard(  ), oWnd:End() )

   oWnd:bInit := {||IIF( cDbfFile<>nil, ( PaintTheName( 0, 0, afiles  ) ), ), oWnd:refresh() }

   ACTIVATE WINDOW oWnd ;
      ON DROPFILES PaintTheName( nRow, nCol, aFiles )

return nil

//----------------------------------------------------------------------------//

function PaintTheName( nRow, nCol, aFiles )

   local cName, cResult := "" 
   local n := 1
   while ! Empty( cName := StrToken( aFiles[ 1 ], n++, "\" ) )
      if "~" $ cName
         cName = SFN2LFN( cResult + cName )
      endif
      cResult += cName + "\"
   end
   
   cResult = SubStr( cResult, 1, Len( cResult ) - 1 )

   oWnd:Say( nRow, nCol, cResult,,,, .t. )  // Say in pixels
   cResultPath :=  cResult 

return nil
//----------------------------------------------------------------------------//
                   
function CopyToClipboard(  )
    local cText:= lower( cResultPath )
   local oClip := TClipBoard():New()

    cText := STRTRAN( cText, "c:\www\htdocs\", "https://winhotel.space/"  )
    cText := STRTRAN(cText, "\", "/"  )
       
   if oClip:Open()
      oClip:SetText( cText )
      oClip:Close()
   endif
   
   oClip:End()
return nil   

//----------------------------------------------------------------------------//



Re: Tool to change path

Posted: Sat May 04, 2019 8:29 pm
by Otto
Hello,
I extended the program to select a domain or localhost.
Best regards,
Otto
Image

Code: Select all

function CopyToClipboard( cCall )
    local cText:= lower( cResultPath )
   local oClip := TClipBoard():New()
    local cDomain := GetPvProfString( "Setup", "domainname", "https://winhotel.space/",  "test2web.ini")
    local clocalDir := GetPvProfString( "Setup", "localDir", "c:\www\htdocs\",  "test2web.ini")
    *----------------------------------------------------------
    if cCall = "LH"
    
        cText := STRTRAN( cText, clocalDir, "localhost/"  )
    else
        cText := STRTRAN( cText, clocalDir, cDomain  )
        
    endif  
    
    cText := STRTRAN(cText, "\", "/"  )
    
   if oClip:Open()
      oClip:SetText( cText )
      oClip:Close()
   endif
   
   oClip:End()
return nil   

//----------------------------------------------------------------------------//