;; VLDCL-PowerShellCore
;; Core function to run PowerShell(PS) codes and get return value from internal bridge TXT file
;; input 1 = dat - PS codes string list
;; output = content from internal bridge txt file
(Defun VLDCL
-PowerShellCore
(dat
/ BAT EXE FNN RTN TXT VLO
) "SpecialFolders"
)
"MyDocuments"
)
"\\VLDCL."
)
)
)
"\nCD "
"\npowershell .\\VLDCL.PS1"
)
fnn
)
)
) ; Read file content into return list
) ; Delete temp
)
;; VLDCL-PowerShellSelectMultipleFiles
;; Call PowerShell(PS) dialog to select multiple files.
;; Note: Some anti-virus program may attempt to stop calling PowerShell PS1 file and BAT file, please allow them to run
;; input 1 = ttl - Dialog title text, nil="VLDCL-PowerShellSelectMultipleFiles"
;; input 2 = dir - Starting folder to select files, nil=DWGPrefix
;; input 3 = filter - File type filter, predefined "DWG" "TXT" "DOC", *.* for all files will be added automatically
;; if this is not string or nil, will display help info
;; output = list of selected files
;; Sample calling:
;; (VLDCL-PowerShellSelectMultipleFiles "Select DWG files" nil nil)
;; (VLDCL-PowerShellSelectMultipleFiles nil nil 5) will display help
(Defun VLDCL
-PowerShellSelectMultipleFiles
(ttl dir filter
/ RTN
) (or ttl
(setq ttl
"VLDCL-PowerShellSelectMultipleFiles")) (or filter
(setq filter
"dwg")) "Drawing files (*.dwg)|*.dwg"
)
"Drawing files (*.dxf)|*.dxf"
)
"Text files (*.txt)|*.txt"
)
"Microsoft Word files (*.doc;*.docx)|*.doc;*.docx"
)
(strcat filter
" files(*." filter
")|*." filter
) )
;; Can add more if needed
(t filter)
)
(setq filter
(strcat filter
"|All files (*.*)|*.*")) )
rtn (VLDCL-PowerShellCore
"Add-Type -AssemblyName System.Windows.Forms"
"$form = New-Object System.Windows.Forms.OpenFileDialog"
(strcat "$form.InitialDirectory = " )
)
"$form.MultiSelect = $true"
"$form.ShowHelp = $true"
"$form.ShowDialog() > $null"
"If($form.FileNames -like \042*\\*\042){$RTN = $form.Filenames}"
"else {$RTN = \042.Cancel\042}"
"$RTN | Out-File -encoding oem -FilePath .\\VLDCL.TXT"
)
)
)
(if (/= (car rtn
) ".Cancel") rtn
)
)
(t
"Function Call"
"\n(VLDCL-PowerShellSelectMultipleFiles Title InitDir FileTypeFilter)\n"
"\nPlease allow VLDCL.BAT and PowerShell to run if anti-virus program"
"\nis attempting to stop them from executing\n\n"
"\nPredefined FileTypeFilter:"
"\nDWG=Drawing files (*.dwg)|*.dwg"
"\nTXT=Text files (*.txt)|*.txt"
"\nDOC=Microsoft Word files (*.doc;*.docx)|*.doc;*.docx\n"
"\nSample of Format for file type filter:"
"\nImage files (*.jpg;*.bmp)|*.jpg;*.bmp"
"\nAdobe PDF files (*.pdf)|*.pdf")
)
)
)
)