Date: 02-16-2022
Return to Index
created by gbSnippets
'PowerBASIC PathName$ functions provides a way to extract the
'various parts of a full pathname.
'Primary Code:
Local f$, result$
f$ = "c:\windows\myfile.txt"
result$ = PathName$(Full, f$) 'full path c:\windows\myfile.txt
result$ = PathName$(PATH, f$) 'path only c:\windows\ ... will have the ending \
result$ = PathName$(Name, f$) 'file name only myfile ... without the extension
result$ = PathName$(EXTN, f$) 'extension only .txt ... with the period
result$ = PathName$(NAMEX, f$) 'file name + extensions myfile.txt
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Push", 50,10,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = 100 AND CB.Ctlmsg = %BN_Clicked Then
Local f$, result$
f$ = "c:\windows\myfile.txt"
result$ = PathName$(Full, f$) 'full path c:\windows\myfile.txt
result$ = result$ + $crlf + $crlf + PathName$(PATH, f$) 'path only c:\windows\ ... will have the ending \
result$ = result$ + $crlf + $crlf + PathName$(Name, f$) 'file name only myfile ... without the extension
result$ = result$ + $crlf + $crlf + PathName$(EXTN, f$) 'extension only .txt ... with the period
result$ = result$ + $crlf + $crlf + PathName$(NAMEX, f$) 'file name + extensions myfile.txt
MsgBox result$
End If
End Function
'gbs_00147
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm