QB64.org Forum

Active Forums => Programs => Topic started by: bplus on February 07, 2021, 08:04:56 pm

Title: Pipecom Browser for Filename$
Post by: bplus on February 07, 2021, 08:04:56 pm
Here is application to viewing BMP24 files that NOVARSEG started:
Code: QB64: [Select]
  1. _Title "Pipecom Browser for BMP24 File Display" 'b+ testing one array system with pipecom
  2. ' Thanks to Spriggsy, Zak, for convincing me pipecom is better!
  3. ' Using Steve's fixed BMP24 loader
  4. ' Also thanks to Dav for 1 window for file and folder selection idea
  5. ' Also thanks to NOVARSEG who got me going on this for a better filename$ retriever
  6.  
  7. Declare Library "pipecom"
  8.     Function pipecom$ (cmd As String)
  9.  
  10. Screen _NewImage(1280, 740, 32)
  11. _Delay .25
  12. _ScreenMove 65, 0 ' your screen might need different
  13.  
  14. ReDim myFile$, image&
  15. ReDim As Long col, row, charW, charH
  16. Color , &HFF000033
  17. Do 'test our new function
  18.     ScnState 0
  19.     col = 16: row = 3: charW = 128: charH = 40
  20.     myFile$ = GetFileName$(row, col, charW, charH)
  21.     ScnState -1 ' <<<<<<<<<<<<<<<<<<<<<<<<<<< this is supposed to restore back color
  22.     image& = loadBMP24&(myFile$)
  23.     Color , &HFF000033
  24.     Cls
  25.     If image& <> 0 Then
  26.         _Title myFile$ + " press any to get another BMP24 file image, esc to quit"
  27.         _PutImage ((_Width - _Width(image&)) / 2, (_Height - _Height(image&)) / 2)-Step(_Width(image&), _Height(image&)), image&, 0
  28.         Sleep
  29.         _FreeImage image&
  30.     End If
  31.  
  32. Function loadBMP24& (Filename$) ' Steve's revised version without the extra handle and memory leak
  33.     Dim As _Unsigned Long of, l, w, r, c
  34.     Dim a As _MEM
  35.     Dim As Long handle, h ' <<< edit as per NOVARSEG
  36.     Dim tt As String * 4
  37.     Dim t As String * 3
  38.     Dim padding$
  39.  
  40.     If Right$(UCase$(Filename$), 4) <> ".BMP" Then Exit Function
  41.     Print Filename$
  42.     Open Filename$ For Binary As #1
  43.     Get #1, 11, of
  44.     Get #1, 15, l
  45.     Get #1, , w
  46.     Get #1, , h
  47.     Get #1, , i
  48.     Get #1, , i 'get I twice ???
  49.     If i <> 24 Then Exit Function
  50.     handle = _NewImage(w, h, 32)
  51.     a = _MemImage(handle)
  52.     If ((w * 3) Mod 4) <> 0 Then padding$ = Space$((4 - ((w * 3) Mod 4))) '’need padding pixels
  53.     Seek #1, of + 1 'go to the offset where the data starts
  54.     For r = h - 1 To 0 Step -1 'from the bottom to top
  55.         For c = 0 To w - 1 'left to right
  56.             Get #1, , t 'get the data sequentially
  57.             tt = t + Chr$(255)
  58.             _MemPut a, a.OFFSET + (w * r + c) * 4, tt
  59.         Next c
  60.         Get #1, , padding$ 'Get the padding at the end of the line
  61.     Next r
  62.     Close
  63.     loadBMP24& = handle
  64.     _MemFree a
  65.  
  66. Function GetFileName$ (LocateR, LocateC, CharWide, CharHigh) ' < careful Locate Row, Col NOT x, y
  67.     'This Funtion needs:
  68.     ' pipecom.h in same folder as QB64.exe
  69.     ' This in main code section near top:
  70.     ' Declare Library "pipecom"
  71.     '    Function pipecom$ (cmd As String)
  72.     ' End Declare
  73.     ' sub  Split source$, delimiter$, arr$()
  74.     ' function GetArrayItem$(x, y, w, h, arr$())
  75.  
  76.     ReDim As String d, s, dr
  77.     ReDim As _Unsigned Long fc, bc
  78.     fc = _DefaultColor: bc = _BackgroundColor ' save colors
  79.     Getfolder:
  80.     Color fc, bc: Cls
  81.     d = pipecom("dir /n /o:gend") '/n files on right (40) /o = order g for group dirs first, e extension, name, date
  82.     d = Left$(d, Len(d) - 1) ' always ends with delimiter
  83.     ReDim dir(1 To 1) As String
  84.     Split d, Chr$(10), dir()
  85.     s = GetArrayItem$(LocateR, LocateC, CharWide, CharHigh, dir())
  86.     If InStr(s, "<DIR>") Then 'isolate name
  87.         dr = _Trim$(Mid$(s, InStr(s, "<DIR>") + 6))
  88.         ChDir dr
  89.         GoTo Getfolder
  90.     ElseIf InStr(s, "AM") Or InStr(s, "PM") Then
  91.         GetFileName$ = _Trim$(Mid$(s, 40))
  92.         Color fc, bc: Cls
  93.     ElseIf s = "" Then 'cancel, escape, bad line
  94.         Color fc, bc: Cls ' will return empty string
  95.     End If
  96.  
  97. Sub Split (SplitMeString As String, delim As String, loadMeArray() As String)
  98.     Dim curpos As Long, arrpos As Long, LD As Long, dpos As Long 'fix use the Lbound the array already has
  99.     curpos = 1: arrpos = LBound(loadMeArray): LD = Len(delim)
  100.     dpos = InStr(curpos, SplitMeString, delim)
  101.     Do Until dpos = 0
  102.         loadMeArray(arrpos) = Mid$(SplitMeString, curpos, dpos - curpos)
  103.         arrpos = arrpos + 1
  104.         If arrpos > UBound(loadMeArray) Then ReDim _Preserve loadMeArray(LBound(loadMeArray) To UBound(loadMeArray) + 1000) As String
  105.         curpos = dpos + LD
  106.         dpos = InStr(curpos, SplitMeString, delim)
  107.     Loop
  108.     loadMeArray(arrpos) = Mid$(SplitMeString, curpos)
  109.     ReDim _Preserve loadMeArray(LBound(loadMeArray) To arrpos) As String 'get the ubound correct
  110.  
  111.  
  112. ' Help: all this I hope is intuitive so Help window is provided
  113. ' "Mouse, mouse wheel, and arrow keys should work as expected for item selection."
  114. ' "Press spacebar to select a highlighted item or just click it."
  115. ' "Use number(s) + enter to select an array item by it's index number,"
  116. ' "backspace will remove last number pressed, delete will clear a number started.
  117. ' "Numbers started are shown in bottom right PgDn bar."
  118. ' "Enter will also select the highlighted item, if no number has been started."
  119. ' "Home starts you at lowest array index, End highlights then highest index."
  120. ' "Use PgUp and PgDn keys to flip through pages of array items."
  121. '
  122. ' Escape to Cancel Return "" else Return the selected string from the array
  123. Function GetArrayItem$ (LocateRoww, LocateColumn, BoxWidth, BoxHeight, Arr() As String)
  124.     'Notes: locateRow, locateColumn for top right corner of selection box on screen in characters for LOCATE.
  125.     'boxWidth and boxHeight are in character units, again for locate and print at correct places.
  126.     'All displaying is restricted to inside the box, which has PgUP and PgDn as top and bottom lines in the display.
  127.  
  128.     ReDim As Long maxWidth, maxHeight, page, hlite, mx, my, locateRow, lastMX, lastMY, row, mb
  129.     ReDim As Long lba, uba, choice, kh, index
  130.     Dim clrStr As String, b As String
  131.  
  132.     'ScnState 0 ' use out side this function before and after
  133.     locateRow = LocateRoww + 1 'fix a miscalc in coding
  134.     maxWidth = BoxWidth '       number of characters in box
  135.     maxHeight = BoxHeight - 2 ' number of lines displayed of array at one time = 1 page
  136.     lba = LBound(arr)
  137.     uba = UBound(arr)
  138.     page = 0
  139.     hlite = 0 '                 line in display ready for selection by spacebar or if no number is started, enter
  140.     clrStr$ = Space$(maxWidth) 'clearing a display line
  141.  
  142.     GoSub update '              show the beginning of the array items for selection
  143.     choice = -1719
  144.     Do 'until get a selection or demand exit
  145.  
  146.         'handle the key stuff
  147.         kh& = _KeyHit
  148.         If kh& Then
  149.             If kh& > 0 And kh& < 255 Then
  150.                 If InStr("0123456789", Chr$(kh&)) > 0 Then
  151.                     b$ = b$ + Chr$(kh&): GoSub update
  152.                 ElseIf kh& = 13 Then 'enter pressed check if number is being entered?
  153.                     If Len(b$) Then
  154.                         If Val(b$) >= lba And Val(b$) <= uba Then 'we have number started
  155.                             choice = Val(b$): Exit Do
  156.                         Else 'clear b$ to show some response to enter
  157.                             b$ = "": GoSub update 'clear the value that doesn't work
  158.                         End If
  159.                     Else
  160.                         choice = hlite + page * maxHeight + lba 'must mean to select the highlighted item
  161.                     End If
  162.                 ElseIf kh& = 27 Then
  163.                     Exit Do 'escape clause offered to Cancel selection process
  164.                 ElseIf kh& = 32 Then
  165.                     choice = hlite + page * maxHeight + lba 'best way to choose highlighted selection
  166.                 ElseIf kh& = 8 Then 'backspace to edit number
  167.                     If Len(b$) Then b$ = Left$(b$, Len(b$) - 1): GoSub update
  168.                 End If
  169.             Else
  170.                 Select Case kh& 'choosing sections of array to display and highlighted item
  171.                     Case 21248 ' delete so clear b$
  172.                         b$ = "": GoSub update
  173.                     Case 20736 ' pg dn
  174.                         If (page + 1) * maxHeight + lba <= uba Then page = page + 1: GoSub update
  175.                     Case 18688 ' pg up
  176.                         If (page - 1) * maxHeight + lba >= lba Then page = page - 1: GoSub update
  177.                     Case 18432 ' up
  178.                         If hlite - 1 < 0 Then
  179.                             If page > 0 Then
  180.                                 page = page - 1: hlite = maxHeight - 1: GoSub update
  181.                             End If
  182.                         Else
  183.                             hlite = hlite - 1: GoSub update
  184.                         End If
  185.                     Case 20480 'down
  186.                         If (hlite + 1) + page * maxHeight + lba <= uba Then 'ok to move up
  187.                             If hlite + 1 > maxHeight - 1 Then
  188.                                 page = page + 1: hlite = 0: GoSub update
  189.                             Else
  190.                                 hlite = hlite + 1: GoSub update
  191.                             End If
  192.                         End If
  193.                     Case 18176 'home
  194.                         page = 0: hlite = 0: GoSub update
  195.                     Case 20224 ' end
  196.                         page = Int((uba - lba) / maxHeight): hlite = maxHeight - 1: GoSub update
  197.                 End Select
  198.             End If
  199.         End If
  200.  
  201.         'handle the mouse stuff
  202.         While _MouseInput
  203.             If _MouseWheel = -1 Then 'up?
  204.                 If hlite - 1 < 0 Then
  205.                     If page > 0 Then
  206.                         page = page - 1: hlite = maxHeight - 1: GoSub update
  207.                     End If
  208.                 Else
  209.                     hlite = hlite - 1: GoSub update
  210.                 End If
  211.             ElseIf _MouseWheel = 1 Then 'down?
  212.                 If (hlite + 1) + page * maxHeight + lba <= uba Then 'ok to move up
  213.                     If hlite + 1 > maxHeight - 1 Then
  214.                         page = page + 1: hlite = 0: GoSub update
  215.                     Else
  216.                         hlite = hlite + 1: GoSub update
  217.                     End If
  218.                 End If
  219.             End If
  220.         Wend
  221.         mx = Int((_MouseX - LocateColumn * 8) / 8) + 2: my = Int((_MouseY - locateRow * 16) / 16) + 2
  222.         If _MouseButton(1) Then 'click contols or select array item
  223.             'clear mouse clicks
  224.             mb = _MouseButton(1)
  225.             If mb Then 'clear it
  226.                 While mb 'OK!
  227.                     If _MouseInput Then mb = _MouseButton(1)
  228.                     _Limit 100
  229.                 Wend
  230.             End If
  231.  
  232.             If mx >= 1 And mx <= maxWidth And my >= 1 And my <= maxHeight Then
  233.                 choice = my + page * maxHeight + lba - 1 'select item clicked
  234.             ElseIf mx >= 1 And mx <= maxWidth And my = 0 Then 'page up or exit
  235.                 If my = 0 And (mx <= maxWidth And mx >= maxWidth - 2) Then 'exit sign
  236.                     Exit Do 'escape plan for mouse click top right corner of display box
  237.                 Else 'PgUp bar clicked
  238.                     If (page - 1) * maxHeight + lba >= lba Then page = page - 1: GoSub update
  239.                 End If
  240.             ElseIf mx >= 1 And mx <= maxWidth And my = maxHeight + 1 Then 'page down bar clicked
  241.                 If (page + 1) * maxHeight + lba <= uba Then page = page + 1: GoSub update
  242.             End If
  243.         Else '   mouse over highlighting, only if mouse has moved!
  244.             If mx >= 1 And mx <= maxWidth And my >= 1 And my <= maxHeight Then
  245.                 If mx <> lastMX Or my <> lastMY Then
  246.                     If my - 1 <> hlite And (my - 1 + page * maxHeight + lba <= uba) Then
  247.                         hlite = my - 1
  248.                         lastMX = mx: lastMY = my
  249.                         GoSub update
  250.                     End If
  251.                 End If
  252.             End If
  253.         End If
  254.         _Limit 200
  255.     Loop Until choice >= lba And choice <= uba
  256.     If choice <> -1719 Then GetArrayItem$ = Arr(choice) 'set function and restore screen
  257.     'ScnState -1 'restore
  258.  
  259.     'display of array sections and controls on screen  ====================================================
  260.     update:
  261.  
  262.     'fix hlite if it has dropped below last array item
  263.     While hlite + page * maxHeight + lba > uba
  264.         hlite = hlite - 1
  265.     Wend
  266.  
  267.     'main display of array items at page * maxHeight (lines high)
  268.     For row = 0 To maxHeight - 1
  269.         If hlite = row Then Color _RGB(200, 200, 255), _RGB32(0, 0, 88) Else Color _RGB32(0, 0, 88), _RGB(200, 200, 255)
  270.         Locate locateRow + row, LocateColumn: Print clrStr$;
  271.         index = row + page * maxHeight + lba
  272.         If index >= lba And index <= uba Then
  273.             Locate locateRow + row, LocateColumn
  274.             Print Left$(LTrim$(Str$(index)) + ") " + Arr(index), maxWidth);
  275.         End If
  276.     Next
  277.  
  278.     'make page up and down bars to click, print PgUp / PgDn if available
  279.     Color _RGB32(200, 200, 255), _RGB32(0, 100, 50)
  280.     Locate locateRow - 1, LocateColumn: Print Space$(maxWidth);
  281.     If page <> 0 Then Locate locateRow - 1, LocateColumn: Print Left$(" Pg Up" + Space$(maxWidth), maxWidth);
  282.     Locate locateRow + maxHeight, LocateColumn: Print Space$(maxWidth);
  283.     If page <> Int(uba / maxHeight) Then
  284.         Locate locateRow + maxHeight, LocateColumn: Print Left$(" Pg Dn" + Space$(maxWidth), maxWidth);
  285.     End If
  286.     'make exit sign for mouse click
  287.     Color _RGB32(255, 255, 255), _RGB32(200, 100, 0)
  288.     Locate locateRow - 1, LocateColumn + maxWidth - 3
  289.     Print " X ";
  290.  
  291.     'if a number selection has been started show it's build = b$
  292.     If Len(b$) Then
  293.         Color _RGB(255, 255, 0), _RGB32(0, 0, 0)
  294.         Locate locateRow + maxHeight, LocateColumn + maxWidth - Len(b$) - 1
  295.         Print b$;
  296.     End If
  297.     _Display
  298.     _Limit 100
  299.     Return
  300.  
  301. Sub ScnState (restoreTF As Long) 'Thanks Steve McNeill  should we get a snap shot of screen?
  302.     Static As _Unsigned Long defaultColor, backGroundColor
  303.     Static As Long font, dest, source, row, col, autodisplay, mb, snap
  304.     If restoreTF Then
  305.         _Font font
  306.         Color defaultColor, backGroundColor
  307.         _Dest dest
  308.         _Source source
  309.  
  310.         _KeyClear
  311.         While _MouseInput: Wend 'clear mouse clicks
  312.         mb = _MouseButton(1)
  313.         If mb Then 'need this if line ?
  314.             Do
  315.                 While _MouseInput: Wend
  316.                 mb = _MouseButton(1)
  317.                 _Limit 100
  318.             Loop Until mb = 0
  319.         End If
  320.         _PutImage , snap, dest
  321.         _FreeImage snap
  322.         _Display
  323.         If autodisplay Then _AutoDisplay Else _Display
  324.         Locate row, col
  325.     Else
  326.         snap = _NewImage(_Width, _Height, 32)
  327.         _PutImage , 0, snap
  328.         font = _Font: defaultColor = _DefaultColor: backGroundColor = _BackgroundColor
  329.         dest = _Dest: source = _Source
  330.         row = CsrLin: col = Pos(0): autodisplay = _AutoDisplay
  331.         While _MouseInput: Wend 'clear mouse clicks
  332.         mb = _MouseButton(1)
  333.         If mb Then 'need this if line ?
  334.             Do
  335.                 While _MouseInput: Wend
  336.                 mb = _MouseButton(1)
  337.                 _Limit 100
  338.             Loop Until mb = 0
  339.         End If
  340.         _KeyClear
  341.     End If
  342.  
  343.  
  344.  
  345.  
  346.  

You will need this in your QB64.exe Folder and a QB64 version dev 1.5 version.


EDIT: made h Long in LoadBMP24 Sub as per NOVARSEG
Title: Re: Pipecom Browser for Filename$
Post by: SpriggsySpriggs on February 07, 2021, 08:06:18 pm
@bplus It's cool that you were able to use my pipecom library to make something neat
Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 07, 2021, 08:08:47 pm
Tell me you tried it already! ;-))

I just got done editing a thankyou to you. :)
Title: Re: Pipecom Browser for Filename$
Post by: SpriggsySpriggs on February 07, 2021, 09:32:33 pm
@bplus It works great! Super fast on my system. Good job on the UI
Title: Re: Pipecom Browser for Filename$
Post by: STxAxTIC on February 07, 2021, 10:25:49 pm
well this is nice!
Title: Re: Pipecom Browser for Filename$
Post by: NOVARSEG on February 08, 2021, 02:53:57 am
@bplus
got to get latest version.

Yes it is true Steve did fix the padding issue.    Evidently some BMPs have a negative height value so you gotta change the
 
h  in 
Dim As _Unsigned Long of, l, w, h, r, c

to a LONG

I've never come across a negative height BMP though.. See my latest BMP viewer code that handles negative height BMPs

https://www.qb64.org/forum/index.php?topic=3602.30#lastPost
Title: Re: Pipecom Browser for Filename$
Post by: Dav on February 08, 2021, 07:39:53 am
Works great here!  Fast too.  I like it.

- Dav
Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 08, 2021, 12:16:12 pm
Thanks for your feedback!

If someone could provide a Linux command that produces a Directory Listing that distinguishes Files from Folders and provides a Sample Output Directory, I could adapt this for Linux.

@johnno56  can you help with this?

Here simple Pipecom code to test commands to OS and Sample Output from Windows that I see all Files and Folders and can distingush Folders have <DIR> in label.
Code: [Select]
_Title "Quick Pipecom Demo" 'b+ 2021-02-08
Declare Library "pipecom"
    Function pipecom$ (cmd As String)
End Declare

Dim F As String 'tests with command line dir calls
' NOTE: these slants work \    these do not /
'F = pipecom("dir " + Chr$(34) + "C:\users\marka\desktop\QB64 work\000 work QB64" + Chr$(34) + " /b /A:D") ' Linux needs other switches
'F = pipecom("dir /b *.BAS") 'if you need just the filenames and not the rest of the output
'F = pipecom("dir /b /A:D") ' /b = bare list /A:D directories only

F = pipecom("dir ??? ") ' <<<<<<<<<<< Linux command goes between quotes here
Print F
_Clipboard$ = F


' Paste from ClipBoard
' Volume in drive C is Windows
' Volume Serial Number is 0EDF-FD28

' Directory of C:\Users\marka\Desktop\QB64 work\000 work QB64\000 Test\DIR$() replacement Spriggsy

'02/08/2021  12:14 PM    <DIR>          .
'02/08/2021  12:14 PM    <DIR>          ..
'10/26/2020  10:14 AM    <DIR>          pipecom.h bak
'02/07/2021  08:43 PM            14,491 Pipecom Browser mod 2 Better Array Select.bas
'02/06/2021  12:56 AM             1,015 Pipecom demo to replace Dir$() by Spriggsy.bas
'02/07/2021  08:54 PM             4,160 Pipecome Browser 1 Crude Keypress Select.bas
'02/08/2021  12:12 PM                 2 Quick Pipecom demo.bas
'01/19/2021  10:45 AM             2,548 Really simple pipe to clip by doppler.bas
'02/07/2021  12:00 PM             2,180 Shell dir to clipboard doppler.bas
'02/07/2021  08:35 PM         2,110,464 Pipecom Browser mod 2 Better Array Select.exe
'02/07/2021  08:53 PM         2,094,592 Pipecome Browser 1 Crude Keypress Select.exe
'02/08/2021  12:14 PM         2,080,256 Quick Pipecom demo.exe
'02/07/2021  11:59 AM         2,085,888 Really simple pipe to clip by doppler.exe
'02/07/2021  12:00 PM         2,087,424 Shell dir to clipboard doppler.exe
'              11 File(s)     10,483,020 bytes
'               3 Dir(s)  907,052,933,120 bytes free



Again put this into the same Folder as your QB64.exe
Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 08, 2021, 12:34:40 pm
@bplus
got to get latest version.

Yes it is true Steve did fix the padding issue.    Evidently some BMPs have a negative height value so you gotta change the
 
h  in 
Dim As _Unsigned Long of, l, w, h, r, c

to a LONG

I've never come across a negative height BMP though.. See my latest BMP viewer code that handles negative height BMPs

https://www.qb64.org/forum/index.php?topic=3602.30#lastPost

OK edited the original post, thanks
Title: Re: Pipecom Browser for Filename$
Post by: NOVARSEG on February 08, 2021, 06:01:08 pm
@bplus
Did you actually try it with -h?

If it works, a normal BMP image (with positive h)  will be upside down.

Dim padding$
 h = 0 - h   ' *** add this line ***
If Right$(UCase$(Filename$), 4) <> ".BMP" Then Exit Function
Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 08, 2021, 06:52:38 pm
@bplus
Did you actually try it with -h?

If it works, a normal BMP image (with positive h)  will be upside down.

Dim padding$
 h = 0 - h   ' *** add this line ***
If Right$(UCase$(Filename$), 4) <> ".BMP" Then Exit Function

I changed the type of h to Long and tested the pictures I had and ran fine.

Now if h is a negative number it will work, I assume. I need an BMP24 file with h <0 pic to test that situation..
Title: Re: Pipecom Browser for Filename$
Post by: NOVARSEG on February 08, 2021, 07:05:50 pm
Quote
Now if h is a negative number it will work, I assume. I need an BMP24 file with h <0 pic to test that situation.
.

Don't need an actual -h BMP to test

Dim padding$
 h = 0 - h   ' *** add this line. For testing only ***
If Right$(UCase$(Filename$), 4) <> ".BMP" Then Exit Function

If the code works then a BMP with +h will display upside down

with commented
  ' h = 0 - h

A BMP with actual -h will now display properly

****
for one thing

handle = _NewImage(w, h, 32)

can't have a negative h


https://www.qb64.org/forum/index.php?topic=3602.30#lastPost

Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 08, 2021, 09:40:24 pm
.

Don't need an actual -h BMP to test

Dim padding$
 h = 0 - h   ' *** add this line. For testing only ***
If Right$(UCase$(Filename$), 4) <> ".BMP" Then Exit Function

If the code works then a BMP with +h will display upside down

with commented
  ' h = 0 - h

A BMP with actual -h will now display properly

****
for one thing

handle = _NewImage(w, h, 32)

can't have a negative h


https://www.qb64.org/forum/index.php?topic=3602.30#lastPost



I'm not messing around with all that if it is enough to make h long. The point of this thread is to test Pipecom and filename retriever code, I just happened to use BMP24 files because it was recent and you @NOVARSEG asked about  mouse input app for you code.

I will be glad to test a -h BMP24 file if one were provided with this app as it is. :)

Title: Re: Pipecom Browser for Filename$
Post by: SMcNeill on February 08, 2021, 09:47:04 pm
If you do get a -h file, just read it as usual and then _PUTIMAGE it from bottom to top to your screen.
Title: Re: Pipecom Browser for Filename$
Post by: NOVARSEG on February 08, 2021, 10:35:44 pm
@bplus

That will be a fair test of the code

I will make a -h BMP convertor. It will take a +h BMP and then convert it into a -h BMP

https://www.mozilla.org/en-US/security/advisories/mfsa2012-61/

here is an interesting one. MS paint evidently crashes with -h BMPs
https://groups.google.com/g/microsoft.public.win32.programmer.gdi/c/8CnUgn-gzD0/m/FS8rzRXq9DgJ

OK i tried engine3.bmp  in MSPAINT and it worked .
Title: Re: Pipecom Browser for Filename$
Post by: NOVARSEG on February 09, 2021, 12:06:06 am
Ok here is a negative h BMP

W = 1024
H = -831

It says 831 at the bottom of the image, but that is an ABS value



Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 09, 2021, 02:51:28 pm
@NOVARSEG

Thanks I am convinced just changing H to Long Type is not enough. But we knew that, I guess, I did after I went and reread everything again. Steve never updated his fixed Sub with another?

I checked back to last version you posted, it may work but it isn't in a handy, portable and convenient Sub like I have here. So get to work man!  ;-))

Sorry, the Interpreter muse has struck me again (won't Aurel be thrilled?) or I'd be fixing myself.

This pipecom code and array displayer are some new features planned for making editable code as well as retrieving files.
I have found my way to a "No double quotes for strings" theory, just bare naked text.

PS might need a Line Editor, not a full fledged WP.
Title: Re: Pipecom Browser for Filename$
Post by: NOVARSEG on February 09, 2021, 08:12:27 pm
Been awhile since I wrote a SUB

Do I have to put my DIMS inside the sub?   I like my DIMS at the start of a program.




Title: Re: Pipecom Browser for Filename$
Post by: SMcNeill on February 09, 2021, 08:30:33 pm
Been awhile since I wrote a SUB

Do I have to put my DIMS inside the sub?   I like my DIMS at the start of a program.

Are the global, or local variables?

DIM inside a sub keeps the values local to the sub, whereas DIM SHARED in the main module makethem global.
Title: Re: Pipecom Browser for Filename$
Post by: NOVARSEG on February 09, 2021, 09:37:24 pm
OK the sub would have to be something like

SUB loadBMP24 (Filename as string$, W AS LONG, H AS LONG, HANDLE AS LONG)
retunrs W  width of BMP
returns  H height of BMP
returns handle   generated from   " HANDLE = _NEWIMAGE(W, ABS(H), 32) "
input Filename
****

Gettimg a "memory not initialized"  these lines of code are inside the sub

    SCREEN _NEWIMAGE(W, (ABS(H)), 32)
    _PUTIMAGE (0, 0), HANDLE
    _MEMFREE a

the  _MEMFREE a  is throwing the error

*******
later   DIM SHARED a AS _MEM

fixed that error
Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 09, 2021, 09:46:24 pm
@NOVARSEG

Once you get image loaded under handle you should be able to just pass handle back to main code through a Function that has type Long & on end of it's name.

I've got you started in BMP thread.
Title: Re: Pipecom Browser for Filename$
Post by: NOVARSEG on February 09, 2021, 10:06:30 pm
I  have a SUB working

SUB loadBMP24 (FILENAME AS STRING, W AS LONG, H AS LONG, HANDLE AS LONG)

returns W  width of BMP
returns  H height of BMP
returns handle   generated from   " HANDLE = _NEWIMAGE(W, ABS(H), 32) "
input Filename


the SUB  does not display any image. That has to be done outside the SUB

Over to the other thread
Title: Re: Pipecom Browser for Filename$
Post by: SMcNeill on February 09, 2021, 10:12:16 pm
Since you guys are almost done reinventing the wheel (24-bit BMP loader in this case), I’d like to also refer you to the wiki: https://www.qb64.org/wiki/Bitmaps

With it as a reference, you can expand and load 1, 4, 8 bit BMP files too, next.  :)
Title: Re: Pipecom Browser for Filename$
Post by: NOVARSEG on February 09, 2021, 11:51:00 pm
Gonna try LOADIMAGE one day :)
Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 10, 2021, 12:43:12 am
Gonna try LOADIMAGE one day :)

Pipecom Browser 3 All da Images! Kicks Butt with BMP24 files, gets them right, in fact this is faster than Windows.
But my fan is running?
Code: QB64: [Select]
  1. _Title "Pipecom Browser for BMP24 File Display" 'b+ testing one array system with pipecom
  2. ' Thanks to Spriggsy, Zak, for convincing me pipecom is better!
  3. ' Using Steve's fixed BMP24 loader
  4. ' Also thanks to Dav for 1 window for file and folder selection idea
  5. ' Also thanks to NOVARSEG who got me going on this for a better filename$ retriever
  6. ' 2021-02-10 Browser 2 update with LoadBMP24 Sub
  7. ' 2021-02-10 Browser 3, just _Loadimage
  8.  
  9. Declare Library "pipecom"
  10.     Function pipecom$ (cmd As String)
  11.  
  12. Screen _NewImage(1280, 740, 32)
  13. _Delay .25
  14. _ScreenMove 65, 0 ' your screen might need different
  15.  
  16. ReDim myFile$
  17. ReDim As Long col, row, charW, charH, W, H, image
  18. Color , &HFF000033
  19. Do 'test our new function
  20.     ScnState 0
  21.     col = 16: row = 3: charW = 128: charH = 40
  22.     myFile$ = GetFileName$(row, col, charW, charH)
  23.     ScnState -1 ' <<<<<<<<<<<<<<<<<<<<<<<<<<< this is supposed to restore back color
  24.     'image& = loadBMP24&(myFile$)
  25.     image = _LoadImage(myFile$)
  26.     'loadBMP24 myFile$, W, H, image
  27.     Color , &HFF000033
  28.     Cls
  29.     If image <> 0 Then
  30.         _Title myFile$ + " press any to get another BMP24 file image, esc to quit"
  31.         _PutImage ((_Width - _Width(image&)) / 2, (_Height - _Height(image&)) / 2)-Step(_Width(image&), _Height(image&)), image&, 0
  32.         Sleep
  33.         _FreeImage image&
  34.     End If
  35.  
  36. Function GetFileName$ (LocateR, LocateC, CharWide, CharHigh) ' < careful Locate Row, Col NOT x, y
  37.     'This Funtion needs:
  38.     ' pipecom.h in same folder as QB64.exe
  39.     ' This in main code section near top:
  40.     ' Declare Library "pipecom"
  41.     '    Function pipecom$ (cmd As String)
  42.     ' End Declare
  43.     ' sub  Split source$, delimiter$, arr$()
  44.     ' function GetArrayItem$(x, y, w, h, arr$())
  45.  
  46.     ReDim As String d, s, dr
  47.     ReDim As _Unsigned Long fc, bc
  48.     fc = _DefaultColor: bc = _BackgroundColor ' save colors
  49.     Getfolder:
  50.     Color fc, bc: Cls
  51.     d = pipecom("dir /n /o:gend") '/n files on right (40) /o = order g for group dirs first, e extension, name, date
  52.     d = Left$(d, Len(d) - 1) ' always ends with delimiter
  53.     ReDim dir(1 To 1) As String
  54.     Split d, Chr$(10), dir()
  55.     s = GetArrayItem$(LocateR, LocateC, CharWide, CharHigh, dir())
  56.     If InStr(s, "<DIR>") Then 'isolate name
  57.         dr = _Trim$(Mid$(s, InStr(s, "<DIR>") + 6))
  58.         ChDir dr
  59.         GoTo Getfolder
  60.     ElseIf InStr(s, "AM") Or InStr(s, "PM") Then
  61.         GetFileName$ = _Trim$(Mid$(s, 40))
  62.         Color fc, bc: Cls
  63.     ElseIf s = "" Then 'cancel, escape, bad line
  64.         Color fc, bc: Cls ' will return empty string
  65.     End If
  66.  
  67. Sub Split (SplitMeString As String, delim As String, loadMeArray() As String)
  68.     Dim curpos As Long, arrpos As Long, LD As Long, dpos As Long 'fix use the Lbound the array already has
  69.     curpos = 1: arrpos = LBound(loadMeArray): LD = Len(delim)
  70.     dpos = InStr(curpos, SplitMeString, delim)
  71.     Do Until dpos = 0
  72.         loadMeArray(arrpos) = Mid$(SplitMeString, curpos, dpos - curpos)
  73.         arrpos = arrpos + 1
  74.         If arrpos > UBound(loadMeArray) Then ReDim _Preserve loadMeArray(LBound(loadMeArray) To UBound(loadMeArray) + 1000) As String
  75.         curpos = dpos + LD
  76.         dpos = InStr(curpos, SplitMeString, delim)
  77.     Loop
  78.     loadMeArray(arrpos) = Mid$(SplitMeString, curpos)
  79.     ReDim _Preserve loadMeArray(LBound(loadMeArray) To arrpos) As String 'get the ubound correct
  80.  
  81.  
  82. ' Help: all this I hope is intuitive so Help window is provided
  83. ' "Mouse, mouse wheel, and arrow keys should work as expected for item selection."
  84. ' "Press spacebar to select a highlighted item or just click it."
  85. ' "Use number(s) + enter to select an array item by it's index number,"
  86. ' "backspace will remove last number pressed, delete will clear a number started.
  87. ' "Numbers started are shown in bottom right PgDn bar."
  88. ' "Enter will also select the highlighted item, if no number has been started."
  89. ' "Home starts you at lowest array index, End highlights then highest index."
  90. ' "Use PgUp and PgDn keys to flip through pages of array items."
  91. '
  92. ' Escape to Cancel Return "" else Return the selected string from the array
  93. Function GetArrayItem$ (LocateRoww, LocateColumn, BoxWidth, BoxHeight, Arr() As String)
  94.     'Notes: locateRow, locateColumn for top right corner of selection box on screen in characters for LOCATE.
  95.     'boxWidth and boxHeight are in character units, again for locate and print at correct places.
  96.     'All displaying is restricted to inside the box, which has PgUP and PgDn as top and bottom lines in the display.
  97.  
  98.     ReDim As Long maxWidth, maxHeight, page, hlite, mx, my, locateRow, lastMX, lastMY, row, mb
  99.     ReDim As Long lba, uba, choice, kh, index
  100.     Dim clrStr As String, b As String
  101.  
  102.     'ScnState 0 ' use out side this function before and after
  103.     locateRow = LocateRoww + 1 'fix a miscalc in coding
  104.     maxWidth = BoxWidth '       number of characters in box
  105.     maxHeight = BoxHeight - 2 ' number of lines displayed of array at one time = 1 page
  106.     lba = LBound(arr)
  107.     uba = UBound(arr)
  108.     page = 0
  109.     hlite = 0 '                 line in display ready for selection by spacebar or if no number is started, enter
  110.     clrStr$ = Space$(maxWidth) 'clearing a display line
  111.  
  112.     GoSub update '              show the beginning of the array items for selection
  113.     choice = -1719
  114.     Do 'until get a selection or demand exit
  115.  
  116.         'handle the key stuff
  117.         kh& = _KeyHit
  118.         If kh& Then
  119.             If kh& > 0 And kh& < 255 Then
  120.                 If InStr("0123456789", Chr$(kh&)) > 0 Then
  121.                     b$ = b$ + Chr$(kh&): GoSub update
  122.                 ElseIf kh& = 13 Then 'enter pressed check if number is being entered?
  123.                     If Len(b$) Then
  124.                         If Val(b$) >= lba And Val(b$) <= uba Then 'we have number started
  125.                             choice = Val(b$): Exit Do
  126.                         Else 'clear b$ to show some response to enter
  127.                             b$ = "": GoSub update 'clear the value that doesn't work
  128.                         End If
  129.                     Else
  130.                         choice = hlite + page * maxHeight + lba 'must mean to select the highlighted item
  131.                     End If
  132.                 ElseIf kh& = 27 Then
  133.                     Exit Do 'escape clause offered to Cancel selection process
  134.                 ElseIf kh& = 32 Then
  135.                     choice = hlite + page * maxHeight + lba 'best way to choose highlighted selection
  136.                 ElseIf kh& = 8 Then 'backspace to edit number
  137.                     If Len(b$) Then b$ = Left$(b$, Len(b$) - 1): GoSub update
  138.                 End If
  139.             Else
  140.                 Select Case kh& 'choosing sections of array to display and highlighted item
  141.                     Case 21248 ' delete so clear b$
  142.                         b$ = "": GoSub update
  143.                     Case 20736 ' pg dn
  144.                         If (page + 1) * maxHeight + lba <= uba Then page = page + 1: GoSub update
  145.                     Case 18688 ' pg up
  146.                         If (page - 1) * maxHeight + lba >= lba Then page = page - 1: GoSub update
  147.                     Case 18432 ' up
  148.                         If hlite - 1 < 0 Then
  149.                             If page > 0 Then
  150.                                 page = page - 1: hlite = maxHeight - 1: GoSub update
  151.                             End If
  152.                         Else
  153.                             hlite = hlite - 1: GoSub update
  154.                         End If
  155.                     Case 20480 'down
  156.                         If (hlite + 1) + page * maxHeight + lba <= uba Then 'ok to move up
  157.                             If hlite + 1 > maxHeight - 1 Then
  158.                                 page = page + 1: hlite = 0: GoSub update
  159.                             Else
  160.                                 hlite = hlite + 1: GoSub update
  161.                             End If
  162.                         End If
  163.                     Case 18176 'home
  164.                         page = 0: hlite = 0: GoSub update
  165.                     Case 20224 ' end
  166.                         page = Int((uba - lba) / maxHeight): hlite = maxHeight - 1: GoSub update
  167.                 End Select
  168.             End If
  169.         End If
  170.  
  171.         'handle the mouse stuff
  172.         While _MouseInput
  173.             If _MouseWheel = -1 Then 'up?
  174.                 If hlite - 1 < 0 Then
  175.                     If page > 0 Then
  176.                         page = page - 1: hlite = maxHeight - 1: GoSub update
  177.                     End If
  178.                 Else
  179.                     hlite = hlite - 1: GoSub update
  180.                 End If
  181.             ElseIf _MouseWheel = 1 Then 'down?
  182.                 If (hlite + 1) + page * maxHeight + lba <= uba Then 'ok to move up
  183.                     If hlite + 1 > maxHeight - 1 Then
  184.                         page = page + 1: hlite = 0: GoSub update
  185.                     Else
  186.                         hlite = hlite + 1: GoSub update
  187.                     End If
  188.                 End If
  189.             End If
  190.         Wend
  191.         mx = Int((_MouseX - LocateColumn * 8) / 8) + 2: my = Int((_MouseY - locateRow * 16) / 16) + 2
  192.         If _MouseButton(1) Then 'click contols or select array item
  193.             'clear mouse clicks
  194.             mb = _MouseButton(1)
  195.             If mb Then 'clear it
  196.                 While mb 'OK!
  197.                     If _MouseInput Then mb = _MouseButton(1)
  198.                     _Limit 100
  199.                 Wend
  200.             End If
  201.  
  202.             If mx >= 1 And mx <= maxWidth And my >= 1 And my <= maxHeight Then
  203.                 choice = my + page * maxHeight + lba - 1 'select item clicked
  204.             ElseIf mx >= 1 And mx <= maxWidth And my = 0 Then 'page up or exit
  205.                 If my = 0 And (mx <= maxWidth And mx >= maxWidth - 2) Then 'exit sign
  206.                     Exit Do 'escape plan for mouse click top right corner of display box
  207.                 Else 'PgUp bar clicked
  208.                     If (page - 1) * maxHeight + lba >= lba Then page = page - 1: GoSub update
  209.                 End If
  210.             ElseIf mx >= 1 And mx <= maxWidth And my = maxHeight + 1 Then 'page down bar clicked
  211.                 If (page + 1) * maxHeight + lba <= uba Then page = page + 1: GoSub update
  212.             End If
  213.         Else '   mouse over highlighting, only if mouse has moved!
  214.             If mx >= 1 And mx <= maxWidth And my >= 1 And my <= maxHeight Then
  215.                 If mx <> lastMX Or my <> lastMY Then
  216.                     If my - 1 <> hlite And (my - 1 + page * maxHeight + lba <= uba) Then
  217.                         hlite = my - 1
  218.                         lastMX = mx: lastMY = my
  219.                         GoSub update
  220.                     End If
  221.                 End If
  222.             End If
  223.         End If
  224.         _Limit 200
  225.     Loop Until choice >= lba And choice <= uba
  226.     If choice <> -1719 Then GetArrayItem$ = Arr(choice) 'set function and restore screen
  227.     'ScnState -1 'restore
  228.  
  229.     'display of array sections and controls on screen  ====================================================
  230.     update:
  231.  
  232.     'fix hlite if it has dropped below last array item
  233.     While hlite + page * maxHeight + lba > uba
  234.         hlite = hlite - 1
  235.     Wend
  236.  
  237.     'main display of array items at page * maxHeight (lines high)
  238.     For row = 0 To maxHeight - 1
  239.         If hlite = row Then Color _RGB(200, 200, 255), _RGB32(0, 0, 88) Else Color _RGB32(0, 0, 88), _RGB(200, 200, 255)
  240.         Locate locateRow + row, LocateColumn: Print clrStr$;
  241.         index = row + page * maxHeight + lba
  242.         If index >= lba And index <= uba Then
  243.             Locate locateRow + row, LocateColumn
  244.             Print Left$(LTrim$(Str$(index)) + ") " + Arr(index), maxWidth);
  245.         End If
  246.     Next
  247.  
  248.     'make page up and down bars to click, print PgUp / PgDn if available
  249.     Color _RGB32(200, 200, 255), _RGB32(0, 100, 50)
  250.     Locate locateRow - 1, LocateColumn: Print Space$(maxWidth);
  251.     If page <> 0 Then Locate locateRow - 1, LocateColumn: Print Left$(" Pg Up" + Space$(maxWidth), maxWidth);
  252.     Locate locateRow + maxHeight, LocateColumn: Print Space$(maxWidth);
  253.     If page <> Int(uba / maxHeight) Then
  254.         Locate locateRow + maxHeight, LocateColumn: Print Left$(" Pg Dn" + Space$(maxWidth), maxWidth);
  255.     End If
  256.     'make exit sign for mouse click
  257.     Color _RGB32(255, 255, 255), _RGB32(200, 100, 0)
  258.     Locate locateRow - 1, LocateColumn + maxWidth - 3
  259.     Print " X ";
  260.  
  261.     'if a number selection has been started show it's build = b$
  262.     If Len(b$) Then
  263.         Color _RGB(255, 255, 0), _RGB32(0, 0, 0)
  264.         Locate locateRow + maxHeight, LocateColumn + maxWidth - Len(b$) - 1
  265.         Print b$;
  266.     End If
  267.     _Display
  268.     _Limit 100
  269.     Return
  270.  
  271. Sub ScnState (restoreTF As Long) 'Thanks Steve McNeill  should we get a snap shot of screen?
  272.     Static As _Unsigned Long defaultColor, backGroundColor
  273.     Static As Long font, dest, source, row, col, autodisplay, mb, snap
  274.     If restoreTF Then
  275.         _Font font
  276.         Color defaultColor, backGroundColor
  277.         _Dest dest
  278.         _Source source
  279.  
  280.         _KeyClear
  281.         While _MouseInput: Wend 'clear mouse clicks
  282.         mb = _MouseButton(1)
  283.         If mb Then 'need this if line ?
  284.             Do
  285.                 While _MouseInput: Wend
  286.                 mb = _MouseButton(1)
  287.                 _Limit 100
  288.             Loop Until mb = 0
  289.         End If
  290.         _PutImage , snap, dest
  291.         _FreeImage snap
  292.         _Display
  293.         If autodisplay Then _AutoDisplay Else _Display
  294.         Locate row, col
  295.     Else
  296.         snap = _NewImage(_Width, _Height, 32)
  297.         _PutImage , 0, snap
  298.         font = _Font: defaultColor = _DefaultColor: backGroundColor = _BackgroundColor
  299.         dest = _Dest: source = _Source
  300.         row = CsrLin: col = Pos(0): autodisplay = _AutoDisplay
  301.         While _MouseInput: Wend 'clear mouse clicks
  302.         mb = _MouseButton(1)
  303.         If mb Then 'need this if line ?
  304.             Do
  305.                 While _MouseInput: Wend
  306.                 mb = _MouseButton(1)
  307.                 _Limit 100
  308.             Loop Until mb = 0
  309.         End If
  310.         _KeyClear
  311.     End If
  312.  
  313.  

You will need this in your QB64.exe file:


Title: Re: Pipecom Browser for Filename$
Post by: NOVARSEG on February 10, 2021, 02:15:49 am
 

fast viewer.   Gonna do another ver of BMP 24 viewer for speed.
Title: Re: Pipecom Browser for Filename$
Post by: Aurel on February 10, 2021, 03:21:41 am
 (won't Aurel be thrilled?)

Youhooooo Mark....
very nice ......
Title: Re: Pipecom Browser for Filename$
Post by: johnno56 on February 10, 2021, 04:23:30 pm
If someone could provide a Linux command that produces a Directory Listing that distinguishes Files from Folders and provides a Sample Output Directory, I could adapt this for Linux.

@johnno56  can you help with this?
Title: Re: Pipecom Browser for Filename$
Post by: STxAxTIC on February 10, 2021, 04:24:07 pm
If someone could provide a Linux command that produces a Directory Listing that distinguishes Files from Folders and provides a Sample Output Directory, I could adapt this for Linux.

@johnno56  can you help with this?

idk, can you?
Title: Re: Pipecom Browser for Filename$
Post by: johnno56 on February 10, 2021, 04:47:42 pm
Ho Ho. It is to laugh... lol

I was replying and hit ENTER before I had finished... Doh!

BPlus,

The commands 'ls' and 'dir' will display current directory contents. Main difference... the 'ls' command will display directories, executables and files in different colours. 'dir' is only white. Adding '-l' to the command will give a detailed list. To easily distinguish folders, commands and files, 'ls' or ls -l' would be the best.

There is probably a better way to do this but these are the commands that "I" use....

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 10, 2021, 04:53:25 pm
OK
If someone could provide a Linux command that produces a Directory Listing that distinguishes Files from Folders and provides a Sample Output Directory, I could adapt this for Linux.

@johnno56  can you help with this?

I think it's "dir -F" I looked it up a couple days ago.
Code: QB64: [Select]
  1. 'make sure pipecom.h is in same folder as QB64.exe
  2. Declare Library "pipecom"
  3.     Function pipecom$ (cmd As String)
  4. F$ = pipecom("dir -F")
  5. print F$ 'see it
  6. _clipboard = F$ 'copy to clipboard
  7.  
If that works, get a copy of output to _clipboard, paste _clipboard into text file. Then paste a copy of txt file here.
I need to know if uses tabs or spaces in output and amount of spacing.

Then I can see how to parse output.

@johnno56   OK you posted but can't read colors from text string, try above instructions.

I know I can read Folders from a dir command because they end in a slash.
Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 10, 2021, 05:03:25 pm
@johnno56  I updated instructions in above post.
Title: Re: Pipecom Browser for Filename$
Post by: johnno56 on February 10, 2021, 05:05:27 pm
I figured you might have issues with the colours.The colours would change with the overall theme of the desktop...
Anyway, I tried the 'dir -F' and all the directories ended in a slash.

I also tried running the the program , as is, and received a "illegal string-number conversion on line 1"
Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 10, 2021, 05:11:04 pm
I figured you might have issues with the colours.The colours would change with the overall theme of the desktop...
Anyway, I tried the 'dir -F' and all the directories ended in a slash.

I also tried running the the program , as is, and received a "illegal string-number conversion on line 1"

That's the line to the Declare Library? can't be the comment!

Well the ball is now in @SpriggsySpriggs  's court!

@johnno56  to be sure our bases are covered, you do have pipecom.h file copy in your QB64.exe Folder?
Title: Re: Pipecom Browser for Filename$
Post by: johnno56 on February 10, 2021, 05:11:46 pm
You were updating your listing as I was forming my last post.

Updated my listing. Ran it. "Invalid name on line 7"
Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 10, 2021, 05:13:14 pm
Try $ on the end of _Clipboard$ <====
Title: Re: Pipecom Browser for Filename$
Post by: johnno56 on February 10, 2021, 05:14:48 pm
No. The pipecom.h is on my Desktop but the listing path was modified.
Title: Re: Pipecom Browser for Filename$
Post by: johnno56 on February 10, 2021, 05:15:30 pm
Adding the $ did it... nicely done...
Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 10, 2021, 05:16:18 pm
No. The pipecom.h is on my Desktop but the listing path was modified.

Well that won't work has to be where QB64.exe can get it.
Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 10, 2021, 05:17:36 pm
Adding the $ did it... nicely done...

Oh, can I get a txt copy, please? Or do you want to try a parsing yourself?
Title: Re: Pipecom Browser for Filename$
Post by: johnno56 on February 10, 2021, 05:27:26 pm
Ok. Normally I put 'test' programs on my desktop and transfer them if and when they work.

Both '.bas' and .h' files are now in the QB64 directory. Used 'F$ = pipecom("dir -F > pipecom.txt")' to produce a text file. See attached.

Parsed? Not sure what you mean. I'm only familiar with that term in regards to text adventures... lol

Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 10, 2021, 05:43:17 pm
OK, got it. Thanks @johnno56

That's one folder?

And appears to be 2 columns but the 2nd column is a little 'all over' ;-))

I bet some kind of tabs are in there.

Parse - is just breaking down a string into more usable units of data using different string functions.
This depends on the strings having some sort of dependable or predictable structure or pattern.
Title: Re: Pipecom Browser for Filename$
Post by: SpriggsySpriggs on February 10, 2021, 11:07:40 pm
This doesn't sound like an error on pipecom's side
Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 10, 2021, 11:40:37 pm
This doesn't sound like an error on pipecom's side

No, just going to be a challenge to make a list and preferably get all the directories at the top of the list.

I am kind of busy trying to figure out how to get ElseIf blocks into my Interpreter this time around.
(and yet I keep checking in here ;-))

OK piece of cake, it's just tabbing out to some 2nd column, displayed in Notepad++ it looked like hell.
Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 11, 2021, 12:07:26 am
@johnno56

Does the command 'dir -F" always make a 2 column list, or does it pick the longest name and make the column widths as narrow as possible to fit the maximum number of names in a minimum number of lines?

OK I am assuming a width of 80 chars for lines, could be 90 so 2nd column at 45 divides in 2 the screen.

Title: Re: Pipecom Browser for Filename$
Post by: johnno56 on February 11, 2021, 12:28:00 am
To tell you the truth, I've never taken much notice of the display format... The standard Terminal screen size is 80 cards x 24 lines.

This is dir -F and dir -F -l.  I have only expanded the height to demonstrate both commands.

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Widening the Terminal, prior to the dir -F, seems to create consistent columns.

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

I hope this helps.

J
Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 11, 2021, 12:42:26 am
Man I was all set to assume 2nd column always 45 but doubt that very much! After seeing last shots.

I think number of columns depends on longest filename.

dir -F -l looks interesting it's a nice one column list but I wonder if the column of interest, the last which is all we want, might be different for different people ie if "john john" were longer for another person.

BTW If I told Linux to
Code: QB64: [Select]
  1. ChDir Android/

in Basic Code would it? Or does slash have to be removed.

Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 11, 2021, 12:54:29 am
@johnno56

Any commands that gets just a plain 1 column list of just filenames or folders?
Title: Re: Pipecom Browser for Filename$
Post by: johnno56 on February 11, 2021, 05:38:39 pm
I have only needed dir or ls when dealing with directories. There are probably a whole swag of commands but I have not had the need to use them or to learn what they are... I know this is not very helpful... In the early days of my Linux experience, using the command line, was more widely used. The advent of better GUI's meant less use of the command line....
Title: Re: Pipecom Browser for Filename$
Post by: bplus on February 11, 2021, 07:39:43 pm
I have only needed dir or ls when dealing with directories. There are probably a whole swag of commands but I have not had the need to use them or to learn what they are... I know this is not very helpful... In the early days of my Linux experience, using the command line, was more widely used. The advent of better GUI's meant less use of the command line....

@johnno56  I probably think of you first when I want cross platform for at least Linux. I thank you again for all your assistance and feedback from that other OS.
Title: Re: Pipecom Browser for Filename$
Post by: johnno56 on February 11, 2021, 11:05:47 pm
"Other" OS? Do you not mean, "The" OS?  lol
Title: Re: Pipecom Browser for Filename$
Post by: SpriggsySpriggs on February 11, 2021, 11:12:56 pm
@johnno56

So you're a Linux guy? Any sort of thing (C++/POSIX-wise) you have on a wishlist for functions in Linux QB64? Linux is fun to mess with
Title: Re: Pipecom Browser for Filename$
Post by: johnno56 on February 12, 2021, 04:20:46 pm
100% Linux since 2005.... and no, nothing really to add to QB64. Quite happy with the way it functions.

A wish-list. Interesting.

I usually work with  a series of "steps". Create concept. Is it feasible with the tools at hand. If so develop and produce. Otherwise move on to the next concept. "Wishing" for something, in my opinion, does not make it real or happen. But that is just me... lol

With that being said... Most 'Basics' are designed for 2D. Having a Physics engine (like Box2D) and a Particle System, 'built in', would be beneficial for 'any' Basic...

Yep. Happy with QB64.