QB64.org Forum

Active Forums => Programs => Topic started by: SierraKen on August 22, 2019, 06:55:44 pm

Title: Problem With Wiki Example
Post by: SierraKen on August 22, 2019, 06:55:44 pm
Has anyone used the File Open and Save Dialog from the Windows Libraries Wiki Page? I've been trying to use it with my Mini MP3 Player but it wouldn't work. So just now I tried it all by itself and it still wouldn't work, the C++ Compilation Failed it says. I looked at the log and it says this:
In file included from qbx.cpp:2171:
..\\temp\\main.txt: In function 'void QBMAIN(void*)':
..\\temp\\main.txt:7:125: error: cast from 'HWND' {aka 'HWND__*'} to 'int' loses precision [-fpermissive]
 *__LONG_HWND=(  int32  )FindWindow(NULL,(char*)(qbs_add(qbs_new_txt_len("Open and Save Dialog demo",25),func_chr( 0 )))->chr);
                                                                                                                             ^
compilation terminated due to -Wfatal-errors.

Here is the example from the Wiki Page if anyone wants to check it out. It's from here: http://www.qb64.org/wiki/Windows_Libraries
I have Windows 10 if that makes any difference.

Code: QB64: [Select]
  1. ' Dialog flag constants (use + or OR to use more than 1 flag value)
  2. CONST OFN_ALLOWMULTISELECT = &H200& '  Allows the user to select more than one file, not recommended!
  3. CONST OFN_CREATEPROMPT = &H2000& '     Prompts if a file not found should be created(GetOpenFileName only).
  4. CONST OFN_EXTENSIONDIFFERENT = &H400& 'Allows user to specify file extension other than default extension.
  5. CONST OFN_FILEMUSTEXIST = &H1000& '    Chechs File name exists(GetOpenFileName only).
  6. CONST OFN_HIDEREADONLY = &H4& '        Hides read-only checkbox(GetOpenFileName only)
  7. CONST OFN_NOCHANGEDIR = &H8& '         Restores the current directory to original value if user changed
  8. CONST OFN_NODEREFERENCELINKS = &H100000& 'Returns path and file name of selected shortcut(.LNK) file instead of file referenced.
  9. CONST OFN_NONETWORKBUTTON = &H20000& ' Hides and disables the Network button.
  10. CONST OFN_NOREADONLYRETURN = &H8000& ' Prevents selection of read-only files, or files in read-only subdirectory.
  11. CONST OFN_NOVALIDATE = &H100& '        Allows invalid file name characters.
  12. CONST OFN_OVERWRITEPROMPT = &H2& '     Prompts if file already exists(GetSaveFileName only)
  13. CONST OFN_PATHMUSTEXIST = &H800& '     Checks Path name exists (set with OFN_FILEMUSTEXIST).
  14. CONST OFN_READONLY = &H1& '            Checks read-only checkbox. Returns if checkbox is checked
  15. CONST OFN_SHAREAWARE = &H4000& '       Ignores sharing violations in networking
  16. CONST OFN_SHOWHELP = &H10& '           Shows the help button (useless!)
  17. '--------------------------------------------------------------------------------------------
  18.  
  19. DEFINT A-Z
  20. TYPE FILEDIALOGTYPE
  21.     lStructSize AS LONG '        For the DLL call
  22.     hwndOwner AS LONG '          Dialog will hide behind window when not set correctly
  23.     hInstance AS LONG '          Handle to a module that contains a dialog box template.
  24.     lpstrFilter AS _OFFSET '     Pointer of the string of file filters
  25.     lpstrCustFilter AS _OFFSET
  26.     nMaxCustFilter AS LONG
  27.     nFilterIndex AS LONG '       One based starting filter index to use when dialog is called
  28.     lpstrFile AS _OFFSET '       String full of 0's for the selected file name
  29.     nMaxFile AS LONG '           Maximum length of the string stuffed with 0's minus 1
  30.     lpstrFileTitle AS _OFFSET '  Same as lpstrFile
  31.     nMaxFileTitle AS LONG '      Same as nMaxFile
  32.     lpstrInitialDir AS _OFFSET ' Starting directory
  33.     lpstrTitle AS _OFFSET '      Dialog title
  34.     flags AS LONG '              Dialog flags
  35.     nFileOffset AS INTEGER '     Zero-based offset from path beginning to file name string pointed to by lpstrFile
  36.     nFileExtension AS INTEGER '  Zero-based offset from path beginning to file extension string pointed to by lpstrFile.
  37.     lpstrDefExt AS _OFFSET '     Default/selected file extension
  38.     lCustData AS LONG
  39.     lpfnHook AS LONG
  40.     lpTemplateName AS _OFFSET
  41.  
  42. DECLARE DYNAMIC LIBRARY "comdlg32" ' Library declarations using _OFFSET types
  43.     FUNCTION GetOpenFileNameA& (DIALOGPARAMS AS FILEDIALOGTYPE) ' The Open file dialog
  44.     FUNCTION GetSaveFileNameA& (DIALOGPARAMS AS FILEDIALOGTYPE) ' The Save file dialog
  45.  
  46.     FUNCTION FindWindow& (BYVAL ClassName AS _OFFSET, WindowName$) ' To get hWnd handle
  47.  
  48. _TITLE "FileOpen Common Dialog demo" 'set Title of program
  49. hWnd& = FindWindow(0, "Open and Save Dialog demo" + CHR$(0)) 'get window handle using _TITLE string
  50.  
  51. ' Do the Open File dialog call!
  52. Filter$ = "Batch files (*.bat)|*.BAT|JPEG images (*.jpg)|*.JPG|All files (*.*)|*.*"
  53. Flags& = OFN_FILEMUSTEXIST + OFN_NOCHANGEDIR + OFN_READONLY '    add flag constants here
  54. OFile$ = GetOpenFileName$("YEAH! Common Dialogs in QB64!!!", ".\", Filter$, 1, Flags&, hWnd&)
  55.  
  56. IF OFile$ = "" THEN ' Display Open dialog results
  57.     PRINT "Shame on you! You didn't pick any file..."
  58.     PRINT "You picked this file: "
  59.     PRINT OFile$
  60.     IF (Flags& AND OFN_READONLY) THEN PRINT "Read-only checkbox checked." 'read-only value in return
  61.  
  62. _DELAY 5 ' Do the Save File dialog call!
  63. Filter$ = "Basic files (*.bas)|*.BAS|All files (*.*)|*.*"
  64. Flags& = OFN_OVERWRITEPROMPT + OFN_NOCHANGEDIR '   add flag constants here
  65. SFile$ = GetSaveFileName$("Save will not create a file!!!", ".\", Filter$, 1, Flags&, hWnd&)
  66.  
  67. IF SFile$ = "" THEN ' Display Save dialog results
  68.     PRINT "You didn't save the file..."
  69.     PRINT "You saved this file: "
  70.     PRINT SFile$
  71.  
  72. FUNCTION GetOpenFileName$ (Title$, InitialDir$, Filter$, FilterIndex, Flags&, hWnd&)
  73.     '  Title$      - The dialog title.
  74.     '  InitialDir$ - If this left blank, it will use the directory where the last opened file is
  75.     '  located. Specify ".\" if you want to always use the current directory.
  76.     '  Filter$     - File filters separated by pipes (|) in the same format as using VB6 common dialogs.
  77.     '  FilterIndex - The initial file filter to use. Will be altered by user during the call.
  78.     '  Flags&      - Dialog flags. Will be altered by the user during the call.
  79.     '  hWnd&       - Your program's window handle that should be aquired by the FindWindow function.
  80.     '
  81.     ' Returns: Blank when cancel is clicked otherwise, the file name selected by the user.
  82.     ' FilterIndex and Flags& will be changed depending on the user's selections.
  83.  
  84.     DIM OpenCall AS FILEDIALOGTYPE ' Needed for dialog call
  85.  
  86.     fFilter$ = Filter$
  87.     FOR R = 1 TO LEN(fFilter$) ' Replace the pipes with character zero
  88.         IF MID$(fFilter$, R, 1) = "|" THEN MID$(fFilter$, R, 1) = CHR$(0)
  89.     NEXT R
  90.     fFilter$ = fFilter$ + CHR$(0)
  91.  
  92.     lpstrFile$ = STRING$(2048, 0) ' For the returned file name
  93.     lpstrDefExt$ = STRING$(10, 0) ' Extension will not be added when this is not specified
  94.     OpenCall.lStructSize = LEN(OpenCall)
  95.     OpenCall.hwndOwner = hWnd&
  96.     OpenCall.lpstrFilter = _OFFSET(fFilter$)
  97.     OpenCall.nFilterIndex = FilterIndex
  98.     OpenCall.lpstrFile = _OFFSET(lpstrFile$)
  99.     OpenCall.nMaxFile = LEN(lpstrFile$) - 1
  100.     OpenCall.lpstrFileTitle = OpenCall.lpstrFile
  101.     OpenCall.nMaxFileTitle = OpenCall.nMaxFile
  102.     OpenCall.lpstrInitialDir = _OFFSET(InitialDir$)
  103.     OpenCall.lpstrTitle = _OFFSET(Title$)
  104.     OpenCall.lpstrDefExt = _OFFSET(lpstrDefExt$)
  105.     OpenCall.flags = Flags&
  106.  
  107.     Result = GetOpenFileNameA&(OpenCall) '            Do Open File dialog call!
  108.  
  109.     IF Result THEN ' Trim the remaining zeros
  110.         GetOpenFileName$ = LEFT$(lpstrFile$, INSTR(lpstrFile$, CHR$(0)) - 1)
  111.         Flags& = OpenCall.flags
  112.         FilterIndex = OpenCall.nFilterIndex
  113.     END IF
  114.  
  115.  
  116. FUNCTION GetSaveFileName$ (Title$, InitialDir$, Filter$, FilterIndex, Flags&, hWnd&)
  117.     '  Title$      - The dialog title.
  118.     '  InitialDir$ - If this left blank, it will use the directory where the last opened file is
  119.     '     located. Specify ".\" if you want to always use the current directory.
  120.     '  Filter$     - File filters separated by pipes (|) in the same format as VB6 common dialogs.
  121.     '  FilterIndex - The initial file filter to use. Will be altered by user during the call.
  122.     '  Flags&      - Dialog flags. Will be altered by the user during the call.
  123.     '  hWnd&       - Your program's window handle that should be aquired by the FindWindow function.
  124.  
  125.     ' Returns: Blank when cancel is clicked otherwise, the file name entered by the user.
  126.     ' FilterIndex and Flags& will be changed depending on the user's selections.
  127.  
  128.     DIM SaveCall AS FILEDIALOGTYPE ' Needed for dialog call
  129.  
  130.     fFilter$ = Filter$
  131.     FOR R = 1 TO LEN(fFilter$) ' Replace the pipes with zeros
  132.         IF MID$(fFilter$, R, 1) = "|" THEN MID$(fFilter$, R, 1) = CHR$(0)
  133.     NEXT R
  134.     fFilter$ = fFilter$ + CHR$(0)
  135.  
  136.     lpstrFile$ = STRING$(2048, 0) ' For the returned file name
  137.     lpstrDefExt$ = STRING$(10, 0) ' Extension will not be added when this is not specified
  138.     SaveCall.lStructSize = LEN(SaveCall)
  139.     SaveCall.hwndOwner = hWnd&
  140.     SaveCall.lpstrFilter = _OFFSET(fFilter$)
  141.     SaveCall.nFilterIndex = FilterIndex
  142.     SaveCall.lpstrFile = _OFFSET(lpstrFile$)
  143.     SaveCall.nMaxFile = LEN(lpstrFile$) - 1
  144.     SaveCall.lpstrFileTitle = SaveCall.lpstrFile
  145.     SaveCall.nMaxFileTitle = SaveCall.nMaxFile
  146.     SaveCall.lpstrInitialDir = _OFFSET(InitialDir$)
  147.     SaveCall.lpstrTitle = _OFFSET(Title$)
  148.     SaveCall.lpstrDefExt = _OFFSET(lpstrDefExt$)
  149.     SaveCall.flags = Flags&
  150.  
  151.     Result& = GetSaveFileNameA&(SaveCall) ' Do dialog call!
  152.  
  153.     IF Result& THEN ' Trim the remaining zeros
  154.         GetSaveFileName$ = LEFT$(lpstrFile$, INSTR(lpstrFile$, CHR$(0)) - 1)
  155.         Flags& = SaveCall.flags
  156.         FilterIndex = SaveCall.nFilterIndex
  157.     END IF
  158.  
  159.  




Title: Re: Problem With Wiki Example
Post by: bplus on August 22, 2019, 07:34:36 pm
Hi Ken,

Never used it, too complicated. Are you trying to get a list of files in a directory to select from?
Title: Re: Problem With Wiki Example
Post by: SierraKen on August 22, 2019, 07:46:59 pm
Yes, I found the string to use to get it from. Half of that code I don't need since it's for Saving. It just uses the TITLE command to find both windows (program and FILE window). I don't know probably 98% of all what is there, but I thought maybe someone has used it before. Would also be nice to know if I can use this, or another known code, to select a Windows Folder (just the folder) and not a file, to change folders.
Title: Re: Problem With Wiki Example
Post by: bplus on August 22, 2019, 08:08:32 pm
Anyone remember the DIR command line for just Folders / Directories?
Title: Re: Problem With Wiki Example
Post by: SMcNeill on August 22, 2019, 08:40:25 pm
I dunno what the heck is going on with the wiki example, but it's somehow gotten all goofy. It *used* to work, but I see several very obvious issues as to why it currently isn't:

_TITLE "FileOpen Common Dialog demo"                           'set Title of program
hWnd& = FindWindow(0, "Open and Save Dialog demo" + CHR$(0)) 'get window handle using _TITLE string

Get the window handle, using the _TITLE string...  Sounds lovely!

But WTH doesn't the string and the _TITLE text match???

To correct this issue, you need to make the two strings match:

_TITLE "FileOpen Common Dialog demo"                           'set Title of program
hWnd& = FindWindow(0, "FileOpen Common Dialog demo" + CHR$(0)) 'get window handle using _TITLE string



At this point, I believe, the example should compile and run for you -- as long as you're running it with the 32-bit version of QB64.

When the sample was added, all QB64 offered was a 32-bit version, so the code is only tailored for 32-bit versions of QB64. 

64-bit versions of QB64 aren't going to compile, at all, for this one line in particular:

DECLARE LIBRARY
    FUNCTION FindWindow& (BYVAL ClassName AS _OFFSET, WindowName$) ' To get hWnd handle
END DECLARE

You can't take a 64-bit OFFSET and store it in a 32-bit value!  The compiler simply *won't* allow it.  This is a 100% crash, even before compilation.  You can change it to the following, and get it to compile for you, at least:

DECLARE LIBRARY
    FUNCTION FindWindow&& (BYVAL ClassName AS _OFFSET, WindowName$) ' To get hWnd handle
END DECLARE



BUT, it still won't work as intended...  The next issue is probably:

DECLARE DYNAMIC LIBRARY "comdlg32" ' Library declarations using _OFFSET types
    FUNCTION GetOpenFileNameA& (DIALOGPARAMS AS FILEDIALOGTYPE) ' The Open file dialog
    FUNCTION GetSaveFileNameA& (DIALOGPARAMS AS FILEDIALOGTYPE) ' The Save file dialog
END DECLARE

It looks like we're trying to call a 32-bit windows library, when we probably need to actually call a 64-bit version.  I'd imagine the offsets are off, and the program simply is returning a fail code to us when we attempt to call those functions.  I'm not 100% certain this is the issue, as I quit digging at this point, but I've seen enough to make me say, "As the example currently exists, it's:  1) glitched with the _TITLE text and 2) only going to work for 32-bit QB64, without some serious tweaking/overhauling. 

Title: Re: Problem With Wiki Example
Post by: bplus on August 22, 2019, 08:50:35 pm
Tiny Navigator almost ready! :)
Title: Re: Problem With Wiki Example
Post by: SMcNeill on August 22, 2019, 09:03:02 pm
Doing a little quick research on the issue, it seems the problem isn't with "comdlg32"; it's with how the file structure is packed between 32-bit and 64-bit versions.  The recommended solution is to compile with the -Zp switch with Visual Studio -- https://docs.microsoft.com/en-us/cpp/build/reference/zp-struct-member-alignment?view=vs-2019 -- but it does us absolutely zero good, as we compile with mingw...  There's probably a suitable switch which we can pop into the compile makeline, but I have no idea what it might be; now what else it might break if we tried to enable it by default...

Title: Re: Problem With Wiki Example
Post by: SierraKen on August 22, 2019, 09:03:17 pm
Wow lots of problems, thank you SMcNeill, that's more than I needed. I run 64 bit and I did try your #1, keeping the TITLE and string the same earlier, but it still wouldn't work. Probably from being 64 bit. I'll just give up on this one.

B+, in my Mini MP3 Player you can change the directories by typing in any one you want, the DOS way using CHDIR, but I was just wondering if there was an easier Windows way using the Mouse. Oh well, thanks for your time guys.
Title: Re: Problem With Wiki Example
Post by: bplus on August 22, 2019, 09:12:51 pm
Wow lots of problems, thank you SMcNeill, that's more than I needed. I run 64 bit and I did try your #1, keeping the TITLE and string the same earlier, but it still wouldn't work. Probably from being 64 bit. I'll just give up on this one.

B+, in my Mini MP3 Player you can change the directories by typing in any one you want, the DOS way using CHDIR, but I was just wondering if there was an easier Windows way using the Mouse. Oh well, thanks for your time guys.

Yes, for Windows you can, I am putting it together now, something I have been meaning to do for long time, thanks for reminder and sharing common need. I found the command line switch for directories only and the file output from pipe needed a little pruning, do you remember that ".." means go up in directories? ie CD ..
Title: Re: Problem With Wiki Example
Post by: SMcNeill on August 22, 2019, 09:28:16 pm
Give this little program a quick try:

Code: QB64: [Select]
  1.     FUNCTION FILE_load_dir& ALIAS load_dir (s AS STRING)
  2.     FUNCTION FILE_has_next_entry& ALIAS has_next_entry ()
  3.     SUB FILE_close_dir ALIAS close_dir ()
  4.     SUB FILE_get_next_entry ALIAS get_next_entry (s AS STRING, flags AS LONG, file_size AS LONG)
  5.     SUB FILE_get_current_dir ALIAS get_current_dir (s AS STRING)
  6.     FUNCTION FILE_current_dir_length& ALIAS current_dir_length ()
  7.  
  8. SCREEN _NEWIMAGE(1024, 720, 32)
  9.  
  10. a$ = SelectFile$("*.*", 100, 100)
  11. PRINT "You selected:"; a$
  12.  
  13.  
  14. FUNCTION SelectFile$ (search$, x AS INTEGER, y AS INTEGER)
  15.     'save some old values
  16.     LoadFile_DC = _DEFAULTCOLOR: LoadFile_BG = _BACKGROUNDCOLOR
  17.     LoadFile_s = _SOURCE: LoadFile_d = _DEST
  18.     f = _FONT: _FONT 16
  19.     'some variables
  20.  
  21.     LoadFile_BoxColor = &HFFAAAAFF
  22.     LoadFile_FolderColor = &HFFFFFF00
  23.     LoadFile_FileColor = &HFFFFFFFF
  24.     IF INSTR(_OS$, "[WINDOWS]") THEN LoadFile_Slash$ = "\" ELSE LoadFile_Slash$ = "/"
  25.     LoadFile_Dir$ = SPACE$(FILE_current_dir_length)
  26.     FILE_get_current_dir LoadFile_Dir$
  27.     LoadFile_Dir$ = LoadFile_Dir$ + LoadFile_Slash$
  28.     'LoadFile_Dir$ = "." + LoadFile_Slash$
  29.     LoadFile_w = 639: LoadFile_h = 479
  30.     REDIM LoadFile_Label(0) AS STRING: LoadFile_Label(0) = "DIR"
  31.     REDIM LoadFile_DirList(-1 TO 9, -1 TO 9999) AS STRING
  32.     LoadFile_last = 1
  33.     FolderDeep = 1
  34.  
  35.     'some error checking
  36.     IF search$ = "" THEN EXIT SUB 'We can't search for nothing!
  37.  
  38.     'Copy background
  39.     PCOPY 0, 1
  40.     'set workscreen
  41.     LoadFile_ws = _NEWIMAGE(640, 480, 32)
  42.  
  43.     'Count our filetypes to display
  44.     LoadFile_TypeCount = 0
  45.     DO
  46.         LoadFile_TypeCount = LoadFile_TypeCount + 1
  47.         LoadFile_l = INSTR(LoadFile_l + 1, search$, ";") ' look for ; to denote more files
  48.         REDIM _PRESERVE LoadFile_Label(LoadFile_TypeCount) AS STRING
  49.         IF LoadFile_l > 0 THEN LoadFile_Label(LoadFile_TypeCount) = MID$(search$, LoadFile_last + 1, LoadFile_l - LoadFile_last - 1) ELSE LoadFile_Label(LoadFile_TypeCount) = MID$(search$, LoadFile_last + 1, LEN(search$) - LoadFile_last)
  50.         LoadFile_last = LoadFile_l + 1
  51.     LOOP UNTIL LoadFile_l = 0
  52.     LoadFile_l = 640 / (LoadFile_TypeCount + 1)
  53.     REDIM LoadFile_start(LoadFile_TypeCount), LoadFile_previous(LoadFile_TypeCount), LoadFile_more(LoadFile_TypeCount), LoadFile_Count(LoadFile_TypeCount)
  54.     FOR i = 0 TO LoadFile_TypeCount: LoadFile_start(i) = 1: NEXT
  55.  
  56.     _SOURCE LoadFile_ws: _DEST LoadFile_ws
  57.     DO
  58.         _LIMIT 30
  59.         FOR i = 0 TO LoadFile_TypeCount
  60.             LoadFile_Count(i) = 0
  61.             FOR j = 0 TO 9999
  62.                 LoadFile_DirList(i, j) = ""
  63.             NEXT
  64.         NEXT
  65.         'Generate our updated directory listings.
  66.  
  67.         IF FILE_load_dir&(LoadFile_Dir$ + CHR$(0)) THEN
  68.             DO
  69.                 LoadFile_length = FILE_has_next_entry 'Get length of next entry
  70.                 IF LoadFile_length > -1 THEN 'If we have a next entry
  71.                     LoadFile_nam$ = SPACE$(LoadFile_length) 'Set the size of our string
  72.                     FILE_get_next_entry LoadFile_nam$, LoadFile_flags, LoadFile_file_size 'Get the file's name, size, and 'flags'
  73.                     'Check if it's a file or a directory
  74.  
  75.                     IF _DIREXISTS(LoadFile_Dir$ + LoadFile_nam$) THEN
  76.                         IF LoadFile_nam$ <> "." THEN
  77.                             LoadFile_Count(0) = LoadFile_Count(0) + 1
  78.                             LoadFile_DirList(0, LoadFile_Count(0)) = LoadFile_nam$
  79.                         END IF
  80.                     ELSE 'We have a file
  81.                         FOR i = 1 TO LoadFile_TypeCount
  82.                             LoadFile_ext$ = RIGHT$(LoadFile_nam$, LEN(LoadFile_Label(i)))
  83.                             IF UCASE$(LoadFile_ext$) = UCASE$(LoadFile_Label(i)) THEN
  84.                                 LoadFile_Count(i) = LoadFile_Count(i) + 1
  85.                                 LoadFile_DirList(i, LoadFile_Count(i)) = LEFT$(LoadFile_nam$, LEN(LoadFile_nam$) - LEN(LoadFile_Label(i)))
  86.                                 EXIT FOR
  87.                             ELSEIF LoadFile_Label(i) = ".*" THEN
  88.                                 LoadFile_Count(i) = LoadFile_Count(i) + 1
  89.                                 LoadFile_DirList(i, LoadFile_Count(i)) = LoadFile_nam$
  90.                             END IF
  91.                         NEXT
  92.                     END IF
  93.                 END IF
  94.             LOOP UNTIL LoadFile_length = -1
  95.             FILE_close_dir
  96.         END IF
  97.  
  98.         updatelist:
  99.  
  100.  
  101.         CLS , &HFF005050 'Draw a nice display box
  102.         COLOR , 0
  103.         LINE (0, 0)-(LoadFile_w, LoadFile_h + 5 - 2 * 16), LoadFile_BoxColor, B
  104.         LINE (1, 1)-(LoadFile_w - 1, LoadFile_h + 6 - 2 * 16), LoadFile_BoxColor, B
  105.         LINE (0, 0)-(LoadFile_w, LoadFile_h), LoadFile_BoxColor, B
  106.         LINE (1, 1)-(LoadFile_w - 1, LoadFile_h - 1), LoadFile_BoxColor, B
  107.  
  108.         LINE (0, 16 + 3)-(LoadFile_w, 16 + 3), LoadFile_BoxColor
  109.         LINE (0, 16 + 4)-(LoadFile_w, 16 + 4), LoadFile_BoxColor
  110.         FOR i = 0 TO LoadFile_TypeCount
  111.             _PRINTSTRING (i * LoadFile_l + (LoadFile_l - 8 * LEN(LoadFile_Label(i))) / 2, 2), LoadFile_Label(i)
  112.             LINE (i * LoadFile_l, 0)-(i * LoadFile_l, LoadFile_h + 5 - 2 * 16), LoadFile_BoxColor
  113.         NEXT
  114.  
  115.         LINE (627, 2)-(637, 18), &HFFFF0000, BF
  116.         LINE (626, 2)-(637, 18), &HFF000000, B
  117.  
  118.         _PRINTSTRING (628, 2), "X"
  119.         IF selection > 0 THEN
  120.             IF LoadFile_Label(row) <> ".*" AND LoadFile_Label(row) <> "DIR" THEN temp$ = LoadFile_DirList(row, selection) + LoadFile_Label(row) ELSE temp$ = LoadFile_DirList(row, selection)
  121.             IF LoadFile_DirList(row, selection) = "" THEN temp$ = ""
  122.             selection = 0
  123.         END IF
  124.         _PRINTSTRING (10, 28 * 16 + 7), LoadFile_Dir$
  125.         _PRINTSTRING (630 - LEN(temp$) * 8, 28 * 16 + 7), temp$
  126.         IF temp$ = "" THEN oldselection = 0
  127.         IF oldselection > 0 THEN LINE (row * LoadFile_l, (oldselection + 1) * 16 + 5)-((row + 1) * LoadFile_l, (oldselection + 2) * 16 + 5), &HAAAAA000, BF
  128.  
  129.         FOR i = 0 TO UBOUND(LoadFile_label)
  130.             IF i = 0 THEN COLOR LoadFile_FolderColor ELSE COLOR LoadFile_FileColor
  131.             counter = 0
  132.             FOR j = LoadFile_start(i) TO LoadFile_start(i) + 24
  133.                 counter = counter + 1
  134.                 IF LoadFile_DirList(i, j) = "" THEN EXIT FOR
  135.                 _PRINTSTRING (i * LoadFile_l + 5, (counter + 1) * 16 + 7), LEFT$(LoadFile_DirList(i, j), LoadFile_l / 8 - 2)
  136.             NEXT
  137.             IF j = LoadFile_start(i) + 25 THEN LoadFile_more(i) = -1 ELSE LoadFile_more(i) = 0
  138.             IF LoadFile_start(i) > 1 THEN LoadFile_previous(i) = -1 ELSE LoadFile_previous(i) = 0
  139.             IF LoadFile_more(i) THEN
  140.                 LINE (i * LoadFile_l + 2, 27 * 16 + 5)-((i + 1) * LoadFile_l - 3, 28 * 16 + 3), &HFFFF0000, BF
  141.                 LINE (i * LoadFile_l + 2, 27 * 16 + 5)-((i + 1) * LoadFile_l - 3, 28 * 16 + 3), BoxColor, B
  142.                 COLOR &HFFFFFF00: _PRINTSTRING (i * LoadFile_l + (LoadFile_l - 8 * 11) / 2, 27 * 16 + 5), "SCROLL DOWN"
  143.                 COLOR LoadFile_FileColor
  144.             END IF
  145.             IF LoadFile_previous(i) THEN
  146.                 LINE (i * LoadFile_l + 2, 16 + 5)-((i + 1) * LoadFile_l - 3, 2 * 16 + 3), &HFFFF0000, BF
  147.                 LINE (i * LoadFile_l + 2, 16 + 5)-((i + 1) * LoadFile_l - 3, 2 * 16 + 3), BoxColor, B
  148.                 COLOR &HFFFFFF00: _PRINTSTRING (i * LoadFile_l + (LoadFile_l - 8 * 9) / 2, 16 + 5), "SCROLL UP"
  149.                 COLOR LoadFile_FileColor
  150.             END IF
  151.         NEXT
  152.  
  153.         _PUTIMAGE (0 + x, 0 + y)-(640 + x, 480 + y), LoadFile_ws, 0
  154.         _DISPLAY
  155.  
  156.         change = 0
  157.         DO
  158.             _LIMIT 30
  159.             LoadFile_LMB = 0 'This sets the left mouse button as unacceptable.
  160.             a = _KEYHIT
  161.             SELECT CASE a
  162.                 CASE 8 'backspace
  163.                     temp$ = LEFT$(temp$, LEN(temp$) - 1)
  164.                     change = -1
  165.                 CASE 13 'enter
  166.                     DO: LOOP UNTIL INKEY$ = "" 'Clear the keyboard buffer so it doesn't affect the main program.
  167.                     temp$ = LoadFile_Dir$ + temp$
  168.                     COLOR LoadFile_DC, LoadFile_BG: _SOURCE LoadFile_s: _DEST LoadFile_d: PCOPY 1, 0: _DISPLAY: SelectFile$ = temp$ 'Restore our old settings
  169.                     _FONT f
  170.                     EXIT SUB 'And leave
  171.                 CASE 27 'If ESC is pressed then...
  172.                     DO: LOOP UNTIL INKEY$ = "" 'Clear the keyboard buffer so it doesn't affect the main program.
  173.                     COLOR LoadFile_DC, LoadFile_BG: _SOURCE LoadFile_s: _DEST LoadFile_d: PCOPY 1, 0: _DISPLAY: SelectFile$ = "" 'Restore our old settings
  174.                     _FONT f
  175.                     EXIT SUB 'And leave
  176.                 CASE 32 TO 126
  177.                     temp$ = temp$ + CHR$(a)
  178.                     change = -1
  179.             END SELECT
  180.             DO
  181.                 IF _MOUSEBUTTON(1) = 0 THEN LoadFile_LMB = -1 'Only by lifting the mouse, will we count it as down
  182.                 'Note: we ignore LoadFile_LMB for the scroll bars, so we can just hold it down and scroll happily forever and ever...
  183.                 'or until we get to the limit of our file list.
  184.                 'We only check LoadFile_LMB when actually trying to select an item from our list.   No more "OOP!  I held it too long and did something I didn't want to do!"
  185.                 'Now we click once to select, click again to accept that selection.
  186.             LOOP WHILE _MOUSEINPUT
  187.             MX = _MOUSEX: MY = _MOUSEY
  188.             IF _MOUSEBUTTON(2) OR (LoadFile_LMB AND MX > 626 + x AND MX < 638 + x AND MY > 1 + y AND MY < 19 + y AND _MOUSEBUTTON(1)) THEN
  189.                 'restore those old values, and just exit.  Right mouse is an escape
  190.                 COLOR LoadFile_DC, LoadFile_BG: _SOURCE LoadFile_s: _DEST LoadFile_d: PCOPY 1, 0: _DISPLAY: SelectFile$ = ""
  191.                 _FONT f
  192.                 EXIT SUB
  193.             END IF
  194.             IF _MOUSEBUTTON(1) THEN 'Without the mouse being down, we don't need to check squat!
  195.                 'Check the 2 roLoadFile_ws for a click in the proper Y position
  196.                 IF MY >= 16 + 5 + y AND MY <= 2 * 16 + 3 + y THEN 'We're on the top row
  197.                     FOR j = 0 TO UBOUND(LoadFile_label)
  198.                         IF LoadFile_previous(j) AND MX >= j * LoadFile_l + 2 + x AND MX <= (j + 1) * LoadFile_l - 3 + x THEN
  199.                             LoadFile_start(j) = LoadFile_start(j) - 1
  200.                             change = -1: selection = 0: click = 0: temp$ = ""
  201.                             EXIT FOR
  202.                         END IF
  203.                     NEXT
  204.                 ELSEIF MY >= 27 * 16 + 5 + y AND MY <= 28 * 16 + 3 + y THEN 'We're on the bottom row
  205.                     FOR j = 0 TO UBOUND(LoadFile_label)
  206.                         IF LoadFile_more(j) AND MX >= j * LoadFile_l + 2 + x AND MX <= (j + 1) * LoadFile_l - 3 + x THEN
  207.                             LoadFile_start(j) = LoadFile_start(j) + 1
  208.                             change = -1: selection = 0: click = 0: temp$ = ""
  209.                             EXIT FOR
  210.                         END IF
  211.                     NEXT
  212.                 ELSEIF MY >= 37 + y AND MY <= 437 + y AND LoadFile_LMB THEN 'It's in a column somewhere.  Did someone click an item?!
  213.                     FOR j = 0 TO UBOUND(LoadFile_label)
  214.                         IF MX >= j * LoadFile_l + 2 + x AND MX <= (j + 1) * LoadFile_l - 3 + x THEN
  215.                             row = j
  216.                             oldselection = INT((MY - y - 37) / 16) + 1
  217.                             selection = LoadFile_start(j) + oldselection - 1
  218.                             change = -1
  219.                             click = -1
  220.                             EXIT FOR
  221.                         END IF
  222.                     NEXT
  223.                 END IF
  224.             END IF
  225.  
  226.             _DISPLAY
  227.         LOOP UNTIL change
  228.         IF click THEN 'we clicked something besides a scroll bar
  229.             IF LoadFile_Label(row) <> ".*" AND LoadFile_Label(row) <> "DIR" THEN temp1$ = LoadFile_DirList(row, selection) + LoadFile_Label(row) ELSE temp1$ = LoadFile_DirList(row, selection)
  230.             IF temp$ = temp1$ THEN
  231.                 'We picked one!
  232.                 SELECT CASE LoadFile_Label(row)
  233.                     CASE "DIR"
  234.                         IF LoadFile_DirList(row, selection) <> ".." THEN
  235.                             LoadFile_Dir$ = LoadFile_Dir$ + LoadFile_DirList(row, selection) + LoadFile_Slash$
  236.                         ELSE
  237.                             DO
  238.                                 LoadFile_Dir$ = LEFT$(LoadFile_Dir$, LEN(LoadFile_Dir$) - 1)
  239.                             LOOP UNTIL RIGHT$(LoadFile_Dir$, 1) = LoadFile_Slash$ OR LEN(LoadFile_Dir$) = 0
  240.                         END IF
  241.                         FOR i = 1 TO UBOUND(Loadfile_start)
  242.                             LoadFile_start(i) = 1
  243.                         NEXT
  244.                         selection = 0: temp$ = "": oldselection = 0
  245.                     CASE ".*": SelectFile$ = LoadFile_Dir$ + temp$: EXIT DO
  246.                     CASE ELSE: SelectFile$ = LoadFile_Dir$ + temp$: EXIT DO
  247.                 END SELECT
  248.             END IF
  249.             IF row > 0 THEN _DELAY .2: GOTO updatelist
  250.         ELSE
  251.             _DELAY .05
  252.             GOTO updatelist
  253.         END IF
  254.     LOOP
  255.     'restore those old values
  256.     COLOR LoadFile_DC, LoadFile_BG: _SOURCE LoadFile_s: _DEST LoadFile_d: PCOPY 1, 0: _DISPLAY
  257.     _FONT f
  258.  
  259. 'If you don't have a copy of direntry.h in your QB64 folder, then copy the following code into a new IDE window.
  260. 'Then remove the remarks.
  261. 'And save it as direntry.h
  262. 'direntry.h is required for this to work properly with the library files.
  263. 'I thought adding the code here would be a way to make certain that it'd be easy to recover the file
  264. 'in case something ever happened and it was accidently deleted off the drive for some reason.
  265.  
  266. '#include <dirent.h>
  267. '#include <sys/stat.h>
  268. '#include <unistd.h>
  269.  
  270. 'const int IS_DIR_FLAG = 1, IS_FILE_FLAG = 2;
  271.  
  272. 'DIR *pdir;
  273. 'struct dirent *next_entry;
  274. 'struct stat statbuf1;
  275.  
  276. 'char current_dir[FILENAME_MAX];
  277. '#ifdef QB64_WINDOWS
  278. '  #define GetCurrentDir _getcwd
  279. '#else
  280. '  #define GetCurrentDir getcwd
  281. '#endif
  282.  
  283. 'int load_dir (char * path) {
  284. '  struct dirent *pent;
  285. '  struct stat statbuf1;
  286. '//Open current directory
  287. 'pdir = opendir(path);
  288. 'if (!pdir) {
  289. 'return 0; //Didn't open
  290. '}
  291. 'return -1;
  292. '}
  293.  
  294. 'int has_next_entry () {
  295. '  next_entry = readdir(pdir);
  296. '  if (next_entry == NULL) return -1;
  297.  
  298. '  stat(next_entry->d_name, &statbuf1);
  299. '  return strlen(next_entry->d_name);
  300. '}
  301.  
  302. 'void get_next_entry (char * nam, int * flags, int * file_size) {
  303. '  strcpy(nam, next_entry->d_name);
  304. '  if (S_ISDIR(statbuf1.st_mode)) {
  305. '    *flags = IS_DIR_FLAG;
  306. '  } else {
  307. '    *flags = IS_FILE_FLAG;
  308. '  }
  309. '  *file_size = statbuf1.st_size;
  310. '  return ;
  311. '}
  312.  
  313. 'void close_dir () {
  314. '  closedir(pdir);
  315. '  pdir = NULL;
  316. '  return ;
  317. '}
  318.  
  319. 'int current_dir_length () {
  320. '  GetCurrentDir(current_dir, sizeof(current_dir));
  321. '  return strlen(current_dir);
  322. '}
  323.  
  324. 'void get_current_dir(char *dir) {
  325. '  memcpy(dir, current_dir, strlen(current_dir));
  326. '  return ;
  327. '}
  328.  

You'll need the direntry.h file in your QB64 folder when running it, so grab it from below, and see how it performs for you.  This little routine should work with all our operating systems -- Windows, Linux, and Mac -- and is something I tossed together ages ago and have shared countless times with folks.  You really won't find a much simpler file selection utility than one which tends to be:

a$ = SelectFile$("*.*", 100, 100)
PRINT "You selected:"; a$
Title: Re: Problem With Wiki Example
Post by: bplus on August 22, 2019, 10:10:35 pm
Kinda hastily put together but you can get around pretty nicely, do not try to go up into \users, Windows shuts down access.

Code: QB64: [Select]
  1. _TITLE "Tiny Navigator" 'B+ 2019-08-22
  2. SCREEN _NEWIMAGE(1200, 600, 32)
  3. _SCREENMOVE 100, 50
  4.  
  5. DIM nav$, mySelection&, done$
  6.     PRINT "Current Directory: " + _CWD$
  7.     REDIM myFiles(0) AS STRING
  8.     loadFA "*.*", myFiles()
  9.     mySelection& = getArrayItemNumber&(5, 5, 90, 30, myFiles())
  10.     CLS
  11.     IF mySelection& <> -1719 THEN
  12.         CHDIR myFiles(mySelection&)
  13.     ELSE
  14.         PRINT "No Directory selected."
  15.         INPUT "Press enter to continue navigator, any + enter to quit... "; done$
  16.     END IF
  17.     _LIMIT 60
  18. LOOP UNTIL done$ <> ""
  19.  
  20. SUB loadFA (spec$, fa() AS STRING)
  21.     DIM Index%, fline$, d$
  22.     CONST TmpFile$ = "DIR$INF0.INF"
  23.     SHELL _HIDE "DIR /a:d >" + TmpFile$ 'get directories  but have to do a little pruning
  24.     'SHELL _HIDE "DIR " + spec$ + " /b > " + TmpFile$
  25.     'SHELL _HIDE "DIR " + spec$ + " /b /s /o:gen> " + TmpFile$
  26.     OPEN TmpFile$ FOR INPUT AS #1
  27.     Index% = -1
  28.     DO WHILE NOT EOF(1)
  29.         LINE INPUT #1, fline$
  30.         IF INSTR(fline$, "<DIR>") THEN
  31.             d$ = _TRIM$(rightOf$(fline$, "<DIR>"))
  32.             Index% = Index% + 1
  33.             REDIM _PRESERVE fa(Index%)
  34.             fa(Index%) = d$
  35.         END IF
  36.     LOOP
  37.     CLOSE #1
  38.     KILL TmpFile$
  39.  
  40. FUNCTION rightOf$ (source$, of$)
  41.     IF INSTR(source$, of$) > 0 THEN rightOf$ = MID$(source$, INSTR(source$, of$) + LEN(of$))
  42.  
  43. 'attempting use this 4 things (2018-12-30)
  44. ' 1. expects HELP sub that uses message and message box but easy to comment out
  45. ' 2. expects to be in graphics mode
  46. ' 3. chages color of screen
  47. ' 4. needs _KEYCLEAR 2 before calling of previous keyhits will interfere!!!
  48. '
  49. ' Future Help Message Box for the function.
  50. ' "*** Mouse and Key Instructions ***"
  51. '
  52. ' "Mouse, mouse wheel, and arrow keys should work as expected for item selection."
  53. ' "Press spacebar to select a highlighted item or just click it."
  54. ' "Use number(s) + enter to select an array item by it's index number,"
  55. ' "backspace will remove last number pressed, c will clear a number started."
  56. ' "Numbers started are shown in bottom right PgDn bar."
  57. ' "Enter will also select the highlighted item, if no number has been started."
  58. ' "Home starts you at lowest array index, End highlights then highest index."
  59. ' "Use PgUp and PgDn keys to flip through pages of array items."
  60. '
  61. ' "Escape returns -1719 to allow a Cancel function and signal no slection."
  62. FUNCTION getArrayItemNumber& (locateRow, locateColumn, boxWidth, boxHeight, arr() AS STRING)
  63.     'Notes: locateRow, locateColumn for top right corner of selection box on screen in characters for LOCATE.
  64.     'boxWidth and boxHeight are in character units, again for locate and print at correct places.
  65.     'All displaying is restricted to inside the box, which has PgUP and PgDn as top and bottom lines in the display.
  66.  
  67.     DIM curRow AS INTEGER, curCol AS INTEGER, fg AS _UNSIGNED LONG, bg AS _UNSIGNED LONG
  68.     DIM maxWidth AS INTEGER, maxHeight AS INTEGER, page AS INTEGER, hlite AS INTEGER, mx AS INTEGER, my AS INTEGER
  69.     DIM lastMX AS INTEGER, lastMY AS INTEGER, row AS INTEGER, mb AS INTEGER
  70.     DIM lba AS LONG, uba AS LONG, choice AS LONG, kh AS LONG, index AS LONG
  71.     DIM clrStr AS STRING, b AS STRING
  72.  
  73.     'save old settings to restore at end ofsub
  74.     curRow = CSRLIN
  75.     curCol = POS(0)
  76.     fg = _DEFAULTCOLOR
  77.     bg = _BACKGROUNDCOLOR
  78.     _KEYCLEAR
  79.  
  80.     maxWidth = boxWidth '       number of characters in box
  81.     maxHeight = boxHeight - 2 ' number of lines displayed of array at one time = 1 page
  82.     lba = LBOUND(arr)
  83.     uba = UBOUND(arr)
  84.     page = 0
  85.     hlite = 0 '                 line in display ready for selection by spacebar or if no number is started, enter
  86.     clrStr$ = SPACE$(maxWidth) 'clearing a display line
  87.  
  88.     GOSUB update '              show the beginning of the array items for selection
  89.  
  90.     'signal cancel selection process, exit sub with this unlikely index to signal canel
  91.     choice = -1719 'primes 7 and 8, not likely to be a select index of an array
  92.  
  93.     DO 'until get a selection or demand exit
  94.  
  95.         'handle the key stuff
  96.         kh& = _KEYHIT
  97.         IF kh& THEN
  98.             IF kh& > 0 AND kh& < 255 THEN
  99.                 IF INSTR("0123456789", CHR$(kh&)) > 0 THEN b$ = b$ + CHR$(kh&): GOSUB update
  100.                 'IF CHR$(kh&) = "h" THEN HELP: _KEYCLEAR
  101.  
  102.                 IF CHR$(kh&) = "c" THEN b$ = "": GOSUB update
  103.                 IF kh& = 13 THEN 'enter pressed check if number is being entered?
  104.                     IF LEN(b$) THEN
  105.                         IF VAL(b$) >= lba AND VAL(b$) <= uba THEN 'we have number started
  106.                             choice = VAL(b$): EXIT DO
  107.                         ELSE 'clear b$ to show some response to enter
  108.                             b$ = "": GOSUB update 'clear the value that doesn't work
  109.                         END IF
  110.                     ELSE
  111.                         choice = hlite + page * maxHeight + lba 'must mean to select the highlighted item
  112.                     END IF
  113.                 END IF
  114.                 IF kh& = 27 THEN EXIT DO 'escape clause offered to Cancel selection process
  115.                 IF kh& = 32 THEN choice = hlite + page * maxHeight + lba 'best way to choose highlighted selection
  116.                 IF kh& = 8 THEN 'backspace to edit number
  117.                     IF LEN(b$) THEN b$ = LEFT$(b$, LEN(b$) - 1): GOSUB update
  118.                 END IF
  119.             ELSE
  120.                 SELECT CASE kh& 'choosing sections of array to display and highlighted item
  121.                     CASE 20736 'pg dn
  122.                         IF (page + 1) * maxHeight + lba <= uba THEN page = page + 1: GOSUB update
  123.                     CASE 18688 'pg up
  124.                         IF (page - 1) * maxHeight + lba >= lba THEN page = page - 1: GOSUB update
  125.                     CASE 18432 'up
  126.                         IF hlite - 1 < 0 THEN
  127.                             IF page > 0 THEN
  128.                                 page = page - 1: hlite = maxHeight - 1: GOSUB update
  129.                             END IF
  130.                         ELSE
  131.                             hlite = hlite - 1: GOSUB update
  132.                         END IF
  133.                     CASE 20480 'down
  134.                         IF (hlite + 1) + page * maxHeight + lba <= uba THEN 'ok to move up
  135.                             IF hlite + 1 > maxHeight - 1 THEN
  136.                                 page = page + 1: hlite = 0: GOSUB update
  137.                             ELSE
  138.                                 hlite = hlite + 1: GOSUB update
  139.                             END IF
  140.                         END IF
  141.                     CASE 18176 'home
  142.                         page = 0: hlite = 0: GOSUB update
  143.                     CASE 20224 ' end
  144.                         page = INT((uba - lba) / maxHeight): hlite = maxHeight - 1: GOSUB update
  145.                 END SELECT
  146.             END IF
  147.         END IF
  148.  
  149.         'handle the mouse stuff
  150.         WHILE _MOUSEINPUT
  151.             IF _MOUSEWHEEL = -1 THEN 'up?
  152.                 IF hlite - 1 < 0 THEN
  153.                     IF page > 0 THEN
  154.                         page = page - 1: hlite = maxHeight - 1: GOSUB update
  155.                     END IF
  156.                 ELSE
  157.                     hlite = hlite - 1: GOSUB update
  158.                 END IF
  159.             ELSEIF _MOUSEWHEEL = 1 THEN 'down?
  160.                 IF (hlite + 1) + page * maxHeight + lba <= uba THEN 'ok to move up
  161.                     IF hlite + 1 > maxHeight - 1 THEN
  162.                         page = page + 1: hlite = 0: GOSUB update
  163.                     ELSE
  164.                         hlite = hlite + 1: GOSUB update
  165.                     END IF
  166.                 END IF
  167.             END IF
  168.         WEND
  169.         mx = INT((_MOUSEX - locateColumn * 8) / 8) + 2: my = INT((_MOUSEY - locateRow * 16) / 16) + 2
  170.         IF _MOUSEBUTTON(1) THEN 'click contols or select array item
  171.             'clear mouse clicks
  172.             mb = _MOUSEBUTTON(1)
  173.             IF mb THEN 'clear it
  174.                 WHILE mb 'OK!
  175.                     IF _MOUSEINPUT THEN mb = _MOUSEBUTTON(1)
  176.                     _LIMIT 100
  177.                 WEND
  178.             END IF
  179.  
  180.             IF mx >= 1 AND mx <= maxWidth AND my >= 1 AND my <= maxHeight THEN
  181.                 choice = my + page * maxHeight + lba - 1 'select item clicked
  182.             ELSEIF mx >= 1 AND mx <= maxWidth AND my = 0 THEN 'page up or exit
  183.                 IF my = 0 AND (mx <= maxWidth AND mx >= maxWidth - 2) THEN 'exit sign
  184.                     EXIT DO 'escape plan for mouse click top right corner of display box
  185.                 ELSE 'PgUp bar clicked
  186.                     IF (page - 1) * maxHeight + lba >= lba THEN page = page - 1: GOSUB update
  187.                 END IF
  188.             ELSEIF mx >= 1 AND mx <= maxWidth AND my = maxHeight + 1 THEN 'page down bar clicked
  189.                 IF (page + 1) * maxHeight + lba <= uba THEN page = page + 1: GOSUB update
  190.             END IF
  191.         ELSE '   mouse over highlighting, only if mouse has moved!
  192.             IF mx >= 1 AND mx <= maxWidth AND my >= 1 AND my <= maxHeight THEN
  193.                 IF mx <> lastMX OR my <> lastMY THEN
  194.                     IF my - 1 <> hlite AND (my - 1 + page * maxHeight + lba <= uba) THEN
  195.                         hlite = my - 1
  196.                         lastMX = mx: lastMY = my
  197.                         GOSUB update
  198.                     END IF
  199.                 END IF
  200.             END IF
  201.         END IF
  202.         _LIMIT 200
  203.     LOOP UNTIL choice >= lba AND choice <= uba
  204.     getArrayItemNumber& = choice
  205.     COLOR fg, bg
  206.     'clear key presses
  207.     _KEYCLEAR
  208.     LOCATE curRow, curCol
  209.     'clear mouse clicks
  210.     mb = _MOUSEBUTTON(1)
  211.     IF mb THEN 'clear it
  212.         WHILE mb 'OK!
  213.             IF _MOUSEINPUT THEN mb = _MOUSEBUTTON(1)
  214.             _LIMIT 100
  215.         WEND
  216.     END IF
  217.     EXIT SUB
  218.  
  219.     'display of array sections and controls on screen
  220.     update:
  221.  
  222.     'fix hlite if it has dropped below last array item
  223.     WHILE hlite + page * maxHeight + lba > uba
  224.         hlite = hlite - 1
  225.     WEND
  226.  
  227.     'main display of array items at page * maxHeight (lines high)
  228.     FOR row = 0 TO maxHeight - 1
  229.         IF hlite = row THEN COLOR _RGB(200, 200, 255), _RGB32(0, 0, 88) ELSE COLOR _RGB32(0, 0, 88), _RGB(200, 200, 255)
  230.         LOCATE locateRow + row, locateColumn: PRINT clrStr$
  231.         index = row + page * maxHeight + lba
  232.         IF index >= lba AND index <= uba THEN
  233.             LOCATE locateRow + row, locateColumn
  234.             PRINT LEFT$(LTRIM$(STR$(index)) + ") " + arr(index), maxWidth)
  235.         END IF
  236.     NEXT
  237.  
  238.     'make page up and down bars to click, print PgUp / PgDn if available
  239.     COLOR _RGB32(200, 200, 255), _RGB32(0, 100, 50)
  240.     LOCATE locateRow - 1, locateColumn: PRINT SPACE$(maxWidth)
  241.     IF page <> 0 THEN LOCATE locateRow - 1, locateColumn: PRINT LEFT$(" Pg Up" + SPACE$(maxWidth), maxWidth)
  242.     LOCATE locateRow + maxHeight, locateColumn: PRINT SPACE$(maxWidth)
  243.     IF page <> INT(uba / maxHeight) THEN
  244.         LOCATE locateRow + maxHeight, locateColumn: PRINT LEFT$(" Pg Dn" + SPACE$(maxWidth), maxWidth)
  245.     END IF
  246.     'make exit sign for mouse click
  247.     COLOR _RGB32(255, 255, 255), _RGB32(200, 100, 0)
  248.     LOCATE locateRow - 1, locateColumn + maxWidth - 3
  249.     PRINT " X "
  250.  
  251.     'if a number selection has been started show it's build = b$
  252.     IF LEN(b$) THEN
  253.         COLOR _RGB(255, 255, 0), _RGB32(0, 0, 0)
  254.         LOCATE locateRow + maxHeight, locateColumn + maxWidth - LEN(b$) - 1
  255.         PRINT b$;
  256.     END IF
  257.     _DISPLAY
  258.     _LIMIT 100
  259.     RETURN
  260.  
  261.  

EDIT: remove unused sub
EDIT2; add title
Title: Re: Problem With Wiki Example
Post by: SierraKen on August 22, 2019, 10:11:34 pm
Thanks SMcNeill! It works mostly now... but there is there a limit of how many folders within folders it can go to? Because it won't pick up a folder within a folder within a folder, and that's where most of my songs are. lol Also, when it plays a song, the screen is black and doesn't go to the rest of my code like it's supposed to. Here is my entire program so far. I also put that file in my QB64 folder, thanks!

Code: QB64: [Select]
  1. 'This program was made on August 21, 2019 by Ken G. with some help by Petr from the QB64.org forum.
  2. 'This program will make a temporary file called MyMusicFiles-Temp000.temp
  3. 'which is just a text file and can be opened by Notepad. It shows a list of
  4. 'the mp3 songs in that directory. The file is deleted once the music starts.
  5.  
  6. DECLARE LIBRARY 'Directory Information using KERNEL32 provided by Dav
  7.     FUNCTION CURDirectory ALIAS GetCurrentDirectoryA (BYVAL nBufferLen AS LONG, lpBuffer AS STRING)
  8.  
  9.     FUNCTION FILE_load_dir& ALIAS load_dir (s AS STRING)
  10.     FUNCTION FILE_has_next_entry& ALIAS has_next_entry ()
  11.     SUB FILE_close_dir ALIAS close_dir ()
  12.     SUB FILE_get_next_entry ALIAS get_next_entry (s AS STRING, flags AS LONG, file_size AS LONG)
  13.     SUB FILE_get_current_dir ALIAS get_current_dir (s AS STRING)
  14.     FUNCTION FILE_current_dir_length& ALIAS current_dir_length ()
  15.  
  16.  
  17. _TITLE "Mini MP3 Player"
  18. SCREEN _NEWIMAGE(1024, 720, 32)
  19. begin:
  20. DIM f$(100000)
  21. record = 0
  22. rec = 0
  23. oldp = 0
  24. p = 0
  25. PRINT "                Mini MP3 Player"
  26. PRINT "                  By Ken G."
  27. '=== SHOW CURRENT DIRECTORY
  28. CurDir$ = SPACE$(255)
  29. Result = CURDirectory(LEN(CurDir$), CurDir$)
  30. IF Result THEN LOCATE 11, 1: PRINT "Directory: "; LEFT$(CurDir$, Result)
  31. PRINT "            (1) Change Directory"
  32. PRINT "            (2) Play Song"
  33. PRINT "            (3) Play Directory"
  34. PRINT "            (4) Quit"
  35. INPUT "      ->", a
  36. IF a = 1 THEN GOTO directory:
  37. IF a = 2 THEN GOTO song:
  38. IF a = 3 THEN GOTO playdir:
  39. IF a = 4 THEN END
  40. IF a > 4 OR a < 1 OR a <> INT(a) THEN GOTO begin:
  41. directory:
  42. again:
  43. INPUT "Directory: ", d$
  44. IF d$ = "" THEN GOTO begin:
  45. r% = _DIREXISTS(d$)
  46. IF r% <> -1 THEN
  47.     PRINT "Directory doesn't exist."
  48.     PRINT "Try again, or Enter for Menu."
  49.     GOTO again:
  50. GOTO begin:
  51. song:
  52. 'FILES "*.mp3"
  53. again2:
  54. 'INPUT "Song: ", song$
  55.  
  56.     song$ = SelectFile$("*.*", 100, 100)
  57.  
  58. LOOP UNTIL RIGHT$(song$, 3) = "mp3" OR RIGHT$(song$, 3) = "MP3" OR RIGHT$(song$, 3) = "Mp3" OR RIGHT$(song$, 3) = "mP3"
  59.  
  60.  
  61. 'PRINT "You selected:"; song$
  62.  
  63. 'IF RIGHT$(song$, 3) <> "mp3" OR RIGHT$(song$, 3) <> "MP3" OR RIGHT$(song$, 3) <> "Mp3" OR RIGHT$(song$, 3) <> "mP3" THEN GOTO again2:
  64.  
  65. 'fe% = _FILEEXISTS(song$)
  66. 'IF fe% <> -1 THEN GOTO again2:
  67. 'PRINT "Filename doesn't exist."
  68. 'PRINT "Try again, or Enter for Menu."
  69. 'GOTO again2:
  70. 'END IF
  71. s& = _SNDOPEN(song$)
  72. LOCATE 1, 1: PRINT song$
  73. LOCATE 2, 1: PRINT "Sound Rate: "; _SNDRATE
  74. LOCATE 4, 1: PRINT "Length: "; INT(_SNDLEN(s&))
  75. LOCATE 6, 1: PRINT "Space Bar = Pause (P)lay (S)top (M)enu"
  76.  
  77.     a$ = INKEY$
  78.     IF a$ = CHR$(27) THEN _SNDSTOP s&: END
  79.     IF a$ = " " THEN _SNDPAUSE s&
  80.     IF a$ = "S" OR a$ = "s" THEN _SNDSTOP s&
  81.     IF a$ = "P" OR a$ = "p" THEN _SNDPLAY s&
  82.     IF a$ = "M" OR a$ = "m" THEN _SNDSTOP s&: GOTO begin:
  83.     oldp = p
  84.     p = _SNDGETPOS(s&)
  85.     LOCATE 3, 1: PRINT "Position: "; INT(p)
  86.     IF INT(oldp) > INT(p) AND INT(p) = 0 THEN GOTO begin:
  87. GOTO begin:
  88. playdir:
  89. REDIM file(0) AS STRING 'create empty text array. 0 is record nr. 1!
  90. SHELL _HIDE "dir *.mp3 /B > MyMusicFiles-Temp000.temp" 'create mp3 files list.
  91. OPEN "MyMusicFiles-Temp000.temp" FOR INPUT AS #1
  92.     CLOSE #1
  93.     SHELL _HIDE "DEL MyMusicFiles-Temp000.temp"
  94.     CLS
  95.     PRINT "No mp3 songs on this folder."
  96.     PRINT
  97.     INPUT "Press Enter to go back to Menu.", menu$
  98.     GOTO begin:
  99.     LINE INPUT #1, file$
  100.     file(record) = file$
  101.     f$(record) = file$
  102.     PRINT f$(record)
  103.     record = record + 1 'for next loop we needed array higher up to one
  104.     REDIM _PRESERVE file(record) AS STRING 'this do array bigger without deleting content
  105. SHELL _HIDE "DEL MyMusicFiles-Temp000.temp"
  106. 'so now file(0) is first file from disk. file(3) is 4th file from disk. Try it:
  107. ready:
  108. s& = _SNDOPEN(file(rec))
  109. LOCATE 1, 1: PRINT f$(rec)
  110. LOCATE 2, 1: PRINT "Sound Rate: "; _SNDRATE
  111. LOCATE 4, 1: PRINT "Length: "; INT(_SNDLEN(s&))
  112. LOCATE 6, 1: PRINT "Space Bar = Pause (P)lay (N)ext Song (M)enu"
  113.  
  114.     a$ = INKEY$
  115.     IF a$ = CHR$(27) THEN _SNDSTOP s&: END
  116.     IF a$ = " " THEN _SNDPAUSE s&
  117.     IF a$ = "N" OR a$ = "n" THEN _SNDSTOP s&
  118.     IF a$ = "P" OR a$ = "p" THEN _SNDPLAY s&
  119.     IF a$ = "M" OR a$ = "m" THEN _SNDSTOP s&: rec = 0: GOTO begin:
  120.     oldp = p
  121.     p = _SNDGETPOS(s&)
  122.     LOCATE 3, 1: PRINT "Position: "; INT(p)
  123.     IF INT(oldp) > INT(p) AND INT(p) = 0 THEN GOTO more:
  124. more:
  125. IF rec = record - 1 THEN GOTO begin:
  126. rec = rec + 1
  127. GOTO ready:
  128.  
  129.  
  130. FUNCTION SelectFile$ (search$, x AS INTEGER, y AS INTEGER)
  131.     'save some old values
  132.     LoadFile_DC = _DEFAULTCOLOR: LoadFile_BG = _BACKGROUNDCOLOR
  133.     LoadFile_s = _SOURCE: LoadFile_d = _DEST
  134.     f = _FONT: _FONT 16
  135.     'some variables
  136.  
  137.     LoadFile_BoxColor = &HFFAAAAFF
  138.     LoadFile_FolderColor = &HFFFFFF00
  139.     LoadFile_FileColor = &HFFFFFFFF
  140.     IF INSTR(_OS$, "[WINDOWS]") THEN LoadFile_Slash$ = "\" ELSE LoadFile_Slash$ = "/"
  141.     LoadFile_Dir$ = SPACE$(FILE_current_dir_length)
  142.     FILE_get_current_dir LoadFile_Dir$
  143.     LoadFile_Dir$ = LoadFile_Dir$ + LoadFile_Slash$
  144.     'LoadFile_Dir$ = "." + LoadFile_Slash$
  145.     LoadFile_w = 639: LoadFile_h = 479
  146.     REDIM LoadFile_Label(0) AS STRING: LoadFile_Label(0) = "DIR"
  147.     REDIM LoadFile_DirList(-1 TO 9, -1 TO 9999) AS STRING
  148.     LoadFile_last = 1
  149.     FolderDeep = 1
  150.  
  151.     'some error checking
  152.     IF search$ = "" THEN EXIT SUB 'We can't search for nothing!
  153.  
  154.     'Copy background
  155.     PCOPY 0, 1
  156.     'set workscreen
  157.     LoadFile_ws = _NEWIMAGE(640, 480, 32)
  158.  
  159.     'Count our filetypes to display
  160.     LoadFile_TypeCount = 0
  161.     DO
  162.         LoadFile_TypeCount = LoadFile_TypeCount + 1
  163.         LoadFile_l = INSTR(LoadFile_l + 1, search$, ";") ' look for ; to denote more files
  164.         REDIM _PRESERVE LoadFile_Label(LoadFile_TypeCount) AS STRING
  165.         IF LoadFile_l > 0 THEN LoadFile_Label(LoadFile_TypeCount) = MID$(search$, LoadFile_last + 1, LoadFile_l - LoadFile_last - 1) ELSE LoadFile_Label(LoadFile_TypeCount) = MID$(search$, LoadFile_last + 1, LEN(search$) - LoadFile_last)
  166.         LoadFile_last = LoadFile_l + 1
  167.     LOOP UNTIL LoadFile_l = 0
  168.     LoadFile_l = 640 / (LoadFile_TypeCount + 1)
  169.     REDIM LoadFile_start(LoadFile_TypeCount), LoadFile_previous(LoadFile_TypeCount), LoadFile_more(LoadFile_TypeCount), LoadFile_Count(LoadFile_TypeCount)
  170.     FOR i = 0 TO LoadFile_TypeCount: LoadFile_start(i) = 1: NEXT
  171.  
  172.     _SOURCE LoadFile_ws: _DEST LoadFile_ws
  173.     DO
  174.         _LIMIT 30
  175.         FOR i = 0 TO LoadFile_TypeCount
  176.             LoadFile_Count(i) = 0
  177.             FOR j = 0 TO 9999
  178.                 LoadFile_DirList(i, j) = ""
  179.             NEXT
  180.         NEXT
  181.         'Generate our updated directory listings.
  182.  
  183.         IF FILE_load_dir&(LoadFile_Dir$ + CHR$(0)) THEN
  184.             DO
  185.                 LoadFile_length = FILE_has_next_entry 'Get length of next entry
  186.                 IF LoadFile_length > -1 THEN 'If we have a next entry
  187.                     LoadFile_nam$ = SPACE$(LoadFile_length) 'Set the size of our string
  188.                     FILE_get_next_entry LoadFile_nam$, LoadFile_flags, LoadFile_file_size 'Get the file's name, size, and 'flags'
  189.                     'Check if it's a file or a directory
  190.  
  191.                     IF _DIREXISTS(LoadFile_Dir$ + LoadFile_nam$) THEN
  192.                         IF LoadFile_nam$ <> "." THEN
  193.                             LoadFile_Count(0) = LoadFile_Count(0) + 1
  194.                             LoadFile_DirList(0, LoadFile_Count(0)) = LoadFile_nam$
  195.                         END IF
  196.                     ELSE 'We have a file
  197.                         FOR i = 1 TO LoadFile_TypeCount
  198.                             LoadFile_ext$ = RIGHT$(LoadFile_nam$, LEN(LoadFile_Label(i)))
  199.                             IF UCASE$(LoadFile_ext$) = UCASE$(LoadFile_Label(i)) THEN
  200.                                 LoadFile_Count(i) = LoadFile_Count(i) + 1
  201.                                 LoadFile_DirList(i, LoadFile_Count(i)) = LEFT$(LoadFile_nam$, LEN(LoadFile_nam$) - LEN(LoadFile_Label(i)))
  202.                                 EXIT FOR
  203.                             ELSEIF LoadFile_Label(i) = ".*" THEN
  204.                                 LoadFile_Count(i) = LoadFile_Count(i) + 1
  205.                                 LoadFile_DirList(i, LoadFile_Count(i)) = LoadFile_nam$
  206.                             END IF
  207.                         NEXT
  208.                     END IF
  209.                 END IF
  210.             LOOP UNTIL LoadFile_length = -1
  211.             FILE_close_dir
  212.         END IF
  213.  
  214.         updatelist:
  215.  
  216.  
  217.         CLS , &HFF005050 'Draw a nice display box
  218.         COLOR , 0
  219.         LINE (0, 0)-(LoadFile_w, LoadFile_h + 5 - 2 * 16), LoadFile_BoxColor, B
  220.         LINE (1, 1)-(LoadFile_w - 1, LoadFile_h + 6 - 2 * 16), LoadFile_BoxColor, B
  221.         LINE (0, 0)-(LoadFile_w, LoadFile_h), LoadFile_BoxColor, B
  222.         LINE (1, 1)-(LoadFile_w - 1, LoadFile_h - 1), LoadFile_BoxColor, B
  223.  
  224.         LINE (0, 16 + 3)-(LoadFile_w, 16 + 3), LoadFile_BoxColor
  225.         LINE (0, 16 + 4)-(LoadFile_w, 16 + 4), LoadFile_BoxColor
  226.         FOR i = 0 TO LoadFile_TypeCount
  227.             _PRINTSTRING (i * LoadFile_l + (LoadFile_l - 8 * LEN(LoadFile_Label(i))) / 2, 2), LoadFile_Label(i)
  228.             LINE (i * LoadFile_l, 0)-(i * LoadFile_l, LoadFile_h + 5 - 2 * 16), LoadFile_BoxColor
  229.         NEXT
  230.  
  231.         LINE (627, 2)-(637, 18), &HFFFF0000, BF
  232.         LINE (626, 2)-(637, 18), &HFF000000, B
  233.  
  234.         _PRINTSTRING (628, 2), "X"
  235.         IF selection > 0 THEN
  236.             IF LoadFile_Label(row) <> ".*" AND LoadFile_Label(row) <> "DIR" THEN temp$ = LoadFile_DirList(row, selection) + LoadFile_Label(row) ELSE temp$ = LoadFile_DirList(row, selection)
  237.             IF LoadFile_DirList(row, selection) = "" THEN temp$ = ""
  238.             selection = 0
  239.         END IF
  240.         _PRINTSTRING (10, 28 * 16 + 7), LoadFile_Dir$
  241.         _PRINTSTRING (630 - LEN(temp$) * 8, 28 * 16 + 7), temp$
  242.         IF temp$ = "" THEN oldselection = 0
  243.         IF oldselection > 0 THEN LINE (row * LoadFile_l, (oldselection + 1) * 16 + 5)-((row + 1) * LoadFile_l, (oldselection + 2) * 16 + 5), &HAAAAA000, BF
  244.  
  245.         FOR i = 0 TO UBOUND(LoadFile_label)
  246.             IF i = 0 THEN COLOR LoadFile_FolderColor ELSE COLOR LoadFile_FileColor
  247.             counter = 0
  248.             FOR j = LoadFile_start(i) TO LoadFile_start(i) + 24
  249.                 counter = counter + 1
  250.                 IF LoadFile_DirList(i, j) = "" THEN EXIT FOR
  251.                 _PRINTSTRING (i * LoadFile_l + 5, (counter + 1) * 16 + 7), LEFT$(LoadFile_DirList(i, j), LoadFile_l / 8 - 2)
  252.             NEXT
  253.             IF j = LoadFile_start(i) + 25 THEN LoadFile_more(i) = -1 ELSE LoadFile_more(i) = 0
  254.             IF LoadFile_start(i) > 1 THEN LoadFile_previous(i) = -1 ELSE LoadFile_previous(i) = 0
  255.             IF LoadFile_more(i) THEN
  256.                 LINE (i * LoadFile_l + 2, 27 * 16 + 5)-((i + 1) * LoadFile_l - 3, 28 * 16 + 3), &HFFFF0000, BF
  257.                 LINE (i * LoadFile_l + 2, 27 * 16 + 5)-((i + 1) * LoadFile_l - 3, 28 * 16 + 3), BoxColor, B
  258.                 COLOR &HFFFFFF00: _PRINTSTRING (i * LoadFile_l + (LoadFile_l - 8 * 11) / 2, 27 * 16 + 5), "SCROLL DOWN"
  259.                 COLOR LoadFile_FileColor
  260.             END IF
  261.             IF LoadFile_previous(i) THEN
  262.                 LINE (i * LoadFile_l + 2, 16 + 5)-((i + 1) * LoadFile_l - 3, 2 * 16 + 3), &HFFFF0000, BF
  263.                 LINE (i * LoadFile_l + 2, 16 + 5)-((i + 1) * LoadFile_l - 3, 2 * 16 + 3), BoxColor, B
  264.                 COLOR &HFFFFFF00: _PRINTSTRING (i * LoadFile_l + (LoadFile_l - 8 * 9) / 2, 16 + 5), "SCROLL UP"
  265.                 COLOR LoadFile_FileColor
  266.             END IF
  267.         NEXT
  268.  
  269.         _PUTIMAGE (0 + x, 0 + y)-(640 + x, 480 + y), LoadFile_ws, 0
  270.         _DISPLAY
  271.  
  272.         change = 0
  273.         DO
  274.             _LIMIT 30
  275.             LoadFile_LMB = 0 'This sets the left mouse button as unacceptable.
  276.             a = _KEYHIT
  277.             SELECT CASE a
  278.                 CASE 8 'backspace
  279.                     temp$ = LEFT$(temp$, LEN(temp$) - 1)
  280.                     change = -1
  281.                 CASE 13 'enter
  282.                     DO: LOOP UNTIL INKEY$ = "" 'Clear the keyboard buffer so it doesn't affect the main program.
  283.                     temp$ = LoadFile_Dir$ + temp$
  284.                     COLOR LoadFile_DC, LoadFile_BG: _SOURCE LoadFile_s: _DEST LoadFile_d: PCOPY 1, 0: _DISPLAY: SelectFile$ = temp$ 'Restore our old settings
  285.                     _FONT f
  286.                     EXIT SUB 'And leave
  287.                 CASE 27 'If ESC is pressed then...
  288.                     DO: LOOP UNTIL INKEY$ = "" 'Clear the keyboard buffer so it doesn't affect the main program.
  289.                     COLOR LoadFile_DC, LoadFile_BG: _SOURCE LoadFile_s: _DEST LoadFile_d: PCOPY 1, 0: _DISPLAY: SelectFile$ = "" 'Restore our old settings
  290.                     _FONT f
  291.                     EXIT SUB 'And leave
  292.                 CASE 32 TO 126
  293.                     temp$ = temp$ + CHR$(a)
  294.                     change = -1
  295.             END SELECT
  296.             DO
  297.                 IF _MOUSEBUTTON(1) = 0 THEN LoadFile_LMB = -1 'Only by lifting the mouse, will we count it as down
  298.                 'Note: we ignore LoadFile_LMB for the scroll bars, so we can just hold it down and scroll happily forever and ever...
  299.                 'or until we get to the limit of our file list.
  300.                 'We only check LoadFile_LMB when actually trying to select an item from our list.   No more "OOP!  I held it too long and did something I didn't want to do!"
  301.                 'Now we click once to select, click again to accept that selection.
  302.             LOOP WHILE _MOUSEINPUT
  303.             MX = _MOUSEX: MY = _MOUSEY
  304.             IF _MOUSEBUTTON(2) OR (LoadFile_LMB AND MX > 626 + x AND MX < 638 + x AND MY > 1 + y AND MY < 19 + y AND _MOUSEBUTTON(1)) THEN
  305.                 'restore those old values, and just exit.  Right mouse is an escape
  306.                 COLOR LoadFile_DC, LoadFile_BG: _SOURCE LoadFile_s: _DEST LoadFile_d: PCOPY 1, 0: _DISPLAY: SelectFile$ = ""
  307.                 _FONT f
  308.                 EXIT SUB
  309.             END IF
  310.             IF _MOUSEBUTTON(1) THEN 'Without the mouse being down, we don't need to check squat!
  311.                 'Check the 2 roLoadFile_ws for a click in the proper Y position
  312.                 IF MY >= 16 + 5 + y AND MY <= 2 * 16 + 3 + y THEN 'We're on the top row
  313.                     FOR j = 0 TO UBOUND(LoadFile_label)
  314.                         IF LoadFile_previous(j) AND MX >= j * LoadFile_l + 2 + x AND MX <= (j + 1) * LoadFile_l - 3 + x THEN
  315.                             LoadFile_start(j) = LoadFile_start(j) - 1
  316.                             change = -1: selection = 0: click = 0: temp$ = ""
  317.                             EXIT FOR
  318.                         END IF
  319.                     NEXT
  320.                 ELSEIF MY >= 27 * 16 + 5 + y AND MY <= 28 * 16 + 3 + y THEN 'We're on the bottom row
  321.                     FOR j = 0 TO UBOUND(LoadFile_label)
  322.                         IF LoadFile_more(j) AND MX >= j * LoadFile_l + 2 + x AND MX <= (j + 1) * LoadFile_l - 3 + x THEN
  323.                             LoadFile_start(j) = LoadFile_start(j) + 1
  324.                             change = -1: selection = 0: click = 0: temp$ = ""
  325.                             EXIT FOR
  326.                         END IF
  327.                     NEXT
  328.                 ELSEIF MY >= 37 + y AND MY <= 437 + y AND LoadFile_LMB THEN 'It's in a column somewhere.  Did someone click an item?!
  329.                     FOR j = 0 TO UBOUND(LoadFile_label)
  330.                         IF MX >= j * LoadFile_l + 2 + x AND MX <= (j + 1) * LoadFile_l - 3 + x THEN
  331.                             row = j
  332.                             oldselection = INT((MY - y - 37) / 16) + 1
  333.                             selection = LoadFile_start(j) + oldselection - 1
  334.                             change = -1
  335.                             click = -1
  336.                             EXIT FOR
  337.                         END IF
  338.                     NEXT
  339.                 END IF
  340.             END IF
  341.  
  342.             _DISPLAY
  343.         LOOP UNTIL change
  344.         IF click THEN 'we clicked something besides a scroll bar
  345.             IF LoadFile_Label(row) <> ".*" AND LoadFile_Label(row) <> "DIR" THEN temp1$ = LoadFile_DirList(row, selection) + LoadFile_Label(row) ELSE temp1$ = LoadFile_DirList(row, selection)
  346.             IF temp$ = temp1$ THEN
  347.                 'We picked one!
  348.                 SELECT CASE LoadFile_Label(row)
  349.                     CASE "DIR"
  350.                         IF LoadFile_DirList(row, selection) <> ".." THEN
  351.                             LoadFile_Dir$ = LoadFile_Dir$ + LoadFile_DirList(row, selection) + LoadFile_Slash$
  352.                         ELSE
  353.                             DO
  354.                                 LoadFile_Dir$ = LEFT$(LoadFile_Dir$, LEN(LoadFile_Dir$) - 1)
  355.                             LOOP UNTIL RIGHT$(LoadFile_Dir$, 1) = LoadFile_Slash$ OR LEN(LoadFile_Dir$) = 0
  356.                         END IF
  357.                         FOR i = 1 TO UBOUND(Loadfile_start)
  358.                             LoadFile_start(i) = 1
  359.                         NEXT
  360.                         selection = 0: temp$ = "": oldselection = 0
  361.                     CASE ".*": SelectFile$ = LoadFile_Dir$ + temp$: EXIT DO
  362.                     CASE ELSE: SelectFile$ = LoadFile_Dir$ + temp$: EXIT DO
  363.                 END SELECT
  364.             END IF
  365.             IF row > 0 THEN _DELAY .2: GOTO updatelist
  366.         ELSE
  367.             _DELAY .05
  368.             GOTO updatelist
  369.         END IF
  370.     LOOP
  371.     'restore those old values
  372.     COLOR LoadFile_DC, LoadFile_BG: _SOURCE LoadFile_s: _DEST LoadFile_d: PCOPY 1, 0: _DISPLAY
  373.     _FONT f
  374.  
  375. 'If you don't have a copy of direntry.h in your QB64 folder, then copy the following code into a new IDE window.
  376. 'Then remove the remarks.
  377. 'And save it as direntry.h
  378. 'direntry.h is required for this to work properly with the library files.
  379. 'I thought adding the code here would be a way to make certain that it'd be easy to recover the file
  380. 'in case something ever happened and it was accidently deleted off the drive for some reason.
  381.  
  382. '#include <dirent.h>
  383. '#include <sys/stat.h>
  384. '#include <unistd.h>
  385.  
  386. 'const int IS_DIR_FLAG = 1, IS_FILE_FLAG = 2;
  387.  
  388. 'DIR *pdir;
  389. 'struct dirent *next_entry;
  390. 'struct stat statbuf1;
  391.  
  392. 'char current_dir[FILENAME_MAX];
  393. '#ifdef QB64_WINDOWS
  394. '  #define GetCurrentDir _getcwd
  395. '#else
  396. '  #define GetCurrentDir getcwd
  397. '#endif
  398.  
  399. 'int load_dir (char * path) {
  400. '  struct dirent *pent;
  401. '  struct stat statbuf1;
  402. '//Open current directory
  403. 'pdir = opendir(path);
  404. 'if (!pdir) {
  405. 'return 0; //Didn't open
  406. '}
  407. 'return -1;
  408. '}
  409.  
  410. 'int has_next_entry () {
  411. '  next_entry = readdir(pdir);
  412. '  if (next_entry == NULL) return -1;
  413.  
  414. '  stat(next_entry->d_name, &statbuf1);
  415. '  return strlen(next_entry->d_name);
  416. '}
  417.  
  418. 'void get_next_entry (char * nam, int * flags, int * file_size) {
  419. '  strcpy(nam, next_entry->d_name);
  420. '  if (S_ISDIR(statbuf1.st_mode)) {
  421. '    *flags = IS_DIR_FLAG;
  422. '  } else {
  423. '    *flags = IS_FILE_FLAG;
  424. '  }
  425. '  *file_size = statbuf1.st_size;
  426. '  return ;
  427. '}
  428.  
  429. 'void close_dir () {
  430. '  closedir(pdir);
  431. '  pdir = NULL;
  432. '  return ;
  433. '}
  434.  
  435. 'int current_dir_length () {
  436. '  GetCurrentDir(current_dir, sizeof(current_dir));
  437. '  return strlen(current_dir);
  438. '}
  439.  
  440. 'void get_current_dir(char *dir) {
  441. '  memcpy(dir, current_dir, strlen(current_dir));
  442. '  return ;
  443. '}
  444.  
  445.  
  446.  
  447.  
Title: Re: Problem With Wiki Example
Post by: SierraKen on August 22, 2019, 10:21:26 pm
Wow that has some great potential B+! But when I try to click the .. to go to regular C: it says File Not Found on line 27.
 OPEN TmpFile$ FOR INPUT AS #1

I have to get to C: to get to my Music folder. But that's a really cool folder picker! I'll look into it more. It might be a SUB that I don't need like you said.
Title: Re: Problem With Wiki Example
Post by: bplus on August 22, 2019, 10:28:13 pm
Wow that has some great potential B+! But when I try to click the .. to go to regular C: it says File Not Found on line 27.
 OPEN TmpFile$ FOR INPUT AS #1

I have to get to C: to get to my Music folder. But that's a really cool folder picker! I'll look into it more. It might be a SUB that I don't need like you said.

Ah, if your files are near root C: I don't think Windows will let us go there. I could only navigate below users in my user name folder and below, Desktop, Documents, Downloads, ... there might be a way through but I don't know it.
Title: Re: Problem With Wiki Example
Post by: SierraKen on August 22, 2019, 10:39:51 pm
Actually B+ your program starts out right where your QB64 programs are, not the Users folder. I just ran a scan on my computer and it doesn't have the file DIR$INF0.INF. I wonder if it's because I am 64 bit Windows 10. I have my programs in (you guys will laugh) C:\QBasic because when I started I converted a lot of QBasic programs to QB64. And I have my entire QB64 inside C:\QBasic. So, this demonstration program starts at C:\QBasic. I just can't get it to C: and you are probably right, Microsoft is being Microsoft again. lol

I need to do some things tonight so I'll look into all of this another day real soon. Thanks again you 2. I haven't given up hope, yet. lol
Title: Re: Problem With Wiki Example
Post by: SMcNeill on August 22, 2019, 10:40:46 pm
Ah, if your files are near root C: I don't think Windows will let us go there. I could only navigate below users in my user name folder and below, Desktop, Documents, Downloads, ... there might be a way through but I don't know it.

You might want to look at my wallpaper changer, as well: https://www.qb64.org/forum/index.php?topic=1008.msg105845#msg105845

It uses SHELL and DIR to make a file listing, and strips out a lot of the unneeded info for you.

For directories only, you want: dir /A:D
files only: dir /A:-D
subfolders: dir /s
bare format: dir /b

Mix and match, as needed, to customize your command.  ;)
Title: Re: Problem With Wiki Example
Post by: bplus on August 23, 2019, 01:21:58 am
You might want to look at my wallpaper changer, as well: https://www.qb64.org/forum/index.php?topic=1008.msg105845#msg105845

It uses SHELL and DIR to make a file listing, and strips out a lot of the unneeded info for you.

For directories only, you want: dir /A:D
files only: dir /A:-D
subfolders: dir /s
bare format: dir /b

Mix and match, as needed, to customize your command.  ;)

Yes, that's what I am doing. You know, I think the problem is not getting DIR info, it is the ChDir command to those folders that I was attempting when "The file does not exist." message pops up and ends the session with error after error.
Title: Re: Problem With Wiki Example
Post by: Petr on August 23, 2019, 04:46:10 am
Hello people. Unfortunately, I also have to acknowledge that the Windows  open dialog in IDE 1.3 will end up saying that the program has stopped working. The same happens when using the IDE version 20180228/86 from git b301f92. However, after compiling the same resource in the 20170120/51 IDE, everything works as expected.

Attached source code contains my very old music player + EXE file compiled under IDE 20170120/51 (or older), if is compiled in this old version then works + skin file.

Title: Re: Problem With Wiki Example
Post by: SMcNeill on August 23, 2019, 06:29:14 am
Hello people. Unfortunately, I also have to acknowledge that the Windows  open dialog in IDE 1.3 will end up saying that the program has stopped working. The same happens when using the IDE version 20180228/86 from git b301f92. However, after compiling the same resource in the 20170120/51 IDE, everything works as expected.

Attached source code contains my very old music player + EXE file compiled under IDE 20170120/51 (or older), if is compiled in this old version then works + skin file.

The 2017 version is 32-bit; do you know if the others are, or not?
Title: Re: Problem With Wiki Example
Post by: Petr on August 23, 2019, 08:20:53 am
Hi Steve i look to it and yes. All versions than the one oldest are 64 bit. Oldest is 32 bit.
Title: Re: Problem With Wiki Example
Post by: bplus on August 23, 2019, 09:04:57 am
Actually B+ your program starts out right where your QB64 programs are, not the Users folder. I just ran a scan on my computer and it doesn't have the file DIR$INF0.INF. I wonder if it's because I am 64 bit Windows 10. I have my programs in (you guys will laugh) C:\QBasic because when I started I converted a lot of QBasic programs to QB64. And I have my entire QB64 inside C:\QBasic. So, this demonstration program starts at C:\QBasic. I just can't get it to C: and you are probably right, Microsoft is being Microsoft again. lol

I need to do some things tonight so I'll look into all of this another day real soon. Thanks again you 2. I haven't given up hope, yet. lol

BTW you can't find DIR$INFO.INF because it is erased after info is extracted. I wonder how it works if move the exe  in the root of your music files directory, should be able to navigate inside folders you make. Tiny Navigator needs a window on files and allow file selection.

Steve's is nice, I wonder about problem Ken reported about not being able to go so far into folders could music files be structured different!

One problem I encountered was over scrolling directories, they can get stuck all the way at top not reachable by mouse.
Title: Re: Problem With Wiki Example
Post by: SMcNeill on August 23, 2019, 09:18:22 am
BTW you can't find DIR$INFO.INF because it is erased after info is extracted. I wonder how it works if move the exe  in the root of your music files directory, should be able to navigate inside folders you make. Tiny Navigator needs a window on files and allow file selection.

Steve's is nice, I wonder about problem Ken reported about not being able to go so far into folders could music files be structured different!

I’m wondering if there’s issues with access permission rights.  I made a test folder my machine, stacked a dozen levels deep, and had no issues opening/navigating through them.  There’s no hard set “folder depth”, as far as I can tell.
Title: Re: Problem With Wiki Example
Post by: bplus on August 23, 2019, 09:21:24 am
I’m wondering if there’s issues with access permission rights.  I made a test folder my machine, stacked a dozen levels deep, and had no issues opening/navigating through them.  There’s no hard set “folder depth”, as far as I can tell.

Neither can I. I get file info from root and Windows stuff... I did find the scroller scrolling directories out of mouse reach, I should check arrow keys work :)
Title: Re: Problem With Wiki Example
Post by: bplus on August 23, 2019, 09:28:27 am
RE: Steves Path or File selector

No arrow keys, maybe I have to bang on scroll up bar 80 times?? to get .. to appear.
Title: Re: Problem With Wiki Example
Post by: bplus on August 23, 2019, 09:38:32 am
I think I know why Tiny Navigator runs into "No file found error", because the temp file is being created in each directory it ChDir changes to and you can't create files in certain Windows directories, easy fix, I think...
Title: Re: Problem With Wiki Example
Post by: Petr on August 23, 2019, 09:58:52 am
I repair problem with my windows browse dialog program and now it works. But it is not the same source code as Ken's. Problem was with LONG / _INTEGER64 types in library function FindWindow. Rewrited as _INTEGER64 and run fine. (i write about my player). Under 1.3.

See to row 463, HwndOwner

Upgraded source code: (need files from ZIP posted before)

