strange behavior in putfile()

41 views
Skip to first unread message

C.J. Koot

unread,
Jun 4, 2025, 5:33:03 AM6/4/25
to Harbour Minigui
Hello group,

I have some strange behavior in the putfile() function and can't see what goes wrong. Here is a part of my code:

lExcel := .T.    && Ihave checked earlier that there is excel available on the computer
cIniBestand := 'beplantingslijst voor Rene Koot'
cSaveBestand := 'plantlijst'
SELECT plantlijst


IF lExcel
cBestand := ALLTRIM(PutFile( { { 'Microsoft Excel-werkmap (*.' + cExcelExt + ')','*.' + cExcelExt + ''}, { 'Tekstbestand (*.txt)', '*.txt'}, {'Database (*.dbf)', '*.dbf' } }, 'Sla selectie op als:', cDocument, .T., cIniBestand ))
ELSE
cBestand := ALLTRIM(PutFile( { { 'Tekstbestand (*.txt)', '*.txt'}, {'Database (*.dbf)', '*.dbf' } }, 'Sla selectie op als:', cDocument, .T., cIniBestand ))
ENDIF

IF !EMPTY(cBestand)
cExtBestand := UPPER(ALLTRIM(SUBSTR(cBestand,RAT('.',cBestand)+1)))
IF cExtBestand == 'TXT'
SaveToTxt(cSaveBestand, cBestand)
ELSEIF cExtBestand == 'XLS' .OR. cExtBestand == 'XLSX'
IF lEtiket
IF nWindow == 3
RKPK_SelectExportFields()
ENDIF
ENDIF
SaveToXls(cSaveBestand, cBestand)

ELSEIF cExtBestand == 'DBF'
SaveToDbf(cSaveBestand, cBestand)
ENDIF
ENDIF

When I don't change the name of the file in the putfile function everything works well, but if I type another name, the extention is not checked OK.

Hope someone has an solution.

Regards,

René Koot

Grigory Filatov

unread,
Jun 4, 2025, 7:07:07 AM6/4/25
to Harbour Minigui
Hello Rene,

Thanks for your request!

I confirm a strange behavior when you type only one symbol as a filename in the putfile() function.

I recommend using the following function to extract the file extension:

FUNCTION cFileExt( cPathMask )

   LOCAL cExt

   hb_FNameSplit( cPathMask, , , @cExt )

RETURN Upper( SubStr( cExt, 2 ) )

It works fine here.

Regards,
Grigory
среда, 4 июня 2025 г. в 11:33:03 UTC+2, plke...@gmail.com:

C.J. Koot

unread,
Jun 4, 2025, 7:35:26 AM6/4/25
to minigu...@googlegroups.com

Hello Grgory,

Thanks again for the quick reply. Your solution works perfect.


Kind regards,

René Koot

Op 04-06-2025 om 13:07 schreef Grigory Filatov:
--
Visit our website on https://www.hmgextended.com/ or https://www.hmgextended.org/
---
You received this message because you are subscribed to the Google Groups "Harbour Minigui" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minigui-foru...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/minigui-forum/4319e6ef-efab-48a0-8782-96baad10c9fen%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages