Tool to change path

Tool to change path

Postby Otto » Wed Apr 24, 2019 7:17 pm

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  Expand view  RUN


#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  

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


********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm

Re: Tool to change path

Postby Otto » Sat May 04, 2019 8:29 pm

Hello,
I extended the program to select a domain or localhost.
Best regards,
Otto
Image
Code: Select all  Expand view  RUN

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  

//----------------------------------------------------------------------------//
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 46 guests