Code: QB64: [Select]
  1. DIM SHARED seznam2(1000) AS STRING * 255 '                 maximum files in directory limited to 1000
  2. DIM SHARED VFiles(1000) AS STRING * 255 '                  Dim for memory array contains VISIBLE file names (vith national characters others as US, displayed with _MAPUNICODE, BUT UNUSABLE TO OPERATION WITH FILES!
  3. DIM SHARED UFiles(1000) AS STRING * 255 '                  Dim for memory array contains UNVISIBLE, old filenames type 8.3. This is ussable to operation with files, but is not standardly displayed. One record lenght = 13.
  4. DIM SHARED MaskUFiles(1000) AS STRING * 255 '              Dim for array contains empty blocks + blocks with record accetable filemask - U = usable for file access
  5. DIM SHARED MaskVFiles(1000) AS STRING * 255 '              the same, but V = Visible - here are strings that can be correctly converted to screen with _MAPUNICODE, but are unussable to file access
  6. ' -------------------------------------------------        this all dims are erased if sub end. Final outputs are:
  7. DIM SHARED FinalVFiles(1000) AS STRING * 255 '             Contains all QB64 usable soundformat files from directory - names unusable for access
  8. DIM SHARED FinalUFiles(1000) AS STRING * 12 '               8 + "." + 3 the same as previous case, but usable for file access
  9. DIM SHARED sekunda(10) AS INTEGER, minuta(360) AS INTEGER 'Array contains seconds and minute for song time
  10. DIM SHARED text(27) AS STRING * 200 '                       27 linies, contains 200 characters (max)
  11. DIM SHARED RndFinalVFiles(1000) AS STRING * 255 '           its still copy FinalVFiles - if random play is off, its random array generated in VFiles copyed back from this still copy
  12. DIM SHARED RndFinalUFiles(1000) AS STRING * 255
  13. DIM SHARED copyU(1000) AS STRING * 200 ' bylo nastaveno max misto 1000 kdyby rndplay neslo...
  14. DIM SHARED copyV(1000) AS STRING * 200
  15. DIM SHARED Track(1000) AS INTEGER '                         contains track list in play order (every track listed by nacti.b has own rerord number)
  16.  
  17. path$ = ENVIRON$("SYSTEMROOT")
  18. path$ = path$ + "\fonts\cour.ttf"
  19. f& = _LOADFONT(path$, 32, "monospace, bold") '              Load font. Font is used for correct display song name
  20. Vol = 1
  21. polar = 10
  22.  
  23.  
  24. _TITLE "QB64 Music Player.      By Petr - Petr.Pr@email.cz" 'i dont know who is it  :-D
  25. i& = _NEWIMAGE(1024, 300, 32) '                              My screen window
  26. new& = _LOADIMAGE("skinDb.png", 32) '                        My all in one graphic file
  27. j& = _NEWIMAGE(1024, 300, 32)
  28. d& = _NEWIMAGE(491, 74, 32)
  29. GreenButtonPlay& = _NEWIMAGE(100, 100, 32)
  30. GreenButtonStop& = _NEWIMAGE(100, 100, 32)
  31. GreenButtonPower& = _NEWIMAGE(100, 100, 32)
  32. GreenButtonBack& = _NEWIMAGE(100, 100, 32)
  33. GreenButtonPause& = _NEWIMAGE(100, 100, 32)
  34. GreenButtonNext& = _NEWIMAGE(100, 100, 32)
  35. VolumePlus& = _NEWIMAGE(50, 50, 32)
  36. VolumeMinus& = _NEWIMAGE(50, 50, 32)
  37. ImageOpenFiles& = _NEWIMAGE(50, 50, 32)
  38. resicon& = _NEWIMAGE(114, 30, 32)
  39. infoicon& = _NEWIMAGE(50, 50, 32)
  40. LoopOneU& = _NEWIMAGE(50, 50, 32) ' U as unpressed or NOT pressed
  41. LoopAllU& = _NEWIMAGE(50, 50, 32)
  42. LoopOneP& = _NEWIMAGE(50, 50, 32) ' P as Pressed
  43. LoopAllP& = _NEWIMAGE(50, 50, 32)
  44. RandPlayOff& = _NEWIMAGE(27, 12, 32)
  45. RandPlayOn& = _NEWIMAGE(27, 12, 32)
  46. afterinfo& = _NEWIMAGE(1024, 300, 32)
  47. _PUTIMAGE (0, 0)-(26, 11), new&, RandPlayOff&, (560, 60)-(586, 71)
  48. _PUTIMAGE (0, 0)-(26, 11), new&, RandPlayOn&, (560, 74)-(586, 85)
  49. _PUTIMAGE (0, 0)-(49, 49), new&, LoopAllP&, (894, 592)-(960, 656)
  50. _PUTIMAGE (0, 0)-(49, 49), new&, LoopOneP&, (960, 590)-(1023, 650)
  51. _PUTIMAGE (0, 0)-(49, 49), new&, LoopAllU&, (896, 530)-(956, 590)
  52. _PUTIMAGE (0, 0)-(49, 49), new&, LoopOneU&, (950, 470)-(1010, 530)
  53. _PUTIMAGE (0, 0)-(49, 49), new&, infoicon&, (964, 538)-(1014, 588)
  54. _PUTIMAGE (0, 0)-(113, 29), new&, resicon&, (571, 8)-(684, 37)
  55. _PUTIMAGE (0, 0)-(49, 49), new&, ImageOpenFiles&, (899, 474)-(948, 523)
  56. _PUTIMAGE (0, 0)-(49, 49), new&, VolumeMinus&, (895, 412)-(945, 462)
  57. _PUTIMAGE (0, 0)-(49, 49), new&, VolumePlus&, (958, 412)-(1008, 462)
  58. _PUTIMAGE (0, 0), new&, GreenButtonNext&, (760, 540)-(860, 640)
  59. _PUTIMAGE (0, 0), new&, GreenButtonPause&, (650, 540)-(750, 640)
  60. _PUTIMAGE (0, 0), new&, GreenButtonBack&, (540, 540)-(640, 640)
  61. _PUTIMAGE (0, 0), new&, GreenButtonPower&, (770, 430)-(870, 530)
  62. _PUTIMAGE (0, 0), new&, GreenButtonStop&, (650, 430)-(750, 530)
  63. _PUTIMAGE (0, 0), new&, GreenButtonPlay&, (532, 431)-(632, 531)
  64. _PUTIMAGE (0, 0), new&, j&, (1, 100)-(1025, 401)
  65. _PUTIMAGE (0, 0), new&, d&, (0, 0)-(490, 73)
  66. 'j& = _LOADIMAGE("skin.png", 32) 'tohle
  67. 'd& = _LOADIMAGE("digits.png", 32) 'tohle
  68. _PUTIMAGE , j&, i&: m& = _NEWIMAGE(400, 100, 32): t& = _NEWIMAGE(5000, 120, 32) ' t& = song title - for long names
  69.  
  70.  
  71. titlemusic$ = "Stoped" '                                                          basic status
  72. InsertX = -200 '                                                                  its X axis for song name moving on screen
  73. 'mrizka 170, 10
  74. 'path$ = ENVIRON$("SYSTEMROOT")
  75. 'path$ = path$ + "\fonts\cour.ttf"
  76.  
  77. 'screen i&
  78. white& = _RGB32(255, 255, 255)
  79. whitetwo& = _RGB32(150, 150, 150)
  80. _SETALPHA 0, white& TO whitetwo&, VolumePlus&
  81. _SETALPHA 0, white& TO whitetwo&, VolumeMinus&
  82. _SETALPHA 0, white& TO whitetwo&, ImageOpenFiles&
  83. _SETALPHA 0, white& TO whitetwo&, infoicon&
  84. _SETALPHA 0, white& TO _RGB32(65, 65, 65), LoopOneU&
  85. _SETALPHA 0, white& TO _RGB32(65, 65, 65), LoopAllU&
  86. '_SETALPHA 0, white& TO _RGB32(65, 65, 65), LoopOneP&
  87. '_SETALPHA 0, white& TO _RGB32(65, 65, 65), LoopAllP&
  88. _PUTIMAGE (918, 170), LoopOneU&
  89. _PUTIMAGE (918, 115), LoopAllU&
  90.  
  91. _PUTIMAGE (739, 223), infoicon&
  92. _PUTIMAGE (799, 223), ImageOpenFiles&, i&
  93. _PUTIMAGE (859, 222), VolumePlus&, i&
  94. _PUTIMAGE (919, 222), VolumeMinus&, i&
  95. _PUTIMAGE (0, 0), i&, afterinfo&
  96. _SETALPHA 0, white& TO _RGB32(65, 65, 65), RandPlayOff&
  97. _PUTIMAGE (930, 91), RandPlayOff&, i&
  98. _SETALPHA 0, white& TO _RGB32(65, 65, 65), RandPlayOn&
  99.  
  100.  
  101. LoopOne = 0 '                                               basic status for neverending playing one track
  102. LoopAll = 0 '                                               basic status for neverending playing all tracks from selected directory
  103. WindowsFileOpenSystem
  104. IF PlEr = 1 THEN PlEr = 0: BEEP: WindowsFileOpenSystem '    PlEr = Play Error. 0 = no error, 1 = is error. WindowsFileOpenSystem is function for opening folders from windows.
  105. nacti.b '                                                   create list all playble files in selected folder to swap file, load it to memory, then delete swap file. Create unsorted list!
  106.  
  107. 'RndPlay 1 OK!!!!
  108.  
  109. reload = 1 '                                                'Reload = 1 started WindowsFileOpenSystem, Reload = 0 close it.
  110. RAP "StartDemo" '                                            Start basic mode
  111. ' WindowsFileOpenSystem ' if skiped this, its start automaticaly plays files in the same directory who is
  112.  
  113. dalsi:
  114. IF _SNDPLAYING(zvuk&) = 0 THEN minuta = 0: sekunda = 0: oldsec = sec 'dodana podminka    Reset song time if song playing is on the end
  115. IF posuv = 1 THEN posuv = 0: GOTO posunuto '                                             POSUV = song moving. 1 = is pressed next or back button
  116. IF LoopOne = 1 THEN GOTO posunuto '                                                      LoopOne = is pressed neverending playing for one song, also akt muss be the same.
  117. akt = akt + 1 '                                                                          akt = actual play track number. Here this say go playing next song in list.
  118.  
  119. posunuto:
  120. IF LoopAll = 1 AND akt > max THEN akt = 1 '                                              This reset playing to begin, if is selected neverending playing for all songs in directory.
  121. IF LoopAll = 0 AND akt > max THEN akt = 0: BEEP: stopp = 1: status$ = "Playlist end!" '  If all songs id directory are played to end and neverending playing for all not selected, beep and now new with status. Stopp = 1 = draw stop button to pressed.
  122.  
  123.  
  124.  
  125.  
  126. 'IF akt > max THEN akt = 1 'return plays to begin
  127. file$ = FinalUFiles$(akt)
  128. IF _SNDPLAYING(zvuk&) = 0 AND _SNDPAUSED(zvuk&) <> -1 AND stopp = 0 THEN hraj file$ 'tento krok zpusobuje chybu funkce STOP
  129. IF inf = 0 THEN _TITLE "QB64 Music Player.      By Petr - Petr.Pr@email.cz"
  130. DO WHILE _SNDPLAYING(zvuk&) = -1 OR _SNDPAUSED(zvuk&) = -1 OR stopp = 1 '                  Play sound if STOP is not pressed, playing is not in the end or PAUSE is not pressed
  131.     IF _FULLSCREEN > 0 THEN _FULLSCREEN _OFF '                                             if user press Alt + enter, do screen size back!
  132.     Rodent '                                                                               call mouse interaction sub
  133.     IF reload = 1 THEN reload = 0: akt = 0: GOTO dalsi '                                   this line is for RELOAD if you open next folder
  134.     RAP FinalVFiles$(akt) '                                                                draw visible song name to screen
  135.     '    COLOR _RGB(255, 255, 255): PRINT FinalVFiles$(akt): SLEEP
  136.     IF inf = 0 THEN _DISPLAY '                                                             inf is for info if icon INFO on screen is pressed or not. If is, then my screen is in the background
  137.     '_LIMIT 25
  138.     cj '                                                                                   cj - sub named as Cesky Jazyk - english - Czech language. It make Czech characters correctly readable an othe screen.
  139.     '--------------------------------------------------------- KEYBOARD INPUTS ---------------------------------------------- Keyboard inputs -------------
  140.     IF inf = 1 THEN info '                                                                  return to sub INFO. INFO is waiting for pressing Esc key to end him or up/dn to read text.
  141.     IF inf = 1 THEN GOTO rtr '                                                              if INFO icon is pressed, is keyboard input for my program off, but not for INFO window.
  142.     i$ = INKEY$
  143.     SELECT CASE i$
  144.         CASE CHR$(27)
  145.             RAP "shutdown.internal.cmd" '                                                  this shutdown this program, before is called other sub for ersing all images from memory.
  146.         CASE CHR$(13)
  147.             IF vs = 1 THEN vs = 0 ELSE vs = 1 '                                             switch song time    backward / normal
  148.         CASE "P", "p"
  149.             'previous
  150.             RAP "getback.internal.cmd" '                                                    say - play previous song
  151.             akt = akt - 1: posuv = 1
  152.             i$ = ""
  153.             IF akt < 1 THEN pl = max '                                                      if is played first song in list, then skip and play last from list
  154.             _SNDSTOP (zvuk&) '                                                              but first stop playing current song.
  155.             EXIT DO
  156.         CASE "N", "n"
  157.             'next
  158.             RAP "getnext.internal.cmd" '                                                    say - play next song
  159.             akt = akt + 1: posuv = 1
  160.             i$ = ""
  161.             IF akt > linka THEN pl = 1 'found and repaired ERROR                            if is played last song from list, then skip and play first from list
  162.             _SNDSTOP (zvuk&) '                                                              but first stop current song.
  163.             EXIT DO
  164.         CASE CHR$(32)
  165.             IF _SNDPAUSED(zvuk&) = -1 THEN _SNDPLAY (zvuk&) ELSE _SNDPAUSE zvuk& '          if is pressed spacebar, use _SNDPAUSE
  166.         CASE "<", ","
  167.             ch# = ch# - .01: IF ch# < -1 THEN ch# = -1
  168.             _SNDBAL zvuk&, ch# '                                                            if is pressed < or , or . or > then reselect balance settings. Using double values.
  169.         CASE ">", "."
  170.             ch# = ch# + .01: IF ch# > 1 THEN ch# = 1
  171.             _SNDBAL zvuk&, ch#
  172.         CASE "+"
  173.             Vol = Vol + .01: IF Vol > 1 THEN Vol = 1 '                                      if is pressed + or - then reselect volume level
  174.             _SNDVOL zvuk&, Vol
  175.         CASE "-"
  176.             Vol = Vol - .01: IF Vol < 0 THEN Vol = 0
  177.             _SNDVOL zvuk&, Vol
  178.     END SELECT
  179.     rtr:
  180.  
  181. IF reload = 1 THEN GOTO dalsi 'here is curent problem?
  182.  
  183. GOTO dalsi '                                                                                   go back to DALSI, its begin this my loop and wait until song is played to end or keys are pressed.
  184. 'konec:
  185. '_SNDSTOP (zvuk&)
  186. 'IF LoopAll = 1 THEN GOTO dalsi 'make neverending loop, plays all files from begin
  187.  
  188. SUB RndPlay (status AS INTEGER) 'sub is tested                                                   Create random order for playlist, status: 0 = not use random order, 1 = use random order
  189.     SHARED max, usingRND, gen, tracknumber, stav '                                                max = maximal songs number in list, usingRND - info if song list is original or randomized
  190.     IF RTRIM$(LTRIM$(FinalUFiles(1))) = "" OR RTRIM$(LTRIM$(FinalVFiles(1))) = "" THEN EXIT SUB
  191.     IF usingRND = 0 THEN
  192.         FOR StillCopy = 1 TO max
  193.             copyU(StillCopy) = FinalUFiles(StillCopy)
  194.             copyV(StillCopy) = FinalVFiles(StillCopy)
  195.         NEXT
  196.     END IF
  197.     gen = 0
  198.     SELECT CASE status
  199.         CASE 0 'Random music play is OFF
  200.             IF usingRND = 0 THEN EXIT SUB
  201.             FOR rewrite = 1 TO max '                                                             here copying old playlist to this arrays, randomlist is ready in finalufiles and finalvfiles. Its ready for rndmusic off.
  202.                 FinalUFiles(rewrite) = copyU(rewrite)
  203.                 FinalVFiles(rewrite) = copyV(rewrite)
  204.  
  205.             NEXT
  206.             usingRND = 0 '                                                                      select RndPlay as unused for next use
  207.  
  208.         CASE 1 'Random music play is ON
  209.             FOR generate = 1 TO max
  210.                 gene:
  211.                 RANDOMIZE generate
  212.                 tracknumber = INT(RND * (max * 2))
  213.                 IF tracknumber > max OR tracknumber <= 0 THEN GOTO gene
  214.                 FOR ctrl = 1 TO generate
  215.                     IF tracknumber = Track(ctrl) THEN GOTO gene
  216.                 NEXT ctrl
  217.                 gen = gen + 1
  218.                 Track(gen) = tracknumber
  219.             NEXT
  220.             '            PRINT "Generovana cisla stop priradim pisnickam:"
  221.  
  222.             FOR cisla = 1 TO max
  223.                 FinalVFiles(cisla) = copyV(Track(cisla))
  224.                 FinalUFiles(cisla) = copyU(Track(cisla))
  225.             NEXT
  226.             '            vypis
  227.             usingRND = 1 '                                                                        Rndmusic is used and is possible rewriting arrays back if is going off.
  228.     END SELECT
  229.  
  230.  
  231.  
  232. SUB Rodent
  233.     SHARED MouseX, MouseY, Lb, zvuk&, akt, posuv, Vol, ch#, vs, stopp, inf, LoopAll, LoopOne, LoopAllU&, LoopAllP&, LoopOneU&, LoopOneP&, i&, rndpl '  mouse interface
  234.     IF inf = 1 THEN EXIT SUB '                                                                                                                         if INFO icon is pressed, is mouse to program window off
  235.         MouseX = _MOUSEX
  236.         MouseY = _MOUSEY
  237.         Lb = _MOUSEBUTTON(1)
  238.     LOOP
  239.     White& = _RGB32(255, 255, 255)
  240.     'mouse interaction
  241.     IF MouseX > 27 AND MouseX < 86 AND MouseY > 40 AND MouseY < 105 AND Lb = -1 THEN GOSUB PlayPressed
  242.     IF MouseX > 145 AND MouseX < 190 AND MouseY > 40 AND MouseY < 105 AND Lb = -1 THEN GOSUB StopPressed
  243.     IF MouseX > 252 AND MouseX < 305 AND MouseY > 40 AND MouseY < 105 AND Lb = -1 THEN GOSUB PowerPressed
  244.     IF MouseX > 27 AND MouseX < 86 AND MouseY > 151 AND MouseY < 209 AND Lb = -1 THEN GOSUB BackPressed
  245.     IF MouseX > 145 AND MouseX < 190 AND MouseY > 151 AND MouseY < 209 AND Lb = -1 THEN GOSUB PausePressed
  246.     IF MouseX > 252 AND MouseX < 305 AND MouseY > 151 AND MouseY < 209 AND Lb = -1 THEN GOSUB NextPressed
  247.     IF MouseX > 861 AND MouseX < 900 AND MouseY > 230 AND MouseY < 265 AND Lb = -1 THEN GOSUB VolPlus
  248.     IF MouseX > 798 AND MouseX < 835 AND MouseY > 230 AND MouseY < 265 AND Lb = -1 THEN GOSUB FilesSelect: EXIT SUB
  249.     IF MouseX > 925 AND MouseX < 961 AND MouseY > 225 AND MouseY < 265 AND Lb = -1 THEN GOSUB VolMinus
  250.     IF MouseX > 410 AND MouseX < 460 AND MouseY > 160 AND MouseY < 205 AND Lb = -1 THEN GOSUB BalanceLeft
  251.     IF MouseX > 600 AND MouseX < 650 AND MouseY > 160 AND MouseY < 205 AND Lb = -1 THEN GOSUB BalanceRight
  252.     IF MouseX > 730 AND MouseX < 923 AND MouseX > 60 AND MouseY < 93 AND Lb = -1 THEN GOSUB ViewTime
  253.     IF MouseX > 745 AND MouseX < 785 AND MouseY > 230 AND MouseY < 265 AND Lb = -1 THEN GOSUB info
  254.     IF MouseX > 930 AND MouseX < 960 AND MouseY > 120 AND MouseY < 155 AND Lb = -1 THEN GOSUB PressedLoopAll
  255.     IF MouseX > 930 AND MouseX < 960 AND MouseY > 176 AND MouseY < 210 AND Lb = -1 THEN GOSUB PressedLoopOne
  256.     IF MouseX > 933 AND MouseX < 955 AND MouseY > 94 AND MouseY < 100 AND Lb = -1 THEN GOSUB RandomPlay
  257.     EXIT SUB
  258.     PlayPressed:
  259.     '_SNDPLAY (zvuk&)
  260.     IF stopp = 1 THEN stopp = 0 '                                                             if is stop button draw as pressed, then draw it as unpressed (stop button cooperation)
  261.     RETURN
  262.     StopPressed:
  263.     IF _SNDPLAYING(zvuk&) = -1 THEN _SNDSTOP (zvuk&)
  264.     IF stopp = 1 THEN stopp = 0 ELSE stopp = 1: _DELAY 0.5 '                                  Stop button cooperation
  265.     RETURN
  266.     PowerPressed: RAP "shutdown.internal.cmd" '                                               Power button cooperation
  267.     BackPressed: RAP "getback.internal.cmd": akt = akt - 1: posuv = 1: _SNDSTOP zvuk& '       Back button cooperation
  268.     IF akt < 1 THEN pl = max
  269.     RETURN
  270.     PausePressed: '                                                                           Pause button cooperation
  271.     IF _SNDPAUSED(zvuk&) = -1 THEN _SNDPLAY (zvuk&) ELSE _SNDPAUSE zvuk&
  272.     _DELAY 0.2
  273.     RETURN
  274.     NextPressed: '                                                                            Next button cooperation
  275.     RAP "getnext.internal.cmd"
  276.     akt = akt + 1: posuv = 1
  277.     IF pl > linka THEN pl = 1
  278.     _SNDSTOP (zvuk&)
  279.     RETURN
  280.     VolPlus: Vol = Vol + .01: IF Vol > 1 THEN Vol = 1 '                                       Volume plus button cooperation
  281.     _SNDVOL zvuk&, Vol: RETURN
  282.     VolMinus: Vol = Vol - .01: IF Vol < 0 THEN Vol = 0 '                                      Volume minus button cooperation
  283.     _SNDVOL zvuk&, Vol: RETURN
  284.     FilesSelect:
  285.     _SNDSTOP (zvuk&)
  286.     ' IF RTRIM$(LTRIM$(FinalUFiles(1))) = "" THEN
  287.     RndPlay 0
  288.     rndpl = 0
  289.     akt = 0
  290.     WindowsFileOpenSystem '                                                                   start first folder select window in program begin
  291.     RETURN
  292.     BalanceLeft:
  293.     ch# = ch# - .01: IF ch# < -1 THEN ch# = -1 '                                              balance (speakers) icon cooperation
  294.     _SNDBAL zvuk&, ch#
  295.     RETURN
  296.     BalanceRight:
  297.     ch# = ch# + .01: IF ch# > 1 THEN ch# = 1
  298.     _SNDBAL zvuk&, ch#
  299.     RETURN
  300.     ViewTime: IF vs = 1 THEN vs = 0: _DELAY .1 ELSE IF vs = 0 AND ab = 0 THEN vs = 1: _DELAY .1 ' If is enter pressed, so vs = 0 = show song time from begin, vs = 1 = show song time from end
  301.     ViewSongTime vs '                                                                           call sub for time view
  302.     RETURN
  303.     info:
  304.     info '                                                                                      call sub info, this view information in data block sub info
  305.     RETURN
  306.     PressedLoopAll:
  307.     IF LoopAll = 0 THEN LoopAll = 1 ELSE LoopAll = 0
  308.     PressLoop 1 '                                                                               set loop after loop for all songs icon click
  309.     _DELAY 0.2
  310.     RETURN
  311.     PressedLoopOne:
  312.     IF LoopOne = 0 THEN LoopOne = 1 ELSE LoopOne = 0 '                                          set loop after click to icon for one song loop
  313.     PressLoop 2
  314.     _DELAY 0.2
  315.     RETURN
  316.     RandomPlay: '                                                                               cooperation with RND icon (random order music play)
  317.     IF _SNDPLAYING(zvuk&) <> -1 THEN RETURN
  318.     IF rndpl = 0 THEN _DELAY .01: rndpl = 1 ELSE rndpl = 0
  319.     RETURN
  320.  
  321.  
  322.  
  323. SUB PressLoop (ico AS INTEGER)
  324.     SHARED LoopAll, LoopOne, LoopAllU&, LoopAllP&, LoopOneU&, LoopOneP&
  325.     SELECT CASE ico
  326.         CASE 1
  327.             SELECT CASE LoopAll
  328.                 CASE 0
  329.                     _PUTIMAGE (918, 115), LoopAllU&
  330.                 CASE 1
  331.                     _CLEARCOLOR _RGB32(255, 255, 255), LoopAllP&
  332.                     _SETALPHA 0, _RGB32(254, 255, 255) TO _RGB32(200, 200, 200), LoopAllP& '    draw loop icons on screen for both case
  333.                     _PUTIMAGE (920, 115), LoopAllP&
  334.             END SELECT
  335.         CASE 2
  336.             SELECT CASE LoopOne
  337.                 CASE 0
  338.                     _PUTIMAGE (918, 170), LoopOneU&
  339.                 CASE 1
  340.                     _CLEARCOLOR _RGB32(255, 255, 255), LoopOneP&
  341.                     _PUTIMAGE (918, 170), LoopOneP&
  342.             END SELECT
  343.     END SELECT
  344.  
  345.  
  346. SUB info 'hodnota inf se priradi pri prvnim spusteni subu info a smaze po jeho opusteni (nastavi se na nulu)
  347.     SHARED i&, inf, afterinfo&, sdeleni&, mov, mox, f&
  348.     IF inf = 1 THEN GOTO block ELSE inf = 1 '                                                    info subprogram started after info icon click
  349.     'text& = _NEWIMAGE(1024, 300, 32)
  350.     RESTORE txt
  351.     sdeleni& = _NEWIMAGE(1024, 300, 32)
  352.     _DEST sdeleni&
  353.     RESTORE txt
  354.     FOR viewtext = 0 TO 27 '28 data linies
  355.         READ r$
  356.         text$(viewtext) = r$
  357.     NEXT
  358.  
  359.     mov = 0
  360.     block:
  361.     _TITLE "QB64 Petr's Player - INFO window"
  362.     LOCATE 1, 1
  363.     SCREEN i&
  364.     ij$ = INKEY$
  365.     DO UNTIL ij$ = CHR$(27)
  366.         SELECT CASE ij$
  367.             CASE CHR$(0) + CHR$(72) 'up
  368.                 mov = mov - 1
  369.                 IF mov < 0 THEN mov = 0
  370.  
  371.  
  372.             CASE CHR$(0) + CHR$(80) 'down
  373.                 mov = mov + 1
  374.                 IF mov > 11 THEN mov = 11 '                                                        11 steps because one screen use 16 linies, data block is long 28 linies, 28 - 16 = 12 - 1 = 11
  375.  
  376.  
  377.         END SELECT
  378.         _DEST sdeleni&
  379.         mox = mov + 16 '                16 rows to one page
  380.         IF mox > 28 THEN mox = 28 '     total linies
  381.         FOR PAGE = mov TO mox
  382.             PRINT RTRIM$(text$(PAGE))
  383.         NEXT
  384.  
  385.  
  386.         _CLEARCOLOR _RGB32(0, 0, 0), sdeleni&
  387.         _SETALPHA 190, , sdeleni&
  388.  
  389.  
  390.         _DEST 0
  391.         '_PUTIMAGE (0, 0), i&, text& 'dokud nestisknes klavesu, tak se vraci rizeni pro i& mimo subu pro klavesnici a mys
  392.         _PUTIMAGE (0, 0), sdeleni&, i&
  393.         _DISPLAY
  394.         ' _DELAY 0.5
  395.         '  _DEST 0
  396.         EXIT SUB
  397.     LOOP
  398.  
  399.     inf = 0 'po stisku klavesy v okne info se vrati rizeni i pro klvesnici a mys a ukonci se sub info
  400.     SCREEN i&
  401.     _PUTIMAGE (0, 0), afterinfo&, i&
  402.     PCOPY _DISPLAY, 1
  403.     '_FREEIMAGE text& '
  404.     _FREEIMAGE sdeleni&
  405.     _TITLE "QB64 Music Player.      By Petr - Petr.Pr@email.cz"
  406.  
  407.  
  408.     txt:
  409.     DATA "                                                                                                                               "
  410.     DATA "                                                                                                                               "
  411.     DATA "About QB Player:                                                                                    USE KEY UP / KEY DOWN / ESC"
  412.     DATA "This open source player writed Petr Preclik. Its use QB64 commands, its based on the _SNDPLAY statement. This is my first ver- "
  413.     DATA "sion in graphic mode. To program:"
  414.     DATA "Is possible program using with mouse or keyboard. Use < or , and > or. for balance, + and - for volume and spacebar for pause"
  415.     DATA "Esc to quit program, enter for song time selecting. N, n for next song in selected directory, P, p for previous song."
  416.     DATA "With mouse is possible using LOOP one or LOOP all songs, play, stop, pause, next, previous, to time select click to song time"
  417.     DATA "display. Two icons are for LOOP / LOOP all (songs in selected dir). "
  418.     DATA "Files for this program: QBPlay.EXE, SKINDb.PNG, Demo.MP3. All used pictures are in the one PNG file, all pictures used in this"
  419.     DATA "PNG file from www.eu.fotolia.com. Program read none ID3, is without equalizer and without vizualization. Is possible, next ver-"
  420.     DATA "sion this already to have. For ID3TAG - See to http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=14111.msg122204#msg122204,i wrote it"
  421.     DATA "but in this version is unimplemented. In the end this program is comming monkey."
  422.     DATA "QB64 users info:"
  423.     DATA "SUB Rodent / mouse coordination with program. Is off if this info is view,"
  424.     DATA "SUB WindowsFileOpenSystem / two QB64 WIKI sources in one SUB, returning path to directory in 8.3 format,"
  425.     DATA "SUB The End - monkeys and memory cleaning sub if program get out,"
  426.     DATA "SUB timing - yes. It calculate time. If is runned as timing TIMER, calculate current time from TIMER,"
  427.     DATA "SUBS ViewVolume, ViewFrequency, ViewVolumeLevel... the same _PUTIMAGE subs. Many coordinates...."
  428.     DATA "SUB rest - reset sound playng if error is comming, because _SNDPLAY generate none errors, is possible if uncompatible file is "
  429.     DATA " loaded,"
  430.     DATA "SUB hraj - its heart. This sub plays music."
  431.     DATA "SUB nacti.b - this sub is my FIRST, this load files with mask filtering to memory (old version was not here used named nacti.A"
  432.     DATA "reads it direct from harddrive), this sub is writed 14 days before i have found windows library file system..."
  433.     DATA "SUB cj - for Czech text correct readable by SUB znak and the to correct displayed"
  434.     DATA "SUB RAP - call other SUBS, because this sub is as graphic central, it displayed song name in the program"
  435.     DATA "SUB znak - First write to unvisible screen song name. Then with POINT is this scaning and every point is with LINE drawing to"
  436.     DATA "other unvisible screen. View this is then used as song name in program.                                    Happy coding! Petr"
  437.     DATA " And now.... i need 2D game in the Commander Keen style to write..."
  438.  
  439.  
  440.  
  441. SUB WindowsFileOpenSystem
  442.     SHARED reload, zvuk&, Lb, akt, stopp, rndpl
  443.  
  444.     wfos:
  445.         FUNCTION FindWindow&& (BYVAL ClassName AS _OFFSET, WindowName$)
  446.     END DECLARE
  447.  
  448.     '_TITLE "Super Window"
  449.     hwnd&& = FindWindow(0, "QB64 Music Player.      By Petr - Petr.Pr@email.cz" + CHR$(0))
  450.  
  451.     TYPE BROWSEINFO 'typedef struct _browseinfo 'Microsoft MSDN http://msdn.microsoft.com/en-us/library/bb773205%28v=vs.85%29.aspx
  452.         hwndOwner AS _INTEGER64 '              '  HWND
  453.         pidlRoot AS _OFFSET '            '  PCIDLIST_ABSOLUTE
  454.         pszDisplayName AS _OFFSET '      '  LPTSTR
  455.         lpszTitle AS _OFFSET '           '  LPCTSTR
  456.         ulFlags AS _UNSIGNED LONG '  UINT
  457.         lpfn AS _OFFSET '                '  BFFCALLBACK
  458.         lParam AS _OFFSET '              '  LPARAM
  459.         iImage AS LONG '                 '  int
  460.     END TYPE 'BROWSEINFO, *PBROWSEINFO, *LPBROWSEINFO;
  461.  
  462.     DECLARE DYNAMIC LIBRARY "shell32"
  463.         FUNCTION SHBrowseForFolder%& (x AS BROWSEINFO) 'Microsoft MSDN http://msdn.microsoft.com/en-us/library/bb762115%28v=vs.85%29.aspx
  464.         SUB SHGetPathFromIDList (BYVAL lpItem AS _OFFSET, BYVAL szDir AS _OFFSET) 'Microsoft MSDN http://msdn.microsoft.com/en-us/library/bb762194%28VS.85%29.aspx
  465.     END DECLARE
  466.  
  467.     DIM b AS BROWSEINFO
  468.     b.hwndOwner = hwnd
  469.     DIM s AS STRING * 1024
  470.     b.pszDisplayName = _OFFSET(s$)
  471.     a$ = "" + CHR$(0)
  472.     b.lpszTitle = _OFFSET(a$)
  473.     DIM o AS _OFFSET
  474.     o = SHBrowseForFolder(b)
  475.     IF o THEN
  476.         ' PRINT LEFT$(s$, INSTR(s$, CHR$(0)) - 1)
  477.         DIM s2 AS STRING * 1024
  478.         SHGetPathFromIDList o, _OFFSET(s2$)
  479.         FolderLong$ = LEFT$(s2$, INSTR(s2$, CHR$(0)) - 1)
  480.  
  481.         'this function make 8.3 worlwide full compatible format to correct acces to folder with no - english chars!:
  482.         DECLARE LIBRARY 'Directory Information using KERNEL32
  483.             FUNCTION GetShortPathNameA (lpLongPath AS STRING, lpShortPath AS STRING, BYVAL cBufferLen AS LONG)
  484.         END DECLARE
  485.  
  486.         '=== SHOW SHORT PATH NAME
  487.         FileOrPath$ = FolderLong$ '<< change to a relevant path or file name on computer
  488.         ShortPathName$ = SPACE$(260)
  489.         Result = GetShortPathNameA(FileOrPath$ + CHR$(0), ShortPathName$, LEN(ShortPathName$))
  490.         Folder$ = ShortPathName$
  491.  
  492.         'end of 8.3 function
  493.  
  494.     ELSE
  495.         EXIT SUB
  496.     END IF
  497.  
  498.     '    IF Folder$ = "" THEN EXIT SUB
  499.     _SNDSTOP (zvuk&)
  500.     _DELAY 0.5
  501.     IF Folder$ = "" THEN GOTO wfos
  502.     IF _DIREXISTS(Folder$) = 0 THEN GOTO wfos
  503.     CHDIR Folder$
  504.     mousex = 0: mousey = 0: Lb = 0
  505.     '    IF stopp = 1 THEN stopp = 0
  506.  
  507.  
  508.  
  509.  
  510.  
  511. SUB TheEnd
  512.     SHARED zvuk&, i&, new&, obraz&, f&, GreenButtonPlay&, GreenButtonStop&, j&, d&, GreenButtonPower&, GreenButtonBack&, GreenButtonPause&, GreenButtonNext&, VolumePlus&, VolumeMinus&, ImageOpenFiles&, resicon&, infoicon&, LoopOne&, loopall&, afterinfo&
  513.     _SNDSTOP (zvuk&)
  514.     IF VAL(LEFT$(TIME$, 3)) > 12 THEN GOSUB opic1 ELSE GOSUB opic2
  515.     b& = _RGB32(255, 255, 255)
  516.     _DEST i&
  517.     CLS
  518.     PCOPY 1, _DISPLAY
  519.     FOR krok = 1024 TO -1024 STEP -1
  520.         hovno = hovno + .2: IF hovno >= 255 THEN hovno = 255
  521.         visible = 255 - hovno
  522.         _SETALPHA visible, b&, obraz&
  523.         _PUTIMAGE (krok, 15), obraz&, i&
  524.         _DISPLAY
  525.         PCOPY 1, _DISPLAY
  526.     NEXT
  527.     'blok _FREE
  528.     SCREEN 0
  529.     _DEST 0
  530.     _FREEFONT f&
  531.     _FREEIMAGE GreenButtonPlay&
  532.     _FREEIMAGE GreenButtonStop&
  533.     _FREEIMAGE new&
  534.     _FREEIMAGE j&
  535.     _FREEIMAGE d&
  536.     _FREEIMAGE GreenButtonPower&
  537.     _FREEIMAGE GreenButtonBack&
  538.     _FREEIMAGE GreenButtonPause&
  539.     _FREEIMAGE GreenButtonNext&
  540.     _FREEIMAGE VolumePlus&
  541.     _FREEIMAGE VolumeMinus&
  542.     _FREEIMAGE ImageOpenFiles&
  543.     _FREEIMAGE resicon&
  544.     _FREEIMAGE obraz&
  545.     _FREEIMAGE i&
  546.     _FREEIMAGE infoicon&
  547.     '    _FREEIMAGE LoopOneU&
  548.     '   _FREEIMAGE LoopAllU&
  549.     '  _FREEIMAGE LoopOneP&
  550.     ' _FREEIMAGE LoopAllP&
  551.     _FREEIMAGE afterinfo&
  552.     _SNDCLOSE zvuk&
  553.     SYSTEM
  554.     opic1:
  555.     obraz& = _NEWIMAGE(252, 241, 32)
  556.     _PUTIMAGE (0, 0), new&, obraz&, (6, 410)-(260, 650)
  557.     RETURN
  558.     opic2:
  559.     obraz& = _NEWIMAGE(228, 246, 32)
  560.     _PUTIMAGE (0, 0), new&, obraz&, (273, 405)-(500, 650)
  561.     RETURN
  562.  
  563. SUB timing (hodnota AS DOUBLE) '                calculate time. Writed for Timer, _SndLen. Input format as TIMER or _SNDLEN WITH "."
  564.     SHARED hodin, minut, sekund, sets
  565.     IF hodnota < 60 THEN hodin = 0: minut = 0: sekund = hodnota: GOTO a1
  566.     IF hodnota > 60 AND hodnota < 3600 THEN hodin = 0: minut = hodnota / 60: GOTO a2
  567.     hodin = hodnota / 3600
  568.     hodin$ = STR$(hodin)
  569.     tecka = INSTR(0, hodin$, ".")
  570.     minut = (VAL("0." + RIGHT$(hodin$, LEN(hodin$) - tecka)) * 0.6) * 100
  571.     a2:
  572.     minut$ = STR$(minut)
  573.     tecka = INSTR(0, STR$(minut), ".")
  574.     sekund = (VAL("0." + RIGHT$(minut$, LEN(minut$) - tecka)) * 0.6) * 100
  575.     a1:
  576.     sekund$ = STR$(sekund)
  577.     tecka = INSTR(0, sekund$, ".")
  578.     sets = (VAL("0." + RIGHT$(sekund$, LEN(sekund$) - tecka)) * 1) * 100
  579.  
  580.  
  581. SUB ViewSongTime (Viewtype AS INTEGER)
  582.     SHARED zvuk&, oldsec!, d&, i&, MouseX, MouseY, Lb, sec, sekunda, minuta, mi, se, se2, hodin, minut, sekund, sets
  583.  
  584.     IF Viewtype = 1 THEN timing (_SNDLEN(zvuk&) - _SNDGETPOS(zvuk&)) ELSE timing _SNDGETPOS(zvuk&)
  585.     minuta = INT(minut)
  586.     sekunda = INT(sekund)
  587.     IF sekunda = 60 THEN sekunda = 0
  588.     set = INT(sets)
  589.  
  590.     IF set < 10 THEN set0 = 0 ELSE set0 = VAL(LEFT$(MID$(STR$(set), 2), 1))
  591.     IF set < 10 THEN set1 = VAL(RIGHT$(STR$(set), 1))
  592.     IF set > 10 THEN set1 = VAL(RIGHT$(STR$(set), 1))
  593.  
  594.     stp = 470: sty = -175
  595.  
  596.     SELECT CASE set1
  597.  
  598.         CASE 0
  599.             _PUTIMAGE (426 + stp, 230 + sty), d&, i&, (285, 0)-(320, 47)
  600.  
  601.         CASE 1
  602.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (1, 0)-(33, 47)
  603.  
  604.         CASE 2
  605.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (30, 0)-(57, 47)
  606.  
  607.         CASE 3
  608.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (64, 0)-(95, 47)
  609.  
  610.         CASE 4
  611.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (95, 0)-(120, 47)
  612.  
  613.         CASE 5
  614.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (130, 0)-(154, 47)
  615.  
  616.         CASE 6
  617.             _PUTIMAGE (424 + stp, 230 + sty), d&, i&, (156, 0)-(185, 47)
  618.  
  619.         CASE 7
  620.             _PUTIMAGE (424 + stp, 230 + sty), d&, i&, (190, 0)-(217, 47)
  621.  
  622.         CASE 8
  623.             _PUTIMAGE (426 + stp, 230 + sty), d&, i&, (225, 0)-(250, 47)
  624.  
  625.         CASE 9
  626.             _PUTIMAGE (432 + stp, 230 + sty), d&, i&, (260, 0)-(286, 47)
  627.  
  628.     END SELECT
  629.  
  630.     stp = 440: sty = -175
  631.  
  632.     SELECT CASE set0
  633.  
  634.         CASE 0
  635.             _PUTIMAGE (426 + stp, 230 + sty), d&, i&, (285, 0)-(320, 47)
  636.  
  637.         CASE 1
  638.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (1, 0)-(33, 47)
  639.  
  640.         CASE 2
  641.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (30, 0)-(57, 47)
  642.  
  643.         CASE 3
  644.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (64, 0)-(95, 47)
  645.  
  646.         CASE 4
  647.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (95, 0)-(120, 47)
  648.  
  649.         CASE 5
  650.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (130, 0)-(154, 47)
  651.  
  652.         CASE 6
  653.             _PUTIMAGE (424 + stp, 230 + sty), d&, i&, (156, 0)-(185, 47)
  654.  
  655.         CASE 7
  656.             _PUTIMAGE (424 + stp, 230 + sty), d&, i&, (190, 0)-(217, 47)
  657.  
  658.         CASE 8
  659.             _PUTIMAGE (426 + stp, 230 + sty), d&, i&, (225, 0)-(250, 47)
  660.  
  661.         CASE 9
  662.             _PUTIMAGE (432 + stp, 230 + sty), d&, i&, (260, 0)-(286, 47)
  663.  
  664.     END SELECT
  665.  
  666.  
  667.     IF sekunda < 10 THEN sekunda0 = 0 ELSE sekunda0 = VAL(LEFT$(MID$(STR$(sekunda), 2), 1))
  668.     IF sekunda < 10 THEN sekunda1 = VAL(RIGHT$(STR$(sekunda), 1))
  669.     IF sekunda > 10 THEN sekunda1 = VAL(RIGHT$(STR$(sekunda), 1))
  670.  
  671.     stp = 370: sty = -175
  672.  
  673.     SELECT CASE sekunda0
  674.  
  675.         CASE 0
  676.             _PUTIMAGE (426 + stp, 230 + sty), d&, i&, (285, 0)-(320, 47)
  677.  
  678.         CASE 1
  679.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (1, 0)-(33, 47)
  680.  
  681.         CASE 2
  682.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (30, 0)-(57, 47)
  683.  
  684.         CASE 3
  685.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (64, 0)-(95, 47)
  686.  
  687.         CASE 4
  688.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (95, 0)-(120, 47)
  689.  
  690.         CASE 5
  691.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (130, 0)-(154, 47)
  692.  
  693.         CASE 6
  694.             _PUTIMAGE (424 + stp, 230 + sty), d&, i&, (156, 0)-(185, 47)
  695.  
  696.         CASE 7
  697.             _PUTIMAGE (424 + stp, 230 + sty), d&, i&, (190, 0)-(217, 47)
  698.  
  699.         CASE 8
  700.             _PUTIMAGE (426 + stp, 230 + sty), d&, i&, (225, 0)-(250, 47)
  701.  
  702.         CASE 9
  703.             _PUTIMAGE (432 + stp, 230 + sty), d&, i&, (260, 0)-(286, 47)
  704.  
  705.     END SELECT
  706.  
  707.     stp = 400: sty = -175
  708.  
  709.     SELECT CASE sekunda1
  710.  
  711.         CASE 0
  712.             _PUTIMAGE (426 + stp, 230 + sty), d&, i&, (285, 0)-(320, 47)
  713.  
  714.         CASE 1
  715.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (1, 0)-(33, 47)
  716.  
  717.         CASE 2
  718.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (30, 0)-(57, 47)
  719.  
  720.         CASE 3
  721.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (64, 0)-(95, 47)
  722.  
  723.         CASE 4
  724.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (95, 0)-(120, 47)
  725.  
  726.         CASE 5
  727.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (130, 0)-(154, 47)
  728.  
  729.         CASE 6
  730.             _PUTIMAGE (424 + stp, 230 + sty), d&, i&, (156, 0)-(185, 47)
  731.  
  732.         CASE 7
  733.             _PUTIMAGE (424 + stp, 230 + sty), d&, i&, (190, 0)-(217, 47)
  734.  
  735.         CASE 8
  736.             _PUTIMAGE (426 + stp, 230 + sty), d&, i&, (225, 0)-(250, 47)
  737.  
  738.         CASE 9
  739.             _PUTIMAGE (432 + stp, 230 + sty), d&, i&, (260, 0)-(286, 47)
  740.  
  741.     END SELECT
  742.  
  743.     '    minuta = 20
  744.  
  745.     IF minuta < 10 THEN minuta0 = 0 ELSE minuta0 = VAL(LEFT$(MID$(STR$(minuta), 2), 1))
  746.     IF minuta < 10 THEN minuta1 = minuta 'VAL(RIGHT$(STR$(minuta), 1))
  747.     IF minuta >= 10 THEN minuta1 = VAL(RIGHT$(STR$(minuta), 1))
  748.     '    IF sec < 60 AND minuta < 1 THEN minuta = 0
  749.  
  750.     stp = 300: sty = -175
  751.  
  752.     SELECT CASE minuta0
  753.  
  754.         CASE 0 TO 0.99
  755.             _PUTIMAGE (426 + stp, 230 + sty), d&, i&, (285, 0)-(320, 47)
  756.  
  757.         CASE 1 TO 1.99
  758.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (1, 0)-(33, 47)
  759.  
  760.         CASE 2 TO 2.99
  761.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (30, 0)-(57, 47)
  762.  
  763.         CASE 3 TO 3.99
  764.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (64, 0)-(95, 47)
  765.  
  766.         CASE 4 TO 4.99
  767.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (95, 0)-(120, 47)
  768.  
  769.         CASE 5 TO 5.99
  770.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (130, 0)-(154, 47)
  771.  
  772.         CASE 6 TO 6.99
  773.             _PUTIMAGE (424 + stp, 230 + sty), d&, i&, (156, 0)-(185, 47)
  774.  
  775.         CASE 7 TO 7.99
  776.             _PUTIMAGE (424 + stp, 230 + sty), d&, i&, (190, 0)-(217, 47)
  777.  
  778.         CASE 8 TO 8.99
  779.             _PUTIMAGE (426 + stp, 230 + sty), d&, i&, (225, 0)-(250, 47)
  780.  
  781.         CASE 9 TO 9.99
  782.             _PUTIMAGE (432 + stp, 230 + sty), d&, i&, (260, 0)-(286, 47)
  783.  
  784.     END SELECT
  785.  
  786.     stp = 330: sty = -175
  787.  
  788.     SELECT CASE minuta1
  789.  
  790.         CASE 0 TO 0.99
  791.             _PUTIMAGE (426 + stp, 230 + sty), d&, i&, (285, 0)-(320, 47)
  792.  
  793.         CASE 1 TO 1.99
  794.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (1, 0)-(33, 47)
  795.  
  796.         CASE 2 TO 2.99
  797.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (30, 0)-(57, 47)
  798.  
  799.         CASE 3 TO 3.99
  800.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (64, 0)-(95, 47)
  801.  
  802.         CASE 4 TO 4.99
  803.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (95, 0)-(120, 47)
  804.  
  805.         CASE 5 TO 5.99
  806.             _PUTIMAGE (430 + stp, 230 + sty), d&, i&, (130, 0)-(154, 47)
  807.  
  808.         CASE 6 TO 6.99
  809.             _PUTIMAGE (424 + stp, 230 + sty), d&, i&, (156, 0)-(185, 47)
  810.  
  811.         CASE 7 TO 7.99
  812.             _PUTIMAGE (424 + stp, 230 + sty), d&, i&, (190, 0)-(217, 47)
  813.  
  814.         CASE 8 TO 8.99
  815.             _PUTIMAGE (426 + stp, 230 + sty), d&, i&, (225, 0)-(250, 47)
  816.  
  817.         CASE 9 TO 9.99
  818.             _PUTIMAGE (432 + stp, 230 + sty), d&, i&, (260, 0)-(286, 47)
  819.  
  820.     END SELECT
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842. SUB ViewFrequency
  843.     SHARED d&, i&
  844.     s = _SNDRATE
  845.     '    s = 25864
  846.     'use 5 chracters to view frequency
  847.     Ach = VAL(LEFT$(STR$(s), 2))
  848.     Bch = VAL(LEFT$(MID$(STR$(s), 3), 1))
  849.     Cch = VAL(LEFT$(MID$(STR$(s), 4), 1))
  850.     Dch = VAL(LEFT$(MID$(STR$(s), 5), 1))
  851.     Ech = VAL(LEFT$(MID$(STR$(s), 6), 1))
  852.  
  853.     '    COLOR _RGB32(255, 255, 255): PRINT Ach, Bch, Cch, Dch, Ech   'ALL pass
  854.     stp = 165
  855.  
  856.     SELECT CASE Ach
  857.  
  858.  
  859.         CASE 0
  860.             _PUTIMAGE (426 + stp, 230), d&, i&, (285, 0)-(320, 47)
  861.  
  862.         CASE 1
  863.             _PUTIMAGE (430 + stp, 230), d&, i&, (1, 0)-(33, 47)
  864.  
  865.         CASE 2
  866.             _PUTIMAGE (430 + stp, 230), d&, i&, (30, 0)-(57, 47)
  867.  
  868.         CASE 3
  869.             _PUTIMAGE (430 + stp, 230), d&, i&, (64, 0)-(95, 47)
  870.  
  871.         CASE 4
  872.             _PUTIMAGE (430 + stp, 230), d&, i&, (95, 0)-(120, 47)
  873.  
  874.         CASE 5
  875.             _PUTIMAGE (430 + stp, 230), d&, i&, (130, 0)-(154, 47)
  876.  
  877.         CASE 6
  878.             _PUTIMAGE (424 + stp, 230), d&, i&, (156, 0)-(185, 47)
  879.  
  880.         CASE 7
  881.             _PUTIMAGE (424 + stp, 230), d&, i&, (190, 0)-(217, 47)
  882.  
  883.         CASE 8
  884.             _PUTIMAGE (426 + stp, 230), d&, i&, (225, 0)-(250, 47)
  885.  
  886.         CASE 9
  887.             _PUTIMAGE (427 + stp, 230), d&, i&, (260, 0)-(286, 47)
  888.  
  889.     END SELECT
  890.  
  891.     stp = 190
  892.  
  893.     SELECT CASE Bch
  894.  
  895.         CASE 0
  896.             _PUTIMAGE (426 + stp, 230), d&, i&, (285, 0)-(320, 47)
  897.  
  898.         CASE 1
  899.             _PUTIMAGE (430 + stp, 230), d&, i&, (1, 0)-(33, 47)
  900.  
  901.         CASE 2
  902.             _PUTIMAGE (430 + stp, 230), d&, i&, (30, 0)-(57, 47)
  903.  
  904.         CASE 3
  905.             _PUTIMAGE (430 + stp, 230), d&, i&, (64, 0)-(95, 47)
  906.  
  907.         CASE 4
  908.             _PUTIMAGE (430 + stp, 230), d&, i&, (95, 0)-(120, 47)
  909.  
  910.         CASE 5
  911.             _PUTIMAGE (430 + stp, 230), d&, i&, (130, 0)-(154, 47)
  912.  
  913.         CASE 6
  914.             _PUTIMAGE (424 + stp, 230), d&, i&, (156, 0)-(185, 47)
  915.  
  916.         CASE 7
  917.             _PUTIMAGE (424 + stp, 230), d&, i&, (190, 0)-(217, 47)
  918.  
  919.         CASE 8
  920.             _PUTIMAGE (426 + stp, 230), d&, i&, (225, 0)-(250, 47)
  921.  
  922.         CASE 9
  923.             _PUTIMAGE (427 + stp, 230), d&, i&, (260, 0)-(286, 47)
  924.  
  925.  
  926.  
  927.     END SELECT
  928.  
  929.     stp = 215
  930.  
  931.     SELECT CASE Cch
  932.  
  933.         CASE 0
  934.             _PUTIMAGE (426 + stp, 230), d&, i&, (285, 0)-(320, 47)
  935.  
  936.         CASE 1
  937.             _PUTIMAGE (430 + stp, 230), d&, i&, (1, 0)-(33, 47)
  938.  
  939.         CASE 2
  940.             _PUTIMAGE (430 + stp, 230), d&, i&, (30, 0)-(57, 47)
  941.  
  942.         CASE 3
  943.             _PUTIMAGE (430 + stp, 230), d&, i&, (64, 0)-(95, 47)
  944.  
  945.         CASE 4
  946.             _PUTIMAGE (430 + stp, 230), d&, i&, (95, 0)-(120, 47)
  947.  
  948.         CASE 5
  949.             _PUTIMAGE (430 + stp, 230), d&, i&, (130, 0)-(154, 47)
  950.  
  951.         CASE 6
  952.             _PUTIMAGE (424 + stp, 230), d&, i&, (156, 0)-(185, 47)
  953.  
  954.         CASE 7
  955.             _PUTIMAGE (424 + stp, 230), d&, i&, (190, 0)-(217, 47)
  956.  
  957.         CASE 8
  958.             _PUTIMAGE (426 + stp, 230), d&, i&, (225, 0)-(250, 47)
  959.  
  960.         CASE 9
  961.             _PUTIMAGE (427 + stp, 230), d&, i&, (260, 0)-(286, 47)
  962.  
  963.     END SELECT
  964.  
  965.     stp = 240
  966.  
  967.     SELECT CASE Dch
  968.  
  969.         CASE 0
  970.             _PUTIMAGE (426 + stp, 230), d&, i&, (285, 0)-(320, 47)
  971.  
  972.         CASE 1
  973.             _PUTIMAGE (430 + stp, 230), d&, i&, (1, 0)-(33, 47)
  974.  
  975.         CASE 2
  976.             _PUTIMAGE (430 + stp, 230), d&, i&, (30, 0)-(57, 47)
  977.  
  978.         CASE 3
  979.             _PUTIMAGE (430 + stp, 230), d&, i&, (64, 0)-(95, 47)
  980.  
  981.         CASE 4
  982.             _PUTIMAGE (430 + stp, 230), d&, i&, (95, 0)-(120, 47)
  983.  
  984.         CASE 5
  985.             _PUTIMAGE (430 + stp, 230), d&, i&, (130, 0)-(154, 47)
  986.  
  987.         CASE 6
  988.             _PUTIMAGE (424 + stp, 230), d&, i&, (156, 0)-(185, 47)
  989.  
  990.         CASE 7
  991.             _PUTIMAGE (424 + stp, 230), d&, i&, (190, 0)-(217, 47)
  992.  
  993.         CASE 8
  994.             _PUTIMAGE (426 + stp, 230), d&, i&, (225, 0)-(250, 47)
  995.  
  996.         CASE 9
  997.             _PUTIMAGE (427 + stp, 230), d&, i&, (260, 0)-(286, 47)
  998.  
  999.     END SELECT
  1000.  
  1001.     stp = 265
  1002.  
  1003.     SELECT CASE Ech
  1004.  
  1005.         CASE 0
  1006.             _PUTIMAGE (426 + stp, 230), d&, i&, (285, 0)-(320, 47)
  1007.  
  1008.         CASE 1
  1009.             _PUTIMAGE (430 + stp, 230), d&, i&, (1, 0)-(33, 47)
  1010.  
  1011.         CASE 2
  1012.             _PUTIMAGE (430 + stp, 230), d&, i&, (30, 0)-(57, 47)
  1013.  
  1014.         CASE 3
  1015.             _PUTIMAGE (430 + stp, 230), d&, i&, (64, 0)-(95, 47)
  1016.  
  1017.         CASE 4
  1018.             _PUTIMAGE (430 + stp, 230), d&, i&, (95, 0)-(120, 47)
  1019.  
  1020.         CASE 5
  1021.             _PUTIMAGE (430 + stp, 230), d&, i&, (130, 0)-(154, 47)
  1022.  
  1023.         CASE 6
  1024.             _PUTIMAGE (424 + stp, 230), d&, i&, (156, 0)-(185, 47)
  1025.  
  1026.         CASE 7
  1027.             _PUTIMAGE (424 + stp, 230), d&, i&, (190, 0)-(217, 47)
  1028.  
  1029.         CASE 8
  1030.             _PUTIMAGE (426 + stp, 230), d&, i&, (225, 0)-(250, 47)
  1031.  
  1032.         CASE 9
  1033.             _PUTIMAGE (427 + stp, 230), d&, i&, (260, 0)-(286, 47)
  1034.  
  1035.     END SELECT
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045. SUB ViewBalanceLevel (channel AS DOUBLE)
  1046.     SHARED d&, i&, ch#
  1047.     '                                    Left Speaker --------#--------  Right Speaker       - usable with mouse to left or right speaker or keyboard "<" and  ","  or ">" and "." Full funcionality only
  1048.     '                                                -100 to  0  to 100                        with WAV files.
  1049.     REM    lvl& = _NEWIMAGE(150, 150, 32)
  1050.     _PUTIMAGE (400, 150), d&, i&, (321, 0)-(392, 65)
  1051.     _PUTIMAGE (590, 150), d&, i&, (321, 0)-(392, 65)
  1052.  
  1053.     LINE (480, 185)-(580, 185), _RGB32(0, 0, 0)
  1054.     LINE (525 - (channel# * 50), 175)-(535 - (channel# * 50), 195), _RGB32(20, 40, 20), BF
  1055.     '    COLOR _RGB32(255, 255, 255): PRINT  'ok, funguje s double
  1056.     REM  _FREEIMAGE lvl&
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067. SUB ViewVolumeLevel
  1068.     SHARED Vol, d&, i&
  1069.     bila& = _RGB32(255, 255, 255)
  1070.     bila2& = _RGB32(215, 215, 215)
  1071.     _SETALPHA 0, bila& TO bila2&, d&
  1072.  
  1073.     Volume = CINT(Vol * 100)
  1074.     '    Volume = 256
  1075.     IF LEN(STR$(Volume)) = 4 THEN fv = 1 ELSE fv = 0
  1076.     IF LEN(Volume) >= 2 THEN sv = VAL(LEFT$(RIGHT$(STR$(Volume), LEN(Volume) - 2), LEN(Volume) - 3)) ELSE sv = 0 'stale druha pozice i pri vol = 56
  1077.     Tv = VAL(RIGHT$(STR$(Volume), 1))
  1078.     '   firstV$ = "1"
  1079.     '  _DEST i&
  1080.     ' COLOR bila&
  1081.     '    CLS
  1082.     '   PRINT sv, 'STR$(Volume)
  1083.     '    SLEEP
  1084.     'fv = 0
  1085.  
  1086.     SELECT CASE fv 'first character Volume. Its 0 or 1 --------------------------  vloz to do noveho pole& a tam trochu zpruhledni ty bily segmenty a teprve pak to vloz do i&
  1087.  
  1088.         CASE 0
  1089.             'load null to view
  1090.             _PUTIMAGE (392, 230), d&, i&, (285, 0)-(320, 45)
  1091.  
  1092.         CASE 1
  1093.             'load one to view
  1094.             _PUTIMAGE (400, 230), d&, i&, (1, 0)-(23, 47)
  1095.  
  1096.  
  1097.     END SELECT
  1098.     'COLOR _RGB32(255, 255, 255): PRINT Tv ', LEN(STR$(Volume)) ' overeno, ze sv ukazuje spravne cislo, overeno a spraveno FV!, overena spravna hodnota Tv  - here i tested it
  1099.     'multipl = (23 * sv) + 10
  1100.     SELECT CASE sv 'second volume character. 0 - 9
  1101.         CASE 0
  1102.             _PUTIMAGE (426, 230), d&, i&, (285, 0)-(320, 47)
  1103.  
  1104.         CASE 1
  1105.             _PUTIMAGE (430, 230), d&, i&, (1, 0)-(33, 47)
  1106.  
  1107.         CASE 2
  1108.             _PUTIMAGE (430, 230), d&, i&, (30, 0)-(57, 47)
  1109.  
  1110.         CASE 3
  1111.             _PUTIMAGE (430, 230), d&, i&, (64, 0)-(95, 47)
  1112.  
  1113.         CASE 4
  1114.             _PUTIMAGE (430, 230), d&, i&, (95, 0)-(120, 47)
  1115.  
  1116.         CASE 5
  1117.             _PUTIMAGE (430, 230), d&, i&, (130, 0)-(154, 47)
  1118.  
  1119.         CASE 6
  1120.             _PUTIMAGE (424, 230), d&, i&, (156, 0)-(185, 47)
  1121.  
  1122.         CASE 7
  1123.             _PUTIMAGE (424, 230), d&, i&, (190, 0)-(217, 47)
  1124.  
  1125.         CASE 8
  1126.             _PUTIMAGE (426, 230), d&, i&, (225, 0)-(250, 47)
  1127.  
  1128.         CASE 9
  1129.             _PUTIMAGE (422, 230), d&, i&, (252, 0)-(286, 47)
  1130.  
  1131.     END SELECT
  1132.  
  1133.     stp = 30
  1134.  
  1135.     SELECT CASE Tv 'third volume character. 0 - 9
  1136.  
  1137.         CASE 0
  1138.             _PUTIMAGE (426 + stp, 230), d&, i&, (285, 0)-(320, 47)
  1139.  
  1140.         CASE 1
  1141.             _PUTIMAGE (430 + stp, 230), d&, i&, (1, 0)-(33, 47)
  1142.  
  1143.         CASE 2
  1144.             _PUTIMAGE (430 + stp, 230), d&, i&, (30, 0)-(57, 47)
  1145.  
  1146.         CASE 3
  1147.             _PUTIMAGE (430 + stp, 230), d&, i&, (64, 0)-(95, 47)
  1148.  
  1149.         CASE 4
  1150.             _PUTIMAGE (430 + stp, 230), d&, i&, (95, 0)-(120, 47)
  1151.  
  1152.         CASE 5
  1153.             _PUTIMAGE (430 + stp, 230), d&, i&, (130, 0)-(154, 47)
  1154.  
  1155.         CASE 6
  1156.             _PUTIMAGE (424 + stp, 230), d&, i&, (156, 0)-(185, 47)
  1157.  
  1158.         CASE 7
  1159.             _PUTIMAGE (424 + stp, 230), d&, i&, (190, 0)-(217, 47)
  1160.  
  1161.         CASE 8
  1162.             _PUTIMAGE (426 + stp, 230), d&, i&, (225, 0)-(250, 47)
  1163.  
  1164.         CASE 9
  1165.             _PUTIMAGE (427 + stp, 230), d&, i&, (260, 0)-(286, 47)
  1166.  
  1167.     END SELECT
  1168.  
  1169. SUB rest
  1170.     SHARED akt, pokus
  1171.     ' BEEP
  1172.     '  WindowsFileOpenSystem
  1173.     IF PlEr = 1 THEN PlEr = 0: BEEP: WindowsFileOpenSystem
  1174.     pokus = pokus + 1
  1175.     akt = 0 + pokus - 1
  1176.     nacti.b
  1177.     reload = 1
  1178.     RAP "StartDemo"
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185. SUB hraj (plaj AS STRING)
  1186.     IF plaj$ = "" THEN EXIT SUB
  1187.     IF PlEr = 1 THEN EXIT SUB
  1188.     SHARED zvuk&, hraju, ch#, Vol, reload, PlEr
  1189.     IF _SNDPLAYING(zvuk&) = -1 THEN PRINT "Sorry, now playing": EXIT SUB ELSE _SNDCLOSE (zvuk&) '    This is music program hearth.
  1190.     zvuk& = _SNDOPEN(plaj$, "VOL, PAUSE, SETPOS, SYNC, LEN"): ' oldzvuk& = _SNDCOPY(zvuk&)
  1191.     IF zvuk& > 0 THEN PRINT "" ELSE PRINT "File not ready - "; file$; "or uncompatible!": rest
  1192.     hraju = 1
  1193.     '    _SNDBAL zvuk&, ch# * 1000 'i have here not enought place for 5.1 / 7.1 speakers. :-D
  1194.     _SNDVOL zvuk&, Vol '  _SNDBAL funcionality is correct only with garanteed file types.
  1195.     _SNDPLAY zvuk&
  1196.     IF _SNDPLAYING(zvuk&) = 0 THEN _SNDPLAY (zvuk&)
  1197.  
  1198. SUB nacti.b
  1199.     SHARED seznam2$, NewRecNr, linka, max, reload: RESTORE FileMask
  1200.     seznam2$ = "": NewRecNr = 0: linka = 0: max = 0: reload = 0
  1201.     'nacte a vyfiltruje soubory do poli Rfiles a Vfiles (Read and open files a Viewed as files)
  1202.  
  1203.     comm$ = "dir *.* /x > filelist.qb64" '                                            vylistuje vsechny soubory ve slozce  8.3 a LONG / DIR make file filelist.qb64 with old type and new type file names
  1204.     SHELL _HIDE comm$
  1205.     IF _FILEEXISTS("filelist.qb64") = 0 THEN _DEST 0: PRINT "Error on line 1264: File list not created!": EXIT SUB 'chybu odchyti funkce plaj vypisem varovani
  1206.     OPEN "filelist.qb64" FOR INPUT AS #1
  1207.     zacatek:
  1208.     IF EOF(1) THEN GOTO konec
  1209.     LINE INPUT #1, nothing$ '                                                        This read rows from DIR outputfile and load its to memory. Its better for harddrive, for SSD extra!
  1210.     linies = linies + 1
  1211.     'PRINT linies
  1212.     seznam2$(linies) = nothing$
  1213.     GOTO zacatek
  1214.     konec:
  1215.     CLOSE #1
  1216.     KILL "filelist.qb64"
  1217.     'PRINT "Transformuji Seznam na pole U a V (usable a visible)"
  1218.     '    IF linies = 0 THEN _DEST 0: PRINT "No files for play.(line 1276)": BEEP: EXIT SUB
  1219.     FOR test = 0 TO linies '                                                       This For...Next read array seznam and make two new arrays: Vfiles and Ufiles. Ussable for us is record from row 7 to row
  1220.         '    PRINT seznam$(test); " = record nr. "; test '                              linies - 3
  1221.         text = text + 1
  1222.         ' IF text > 6 AND text < linies - 3 THEN             vyrazeno verzi 0.21C - necetl vsechny mozne soubory.
  1223.  
  1224.         VFiles$(test) = RIGHT$(seznam2$(test), LEN(seznam2$(test)) - 49)
  1225.         UFiles$(test) = RIGHT$(LEFT$(seznam2$(test), 49), 13)
  1226.         IF VFiles$(test) <> "" AND LTRIM$(UFiles$(test)) = "" THEN UFiles$(test) = VFiles$(test) 'LTRIM$ remove spaces. This IF muss to be used, because if filename is <8 characters or is used compatible
  1227.         '  COLOR , 2: PRINT "UFILE RECORD"; UFiles$(test) 'VTK OK!                                   filename with American ASCII, then filename is writed only as Vfile (visible and unvisible name is the same)
  1228.         '  COLOR , 6: PRINT "VFILE RECORD"; VFiles$(test) ' VTK OK!
  1229.         'END IF
  1230.     NEXT
  1231.  
  1232.  
  1233.     FOR mask = 1 TO 11 '                                                                     Have 11 filetypes in DATA - am end this sub
  1234.         READ FileMask$ '                                                                     in arrays we have all files in the directory. I need only types in DATA command. This filemask is filter.
  1235.         FOR FileFilter = 0 TO linies
  1236.             a$ = RIGHT$(LTRIM$(UCASE$(LEFT$(UFiles$(FileFilter), (INSTR(0, UFiles$(FileFilter), ".") + 3)))), 3)
  1237.             IF a$ = FileMask$ THEN MaskUFiles$(FileFilter) = RTRIM$(UFiles$(FileFilter)): MaskVFiles$(FileFilter) = RTRIM$(VFiles$(FileFilter))
  1238.             ' PRINT FileMask$, RIGHT$(LTRIM$(UCASE$(LEFT$(UFiles$(FileFilter), (INSTR(0, UFiles$(FileFilter), ".") + 3)))), 3), mask, FileFilter,
  1239.             ' PRINT a$, FileMask$: SLEEP
  1240.             'sleep
  1241.         NEXT FileFilter
  1242.     NEXT mask
  1243.  
  1244.     COLOR 7, 0
  1245.     'REDIM MaskUFiles
  1246.     'REDIM MaskVFiles
  1247.     IF linies = 0 THEN reload = 0: EXIT SUB
  1248.  
  1249.     FOR vypis = 0 TO linies 'here is already created filelist using filemask in DATA. But in array are empty records, this muss be removed.
  1250.  
  1251.         IF MaskUFiles$(vypis) = STRING$(255, "") THEN GOTO nowrite ELSE NewRecNr = NewRecNr + 1: FinalUFiles$(NewRecNr) = LTRIM$(MaskUFiles$(vypis))
  1252.         IF MaskVFiles$(vypis) = STRING$(255, "") THEN GOTO nowrite ELSE NewRecNr2 = NewRecNr2 + 1: FinalVFiles$(NewRecNr2) = LTRIM$(MaskVFiles$(vypis))
  1253.  
  1254.         nowrite:
  1255.     NEXT vypis
  1256.     IF NewRecNr <= 0 THEN reload = 0: EXIT SUB
  1257.     'IF RTRIM$(FinalUFiles$(1)) = "" THEN reload = 0: BEEP: EXIT SUB
  1258.     '   PRINT NewRecNr: SLEEP               chyba.
  1259.     'BEEP
  1260.     'COLOR _RGB32(255, 255, 255)
  1261.     'FOR ControlLoop = 0 TO NewRecNr
  1262.  
  1263.     'PRINT FinalUFiles$(ControlLoop); ControlLoop; NewRecNr
  1264.     'PRINT FinalVFiles$(ControlLoop); ControlLoop; NewRecNr2
  1265.     'PRINT "MaskUFiles record NR:"; vypis; MaskUFiles$(vypis); "LEN:"; LEN(MaskUFiles$(vypis))
  1266.     'PRINT "MaskVFiles record NR:"; vypis; MaskVfiles$(vypis); "LEN:"; LEN(MaskVfiles$(vypis))
  1267.     'SLEEP
  1268.     'NEXT ControlLoop
  1269.  
  1270.     'here are sub outputs:
  1271.     'NewRecNr - number new records - files accepts filemask
  1272.     'FinalUFiles$(record_number) - list files accepts filemasks, usable to file access
  1273.     'FinalVFiles$(record_number) - list files accepts filemasks, unusable to file acces if filename contains non US characters, but usable to correct view filenames with non US characters with _MAPUNICODE
  1274.     'If filename contains US compatible characters, are both records the same.
  1275.  
  1276.     'ERASE seznam2$, UFiles$, VFiles$, MaskUFiles$, MaskVFiles$
  1277.     'RESTORE FileMask
  1278.  
  1279.  
  1280.  
  1281.     FileMask:
  1282.     DATA WAV,OGG,AIFF,RIFF,VOC,MP3,MIDI,MOD,AIF,RIF,MID
  1283.     linka = NewRecNr: max = NewRecNr
  1284.  
  1285.  
  1286.  
  1287. SUB cj '                                                                                      Sub make Czech characters readable correctly on the screen. If you needed use this
  1288.     '                                                                                         for other language, is possible, you needed others DATA block. Data blocks are
  1289.     RESTORE Microsoft_pc_cpMIK '                                                              for more languages in QB64 help (Shift + F1 / Alphabetical index / _MAPUNICODE statement /
  1290.     '                                                                                         Code Pages)
  1291.     FOR ASCIIcode = 128 TO 255 '                                                              But if your problem is in acces to files with no english names, see to sub nacti.b used in
  1292.         '                                                                                     this program. This is first, based on DIR /X, uses 8.3 filenames, is full compatible for ALL
  1293.         READ unicode '                                                                        languages. It have 2 outputs. One as long filenames uses national characters, two in 8.3 to
  1294.         '                                                                                     file access. 8.3 is full compatible with all languages.
  1295.         _MAPUNICODE unicode TO ASCIIcode '                                                    And i. I need adress in memory to read sound wave. For drawing sound waves to screen :-D
  1296.  
  1297.     NEXT
  1298.  
  1299.  
  1300.  
  1301.     EXIT SUB
  1302.  
  1303.  
  1304.     Microsoft_pc_cpMIK:
  1305.  
  1306.     DATA 199,252,233,226,228,367,263,231,322,235,336,337,238,377,196,262
  1307.     DATA 201,313,314,244,246,317,318,346,347,214,220,356,357,321,215,269
  1308.     DATA 225,237,243,250,260,261,381,382,280,281,172,378,268,351,171,187
  1309.     DATA 9617,9618,9619,9474,9508,193,194,282,350,9571,9553,9559,9565,379,380,9488
  1310.     DATA 9492,9524,9516,9500,9472,9532,258,259,9562,9556,9577,9574,9568,9552,9580,164
  1311.     DATA 273,272,270,203,271,327,205,206,283,9496,9484,9608,9604,354,366,9600
  1312.     DATA 211,223,212,323,324,328,352,353,340,218,341,368,253,221,355,180
  1313.     DATA 173,733,731,711,728,167,247,184,176,168,729,369,344,345,9632,160
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319. SUB RAP (text AS STRING)
  1320.     IF text$ = "shutdown.internal.cmd" THEN GOTO sht
  1321.     SHARED t&, i&, InsertX, ch#, f&, zvuk&, GreenButtonPlay&, GreenButtonStop&, GreenButtonPower&, viewto, GreenButtonBack&, viewto2, GreenButtonNext&, GreenButtonPause&, MouseX, MouseY, vs
  1322.     SHARED resicon&, res, i&, polar, bmx, stopp, LoopAll, RandPlayOn&, RandPlayOff&, rndpl
  1323.     IF text$ = "StartDemo" THEN text$ = "Waiting": GOTO startdemo
  1324.     IF LEN(text$) > 75 THEN text$ = LEFT$(text$, 75)
  1325.     IF _SNDPLAYING(zvuk&) = 0 AND _SNDPAUSED(zvuk&) = 0 THEN znak "...STOP...": GOTO sk
  1326.     IF _SNDPAUSED(zvuk&) = -1 THEN znak RTRIM$("+   -Paused-    +"): GOTO sk
  1327.  
  1328.     startdemo:
  1329.     znak text$
  1330.     sk:
  1331.     _DEST i&
  1332.     black& = _RGB32(0, 0, 0)
  1333.  
  1334.     _SETALPHA 0, black&, t&
  1335.     IF InsertX > 7 * (LEN(RTRIM$(text$)) * _FONTWIDTH(f&)) THEN InsertX = -920 'display have 7 characters
  1336.     sht:
  1337.     IF text$ <> "StartDemo" THEN PCOPY 1, _DISPLAY
  1338.     ViewVolumeLevel
  1339.     ViewBalanceLevel ch#
  1340.     ViewFrequency
  1341.     PressLoop 1: PressLoop 2
  1342.     IF vs = 0 THEN ViewSongTime 0 ELSE ViewSongTime 1: GOSUB viewicon
  1343.     IF rndpl = 0 THEN _PUTIMAGE (930, 91), RandPlayOff&, i&: RndPlay 0 ELSE _PUTIMAGE (930, 91), RandPlayOn&, i&: RndPlay 1
  1344.  
  1345.  
  1346.     REM LOCATE 16, 1: COLOR _RGB(255, 255, 255): PRINT MouseX, MouseY, LoopAll
  1347.     LINE (435, 33)-(710, 128), _RGB32(0, 0, 0), B 'cernej obdelnik kolem TITLE
  1348.  
  1349.     IF text$ = "shutdown.internal.cmd" THEN _SNDSTOP (zvuk&): _PUTIMAGE (237, 41), GreenButtonPower&, i&: _DISPLAY: SLEEP 1: TheEnd
  1350.     IF _SNDPLAYING(zvuk&) = -1 THEN _PUTIMAGE (-1, 42), GreenButtonPlay&, i&
  1351.     IF _SNDPLAYING(zvuk&) = 0 AND _SNDPAUSED(zvuk&) = 0 AND text$ <> "shutdown.internal.cmd" THEN _PUTIMAGE (117, 41), GreenButtonStop&, i&
  1352.     IF text$ = "getback.internal.cmd" THEN viewto = TIMER + 4: text$ = "" ' this make green visible to 4 sec
  1353.     IF viewto > TIMER THEN _PUTIMAGE (7, 151), GreenButtonBack&, i&
  1354.     IF text$ = "getnext.internal.cmd" THEN viewto2 = TIMER + 4: text$ = ""
  1355.     IF viewto2 > TIMER THEN _PUTIMAGE (227, 151), GreenButtonNext&, i&
  1356.     IF _SNDPAUSED(zvuk&) = -1 THEN _PUTIMAGE (117, 151), GreenButtonPause&, i&
  1357.  
  1358.     _PUTIMAGE (450, 30)-(700, 144), t&, i&, (InsertX, -8)-(InsertX + 500, 150)
  1359.     InsertX = InsertX + 10
  1360.     'COLOR _RGB32(255, 255, 255): LOCATE 1, 1: PRINT _SNDLEN(zvuk&)
  1361.    
  1362.     EXIT SUB
  1363.  
  1364.     viewicon:
  1365.     res = res + polar / 2
  1366.     IF res >= 250 OR res <= 0 THEN polar = -polar
  1367.     IF res < 0 THEN res = 0: polar = -polar
  1368.     IF res > 255 THEN res = 255: polar = -polar
  1369.  
  1370.     _SETALPHA res, , resicon&
  1371.     _PUTIMAGE (865, 27), resicon&, i&
  1372.     'COLOR _RGB(255, 255, 255): PRINT res
  1373.  
  1374.     RETURN
  1375.  
  1376.  
  1377. SUB znak (txt AS STRING)
  1378.     'udela kompletni obraz do t&, txt$ prichazi spravne
  1379.     SHARED t&, f&, linka, akt, printed$
  1380.     text& = _NEWIMAGE(1980, 100, 32)
  1381.     _DEST t&: CLS
  1382.     _DEST text&
  1383.     cj
  1384.     _FONT f&
  1385.  
  1386.     printed$ = "(" + LTRIM$(STR$(akt)) + "/" + LTRIM$(STR$(linka)) + ")"
  1387.     '    IF linka > akt THEN linka = 1
  1388.     toend = 140 - LEN(printed$)
  1389.     PRINT printed$; txt$ ' + STRING$(toend, CHR$(32))
  1390.     '    SCREEN text&: SLEEP
  1391.     black& = _RGB32(0, 0, 0)
  1392.     cil = LEN(txt$) * 29
  1393.     _SOURCE text&
  1394.     FOR rozlozX = 0 TO cil
  1395.         FOR rozlozY = 1 TO 29
  1396.             scan& = POINT(rozlozX, rozlozY)
  1397.             IF scan& <> black& THEN _DEST t&: LINE ((tx + (rozlozX * 4)) - 2, (ty + (rozlozY * 4)) - 2)-((tx + (rozlozX * 4)) + 2, (ty + (rozlozY * 4)) + 2), _RGB32(33, 33, 38), B
  1398.             _DEST text&
  1399.         NEXT
  1400.     NEXT
  1401.     '    SCREEN t&: SLEEP
  1402.     _DEST i& 'pocat
  1403.     _FREEIMAGE text&
  1404.  
  1405.  

 
Title: Re: Problem With Wiki Example
Post by: Petr on August 23, 2019, 10:15:22 am
I tried to apply the same procedure to the source code of Ken but there I just managed to correct the compilation error so that the program compiles, but unfortunately does not invoke the windows dialog Open or Save, but it behaves as if I did not select anything and dialog directly closed. So the program scolds me (I need it :)) and that's it. I j rewritte the hwndOwner type to _INTEGER64 in FIELDDIALOGTYPE.  Then have function FindWindowA rewrited to _INTEGER64 type. I vaguely remember, Steve, that you were showing something with _WindowHandle somewhere (if it was you?) And that you no longer need to call FindWindowA. Somewhere in that window identification that calls Windows dialogs and it is likely to be a problem.
Title: Re: Problem With Wiki Example
Post by: SMcNeill on August 23, 2019, 11:14:03 am
I tried to apply the same procedure to the source code of Ken but there I just managed to correct the compilation error so that the program compiles, but unfortunately does not invoke the windows dialog Open or Save, but it behaves as if I did not select anything and dialog directly closed. So the program scolds me (I need it :)) and that's it. I j rewritte the hwndOwner type to _INTEGER64 in FIELDDIALOGTYPE.  Then have function FindWindowA rewrited to _INTEGER64 type. I vaguely remember, Steve, that you were showing something with _WindowHandle somewhere (if it was you?) And that you no longer need to call FindWindowA. Somewhere in that window identification that calls Windows dialogs and it is likely to be a problem.

