Copy File Name

Copy File Name

Postby Natter » Thu Jan 20, 2022 9:57 am

Hi,

In some application (for example, Total Commander or Explorer) I can highlight the file name and copy it to the clipboard. Is it possible to do the same from the FWH code ?
Natter
 
Posts: 1215
Joined: Mon May 14, 2007 9:49 am

Re: Copy File Name

Postby Antonio Linares » Thu Jan 20, 2022 10:01 am

Yes, sure

You can do it from a GET, or a Memo, or a RichEdit, etc.

Also you can place and recover any content on the clipboard programmatically

Please review FWH\samples\testclip.prg
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Copy File Name

Postby Natter » Thu Jan 20, 2022 10:43 am

Thank you, Antonio!

The thing is: there is a file with a header in UTF 8. A character from another code page was inserted into this header. :( I get this file through Directory() and see it like this *******?.pdf (where "?" is a character from another code table). I cannot rename this program file because for FW the file ******?.pdf does not exist. This can only be done by pasting the file name from the clipboard (for example via CMD ren or PowerShell)
Natter
 
Posts: 1215
Joined: Mon May 14, 2007 9:49 am

Re: Copy File Name

Postby Antonio Linares » Thu Jan 20, 2022 12:09 pm

You may try:

? hb_utf8tostr( *******?.pdf ) // The name that you get
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Copy File Name

Postby Natter » Thu Jan 20, 2022 12:21 pm

This doesn't fit
Natter
 
Posts: 1215
Joined: Mon May 14, 2007 9:49 am

Re: Copy File Name

Postby Antonio Linares » Thu Jan 20, 2022 12:43 pm

Please post here each char (numeric code) that you get so we can try different solutions
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Copy File Name

Postby Natter » Thu Jan 20, 2022 1:51 pm

Antonio, it will be easier if I give a link to the file. His name contains the code CC 86

https://cloud.mail.ru/public/yyLv/NZX8194xG
Natter
 
Posts: 1215
Joined: Mon May 14, 2007 9:49 am

Re: Copy File Name

Postby Jimmy » Fri Jan 21, 2022 8:02 am

hi,

have download PDF but can not open it with Firefox, EDGE or Sumatra.
i have rename PDF but still it can not be open by any of PDF-Reader which i use

so it is not a Fivewin or Clipboard "Problem" ... it is "something" with your PDF
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Copy File Name

Postby Natter » Fri Jan 21, 2022 9:29 am

Hi, Jimmy !

The file extension doesn't matter, I made an empty file on purpose! The main title is in Utf 8. I get the file headers through the directory() function, they have already been recoded relative to the code page specified in my application (I have it RU866). If there is a symbol from some other code page in the header, then this symbol is replaced with the symbol "?". If you look at the title in a 16-bit editor, there is such a symbol CC 86. As a result, I can't change this file from FW because I don't know its exact name.
Natter
 
Posts: 1215
Joined: Mon May 14, 2007 9:49 am

Re: Copy File Name

Postby Otto » Fri Jan 21, 2022 10:04 am

Hello Natter,
as there are so many code pages I use in my mod harbour programs, a handmade convert function.
Maybe this can help?
Uncommand the 3 lines to find out the ASCII value.
Best regards,
Otto


? convertUmlaute( *******?.pdf ) // The name that you get

Code: Select all  Expand view

function convertUmlaute( cVData )
    local ctest := ""
    local I := 0
   
   
 //   for I := 1 to len(cVData)
 //  ? ( cVData + CRLF + substr(cVData,I,1) + "  #  "+ str( ASC ( substr(cVData,I,1)) ))
 //   next
   
 
   cVData  :=  STRTRAN(cVData, chr(174), "®"   )

    cVData  :=  STRTRAN(cVData, chr(228), "ä"   )
    cVData  :=  STRTRAN(cVData, chr(132), "ä"   )
   
   
    cVData  :=  STRTRAN(cVData, chr(246), "ö"   )
    cVData  :=  STRTRAN(cVData, chr(148), "ö"   )
   
    cVData  :=  STRTRAN(cVData, chr(252), "ü"   )
    cVData  :=  STRTRAN(cVData, chr(129), "ü"   )
   
    cVData  :=  STRTRAN(cVData, chr(196), "Ä"   )
    cVData  :=  STRTRAN(cVData, chr(142), "Ä"   )
   
   
    cVData  :=  STRTRAN(cVData, chr(214), "Ö"   )
    cVData  :=  STRTRAN(cVData, chr(153), "Ö"   )
   
    cVData  :=  STRTRAN(cVData, chr(220), "Ü" )
    cVData  :=  STRTRAN(cVData, chr(154), "Ü" )
   
    cVData  :=  STRTRAN(cVData, chr(223), "ß" )
    cVData  :=  STRTRAN(cVData, chr(225), "ß" )

    cVData  :=  STRTRAN(cVData, chr(224), "à" )

    cVData  :=  STRTRAN(cVData, chr(225), "á" )
 
   
 
   
return(cVData)

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

Re: Copy File Name

Postby Natter » Fri Jan 21, 2022 10:41 am

Does not fit - returns the file name with "?"
I have a lot of files on the network with this problem, so I wrote a utility to rename these files via CMD
Natter
 
Posts: 1215
Joined: Mon May 14, 2007 9:49 am

Re: Copy File Name

Postby Otto » Fri Jan 21, 2022 11:02 am

Natter, this is an example.

You have to check your ASCII values and then substitute.
// for I := 1 to len(cVData)
// ? ( cVData + CRLF + substr(cVData,I,1) + " # "+ str( ASC ( substr(cVData,I,1)) ))
// next


cVData := STRTRAN( cVData, chr( your value ), "your character" )

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

Re: Copy File Name

Postby Jimmy » Fri Jan 21, 2022 2:06 pm

hi,

> I made an empty file
sorry i have "oversee" that Size is 0

now i have try to "copy" it with ShFileOperation() Function and got Error that Target file can not create/found ...

Question : did you get File as Attachment :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Copy File Name

Postby karinha » Fri Jan 21, 2022 3:01 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7808
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Copy File Name

Postby Antonio Linares » Fri Jan 21, 2022 4:21 pm

Natter,

I get Пресненский.pdf (name of the file, though it has zero bytes) here

What parameters are you providing to Directory() ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 99 guests