|
Ein Programm in der Programmiersprache | A program in the programming language | |||
Power Basic 10 for Windows | ||||
zur Erzeugung eines Dateiauswahlfensters
|
for generation of a file-open-select-window
| |||
This is: Power BASIC | ||||
| ||||
Die File-Open-Select-Funktion is eingerichtet für Mehrfachauswahl von Dateien und dafür ist einiger Code notwendig, um es verwendbar zu machen für den Benutzer.
|
The file-open-select-function is made appropriate for multifile-select and for this some code is added to make the output useful for the user.
| |||
Das Programm ist getestet vor der Publikation, aber es kann keine Garantie gegeben werden, dass es fehlerfrei ist | The program ist tested before publication, but there can be given no guarantee, that it is free of errors | |||
30. Sept. 2012 | Sept 30th 2012 |
#COMPILE EXE #DIM ALL FUNCTION PBMAIN () AS LONG ' SelectedFileSpec = Path & FileName DIM SelectedFileSpec AS STRING, sTmp AS STRING, i AS WORD sTmp = FileOpenSelect("c:\Users\..\Documents\..") IF sTmp = "" THEN MSGBOX "no file selected": EXIT FUNCTION FOR i = 2 TO PARSECOUNT(sTmp,CHR$(0)) SelectedFileSpec = PARSE$(sTmp,CHR$(0),1) & PARSE$(sTmp,CHR$(0),i) CALL Program(SelectedFileSpec) ' Process Program for selected file NEXT END FUNCTION FUNCTION FileOpenSelect(StartFolder AS STRING) AS STRING ' DISPLAY OPENFILE [hParent], [xpos&], [ypos&], title$, folder$, filter$, _ ' start$, defextn$, flags& TO filevar$ [,countvar&] ' DESKTOP GET SIZE TO ncWidth&, ncHeight& DIM countvar&, filevar$, start$, sTmp AS STRING, i AS WORD DISPLAY OPENFILE %HWND_DESKTOP, 300, 200, _ "FileOpenSelect", _ ' Title StartFolder , _ ' starting folder CHR$("BASIC", 0, "*.BAS;*.INC;*.DAT;*.HTA;*.VBS", 0), _ ' filter start$, _ ' starting filename "", %OFN_ALLOWMULTISELECT + %OFN_ENABLESIZING + _ %OFN_FILEMUSTEXIST + %OFN_NOVALIDATE + _ %OFN_PATHMUSTEXIST TO filevar$, countvar& IF filevar$ = "" THEN FUNCTION = "": EXIT FUNCTION IF RIGHT$(filevar$,1) = CHR$(0) THEN _ filevar$ = LEFT$(filevar$,LEN(filevar$)-1) ' Remove terminator chr$(0) IF countvar& = 1 THEN sTmp = PATHNAME$(PATH, filevar$) ' Split Path and Filename IF RIGHT$(sTmp,1) = "\" THEN sTmp = LEFT$(sTmp, LEN(sTmp)-1) ' Remove \ filevar$ = sTmp & CHR$(0) & PATHNAME$(NAMEX, filevar$) ' Modified filevar$ END IF: sTmp = PARSE$(filevar$,CHR$(0),1) & "\" FOR i = 1 TO countvar& sTmp = sTmp & CHR$(0) & PARSE$(filevar$,CHR$(0),i+1) NEXT : FUNCTION = sTmp END FUNCTION SUB Program(AnyFileSpec AS STRING) MSGBOX AnyFileSpec END SUB | ||