Change line 460 in your program to hwnd& = _WINDOWHANDLE, and you won’t need FindWindowA.

As for the LONG/INTEGER64 type, at line 463, make it auto sizing with the precompiler:

$IF 32BIT THEN
    hwndOwner AS LONG
$ELSE
    hwndOwner AS _INTEGER64
$END IF
Title: Re: Problem With Wiki Example
Post by: Petr on August 23, 2019, 11:21:30 am
Thank you, Steve
Title: Re: Problem With Wiki Example
Post by: SierraKen on August 23, 2019, 01:07:50 pm
Wow... I read all of these replies and I have no idea where to start on mine. Or is it possible yet? I feel like I just walked into a classroom of PhD programmers. :)
Title: Re: Problem With Wiki Example
Post by: bplus on August 23, 2019, 01:32:46 pm
Wow... I read all of these replies and I have no idea where to start on mine. Or is it possible yet? I feel like I just walked into a classroom of PhD programmers. :)

I fixed Tiny Navigator, should I start thread? I was going to try a files window like Steve has before posting.
Title: Re: Problem With Wiki Example
Post by: SpriggsySpriggs on May 13, 2020, 09:32:13 am
The way I've found to get around the 64 vs 32 bit issue is using the 32 bit library for the 32 bit programs and using a PowerShell script to call an open file dialog in 64 bit versions instead and outputting the returned filename to a text file that I can read it back from.
PowerShell code:
Quote
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'
Add-Type -AssemblyName System.Windows.Forms
$FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{
    InitialDirectory = '.\'
    Filter = 'All Files (*.*)|*.*'
}
$null = $FileBrowser.ShowDialog()
$FileName = $FileBrowser.FileName
if ($FileName -ne ''){
Write-Host $FileName
$FileName > 'openfilename.txt'
exit 1
}
else{
exit 0
}
QB64 Code:
Code: QB64: [Select]
  1. SHELL$ = "PowerShell -WindowStyle Hidden -ExecutionPolicy Bypass " + CHR$(34) + "&'" + _STARTDIR$ + "\OpenFile.ps1';exit $LASTEXITCODE" + CHR$(34)
  2. IF a = 1 THEN
  3.     OPEN "openfilename.txt" FOR BINARY AS #1
  4.     LINE INPUT #1, OFile$
  5.     PRINT "Cancelled"
  6. OFile$ = RIGHT$(OFile$, LEN(OFile$) - 3)
  7. PRINT OFile$
You trim off the last three characters because there are some hidden characters that Windows Forms seems to add and they will screw up all the file handling if you don't trim them off. I hope this can help someone!
Title: Re: Problem With Wiki Example
Post by: SpriggsySpriggs on May 13, 2020, 01:09:40 pm
Here is a way to really adapt the open file dialog for 64 bit. The only issue is that you can't use the initial directory parameter due to the fact that it is through a PowerShell call. (Fixed this as I was writing this post.)
A screenshot of the dialog:
 

Here is the PowerShell code, fully fixed to accept a custom title, Start Directory, and Filter for filetypes
Quote
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'
Add-Type -AssemblyName System.Windows.Forms
$FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{
}
$FileBrowser.Title = $args[0]
$initial = $args[1].ToString().Replace("/","\")
$FileBrowser.InitialDirectory = $initial
$chosenfilter = $args[2].ToString().Replace("^/^","|")
$FileBrowser.Filter = $chosenfilter

$null = $FileBrowser.ShowDialog()
$FileName = $FileBrowser.FileName
if ($FileName -ne ''){
$FileName > 'openfilename.txt'
exit 1
}
else{
exit 0
}
And here is the current QB64 code that would allow you to call a function similar to GetOpenFileNameA and display an Open File Dialog:
Code: QB64: [Select]
  1. OFile$ = GetOpenFileName64("Select a file, jackass", "C:\Users\zacharys\[redacted]\Desktop\QB64 Files\qb32", "QB64 Files (*.BAS)|*.bas|All Files (*.*)|*.*")
  2. FUNCTION GetOpenFileName64$ (Title$, InitialDir$, Filter$)
  3.     SHELL$ = "PowerShell -WindowStyle Hidden -ExecutionPolicy Bypass " + CHR$(34) + "&'" + _STARTDIR$ + "\OpenFile.ps1'"
  4.     SHELL$ = SHELL$ + " " + "\" + CHR$(34) + Title$ + "\" + CHR$(34)
  5.     IF INSTR(InitialDir$, "\") THEN
  6.         InitialDir$ = ReplaceStringItem(InitialDir$, "\", "/")
  7.     END IF
  8.     SHELL$ = SHELL$ + " " + "\" + CHR$(34) + InitialDir$ + "\" + CHR$(34)
  9.     IF INSTR(Filter$, "|") THEN
  10.         Filter$ = ReplaceStringItem(Filter$, "|", "^/^")
  11.         'Filter$ = ReplaceStringItem(Filter$, "/", "|")
  12.     END IF
  13.     SHELL$ = SHELL$ + " " + "\" + CHR$(34) + Filter$ + "\" + CHR$(34)
  14.     SHELL$ = SHELL$ + ";exit $LASTEXITCODE" + CHR$(34)
  15.     a = _SHELLHIDE(SHELL$)
  16.     '_ECHO SHELL$
  17.     IF a = 1 THEN
  18.         F = FREEFILE
  19.         OPEN "openfilename.txt" FOR BINARY AS #F
  20.         LINE INPUT #F, OFile$
  21.         CLOSE #F
  22.         OFile$ = RIGHT$(OFile$, LEN(OFile$) - 3)
  23.         GetOpenFileName64 = OFile$
  24.     ELSE
  25.         GetOpenFileName64 = ""
  26.         '    PRINT "Cancelled"
  27.     END IF
  28.  
  29.  FUNCTION ReplaceStringItem$ (text$, old$, new$)
  30.     DO
  31.         find = INSTR(start + 1, text$, old$) 'find location of a word in text
  32.         IF find THEN
  33.             first$ = LEFT$(text$, find - 1) 'text before word including spaces
  34.             last$ = RIGHT$(text$, LEN(text$) - (find + LEN(old$) - 1)) 'text after word
  35.             text$ = first$ + new$ + last$
  36.         END IF
  37.         start = find
  38.     LOOP WHILE find
  39.     ReplaceStringItem = text$

UPDATE!!!!! 2:50 PM: 8:20 AM 5/14/2020
Here is the code for making the GetSaveFileName function:
PowerShell:
Quote
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'
Add-Type -AssemblyName System.Windows.Forms
$FileBrowser = New-Object System.Windows.Forms.SaveFileDialog -Property @{
}
$FileBrowser.Title = $args[0]
$initial = $args[1].ToString().Replace("/","\")
$FileBrowser.InitialDirectory = $initial
$chosenfilter = $args[2].ToString().Replace("^/^","|")
$FileBrowser.Filter = $chosenfilter

$null = $FileBrowser.ShowDialog()
$FileName = $FileBrowser.FileName
if ($FileName -ne ''){
$FileName > 'savefilename.txt'
exit 1
}
else{
exit 0
}
And QB64:
Code: QB64: [Select]
  1.    
  2. SFile$ = GetSaveFileName64("Save a file, jackass", "C:\Users\zacharys\[redacted]\Desktop\QB64 Files\qb32", "QB64 Files (*.BAS;*.BI;*.BM;*.FRM)|*.BAS;*.BI;*.BM;*.FRM|All Files (*.*)|*.*")
  3. FUNCTION GetSaveFileName64$ (Title$, InitialDir$, Filter$)
  4.     SHELL$ = "PowerShell -ExecutionPolicy Bypass " + CHR$(34) + "&'" + _STARTDIR$ + "\SaveFile.ps1'"
  5.     SHELL$ = SHELL$ + " " + "\" + CHR$(34) + Title$ + "\" + CHR$(34)
  6.     IF INSTR(InitialDir$, "\") THEN
  7.         InitialDir$ = ReplaceStringItem(InitialDir$, "\", "/")
  8.     END IF
  9.     SHELL$ = SHELL$ + " " + "\" + CHR$(34) + InitialDir$ + "\" + CHR$(34)
  10.     IF INSTR(Filter$, "|") THEN
  11.         Filter$ = ReplaceStringItem(Filter$, "|", "^/^")
  12.         'Filter$ = ReplaceStringItem(Filter$, "/", "|")
  13.     END IF
  14.     SHELL$ = SHELL$ + " " + "\" + CHR$(34) + Filter$ + "\" + CHR$(34)
  15.     SHELL$ = SHELL$ + ";exit $LASTEXITCODE" + CHR$(34)
  16.     a = _SHELLHIDE(SHELL$)
  17.     'a = SHELL(SHELL$)
  18.     '_ECHO SHELL$
  19.     IF a = 1 THEN
  20.         F = FREEFILE
  21.         OPEN "savefilename.txt" FOR BINARY AS #F
  22.         LINE INPUT #F, SFile$
  23.         CLOSE #F
  24.         SFile$ = RIGHT$(SFile$, LEN(SFile$) - 3)
  25.         GetSaveFileName64 = SFile$
  26.     ELSE
  27.         GetSaveFileName64 = ""
  28.         '    PRINT "Cancelled"
  29.     END IF