Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - mdijkens

Pages: 1 [2] 3
16
Programs / Re: A skeleton code for Text Scroller via Drag-and-Drop
« on: March 14, 2022, 04:45:19 am »
Very interesting thread! Thank you!

I am regularly working with really big files (some over to 100GB) and have been optimizing 2 functions to read/process big files very fast.

I thought I'd add them here for information:

Code: QB64: [Select]
  1. Function readBigFile~&& (file$) '1.5GB/sec
  2.   Const BLOCKSIZE = 4194304 '=64*65536 = 4 MB
  3.   fsize~&& = fileSize(file$)
  4.   Dim mem As _MEM: mem = _MemNew(fsize~&& + BLOCKSIZE)
  5.   Dim block As String * BLOCKSIZE '=64*65536
  6.   filenum% = FreeFile
  7.   Open file$ For Random Access Read As filenum% Len = BLOCKSIZE
  8.   blocks~& = .5 + (fsize~&& / BLOCKSIZE)
  9.   For blck~& = 1 To blocks~&
  10.     Get filenum%, , block
  11.     _MemPut mem, mem.OFFSET + mpos~&&, block
  12.     mpos~&& = mpos~&& + BLOCKSIZE
  13.   Next blck~&
  14.   Close filenum%
  15.         ' Process mem
  16.   _MemFree mem
  17.   readBigFile~&& = fsize~&&
  18.  
  19. Function fileSize~&& (file$)
  20.   If Not _FileExists(file$) Then fileSize~&& = 0: Exit Function
  21.   filenum% = FreeFile
  22.   Open file$ For Binary Access Read As filenum%
  23.   fileSize~&& = LOF(filenum%)
  24.   Close filenum%
  25.  

and for csv's:
Code: QB64: [Select]
  1. Function CSV.read& (fileName$, eol$) ' 4M lines/sec
  2.   Const BLOCKSIZE = 4194304 '=64*65536 = 4 MB
  3.   If Not _FileExists(fileName$) Then CSV.read& = 0: Exit Function
  4.   'Print "Reading lines from "; fileName$; " ";: cpos% = Pos(0) '@@ progress info
  5.   eoll% = Len(eol$)
  6.   Dim block As String * BLOCKSIZE
  7.   ff% = FreeFile
  8.   Open fileName$ For Binary Access Read As #ff%
  9.   blocks& = .5 + LOF(ff%) / Len(block)
  10.   sep& = 0
  11.   lines& = -1
  12.   For curblock& = 1 To blocks&
  13.     Get #ff%, , block
  14.     If curblock& > 1 Then
  15.       buf$ = Mid$(buf$, sep&) + block
  16.       r0& = InStr(buf$, eol$) + eoll%
  17.     Else
  18.       buf$ = block 'Mid$(block, InStr(block, Chr$(10)) + 1)
  19.       r0& = 1
  20.     End If
  21.     r1& = InStr(r0&, buf$, eol$)
  22.     Do While r1& >= r0& And r0& > 0
  23.       lin$ = Mid$(buf$, r0&, r1& - r0& + eoll%)
  24.       ' Process lin$
  25.       lines& = lines& + 1
  26.       sep& = r1&: r0& = r1& + eoll%: r1& = InStr(r0&, buf$, eol$)
  27.     Loop
  28.     'Locate , cpos%, 0: Print lines&; '@@ progress info
  29.   Next curblock&
  30.   Close #ff%
  31.   buf$ = ""
  32.   'Locate , cpos%, 0 '@@ progress info
  33.   CSV.read& = lines&
  34.  

17
QB64 Discussion / Re: Has $Debug been working well for you?
« on: March 09, 2022, 07:27:01 pm »
@mdijkens don't hold high hopes for watching expressions, don't forget it's compiled code we're dealing with, and that request would require a full-blown interpreter to be integrated, which is not our goal in the end.

I can totally understand the issue there. PDS ran in some intermediate debug/interpreted mode (also slower then final compiled/linked program. Instant watch variables would already be very valuable.

18
QB64 Discussion / Re: Has $Debug been working well for you?
« on: March 09, 2022, 05:37:31 pm »
Actually, this would also be solved with an 'Instant Watch' implementation as PDS had:
You don't have to look for a variable in a list (which could be very long), but you can just select any variable (also when declared in an include-file)

With 'Instant Watch' not only could you put your cursor on a variable in the source and press Shift-F9 to view it and then Enter to add it to the watchlist (or Esc if you don't need that), but you could also select any (complex) expression in the source and do the same. e.g. select Val(Mid$(Str$(var!), Instr(Mid$(Str$(var!),"."))+1)) as a watch-value.

19
QB64 Discussion / Re: Some info regarding $IF precompiler directives
« on: March 08, 2022, 12:01:41 pm »
And it also determines if it gets compiled/linked in your executable and thus (not) include certain libraries

Code: QB64: [Select]
  1. $Let MYLOG = 1
  2.  
  3. Sub log (l$)
  4.   $If MYLOG = DEFINED Then
  5.  
  6.   $End If
  7.  

20
QB64 Discussion / Re: Has $Debug been working well for you?
« on: March 08, 2022, 10:10:57 am »
@mdijkens Great to hear! The variable lookup is planned for a future update, I'll keep you posted.

That is really cool!
I remember I used 'instant watch' more then regular watch-list.
Imagine you put a breakpoint in the troublesome code, use F8 and Shift-F8 to walk through it
and at any time quickly look at any variable with Shift-F9 Esc, other variable Shift F9 Esc, etc.
Way quicker then searching variable list or typing an expression to add it to the watch list

21
QB64 Discussion / Re: Has $Debug been working well for you?
« on: March 08, 2022, 09:44:14 am »
Very happy with $Debug
It is not in my system yet to automatically think about using it, but that happens more and more until I don't know any better :-)

One minor thing missing that I really loved in PBDS7 was to put a cursor on any variable and press Shift-F9 to lookup it's value and then Enter to add it to watch-list.

22
QB64 Discussion / Re: &H colors dont work as CONST
« on: March 06, 2022, 12:04:50 pm »
I would expect CONST values to match assigned type or condition?
So
Const MYCONST = &HFFFF
a% = MYCONST ' -1
a~% = MYCONST ' 65536
a&= MYCONST '65536

Same with comparing in conditions

23
QB64 Discussion / No Sound on Mac
« on: March 06, 2022, 03:35:46 am »
Let me start by saying that I have absolutely zero knowledge or experience on Mac!

I'm trying to compile one of my qb64 programs I made on Mac
I followed the Mac install, nothing else.
I had to change most code that deals with filenames/paths (e.g. / instead of \ etc.)
The program runs without any errors now, but there is no sound.
After some small tests with _SndPlay & _SndPlayFile, I made it even simpler by testing Beep and Play("cde"), but No sound at all is generated?
I also tested youtube in the browser to see if the laptop could produce sound at al or if sound was muted or not configured, but youtube sounds fine.

Is there something on Mac that I forgot/need to do to have sound in qb64 compiled programs?
Again, I have zero Mac knowledge so maybe even something very basic is needed?

24
QB64 Discussion / Re: Printing Color using LPRINT
« on: March 04, 2022, 02:21:20 pm »
Use _PRINTIMAGE for that:
https://wiki.qb64.org/wiki/PRINTIMAGE

25
QB64 Discussion / Re: how to time something (ie do loop for n seconds)
« on: February 28, 2022, 06:15:25 pm »
If it is important without an extra condition
Code: QB64: [Select]
  1. Tim! = Timer
  2. Do While (86400 + Timer - Tim!) Mod 86400 < 10
  3.   ' Try something over and over again for 10 seconds
  4.  

26
QB64 Discussion / Re: how to time something (ie do loop for n seconds)
« on: February 28, 2022, 05:35:39 pm »
One caveat here:  You *can* experience bugs with this after midnight.

Program starts at 23:59:59.  Add three seconds -- 24:00:02...  (In seconds, and not hours and minutes like this, though hours and minutes are easier to visualize.)

Clock hits midnight:  0:00:00

At no point will you ever have TIMER become greater than t#.

If it is not that critical for normal situations I always used:

Code: QB64: [Select]
  1. Tim! = Timer
  2. Do While Abs(Timer - Tim!) < 10
  3.   ' Try something over and over again for 10 seconds
  4.  

and yes, around midnight you might have one shorter loop, but in most cases that's not so critical

27
QB64 Discussion / Re: Windows Notification sample
« on: February 28, 2022, 05:29:35 pm »
Yes, running 64bit.
I would be very happy if you could have a look at it again

28
QB64 Discussion / Re: Command$ parses wildcards in paths
« on: February 28, 2022, 02:11:00 pm »
Are you sure QB64 is the one returning multiple files for wildcard command and not Windows?
Being passed through Windows on command line, Windows may be the interfering source of the problem.

(I am pissed at Windows today, very! freak'n 150 background processes own my computer and ties it up for fractions of hour!) I do diagnostics, everything working fine blah!

I'm  sure. Windows GetCommandLineA returns unmodified params.
And yes, we're all pissed at Windows every now and then :-)
(Remembering the good old days of MS-DOS and PDS 7.1)

29
QB64 Discussion / Re: Command$ parses wildcards in paths
« on: February 28, 2022, 11:49:28 am »
Allright then. I still regards it as inconsistency, but no crying over spilled milk ;-)
I propose, you decide; no problemo.

I've worked around it now like this:
Code: QB64: [Select]
  1. Function getCommand$ (n%)
  2.   Static cmd$(100), ccount As Integer
  3.   If cmd$(0) = "" Then
  4.       Function GetCommandLineA%& ()
  5.     End Declare
  6.     Dim m As _MEM, ms As String * 1000
  7.     a%& = GetCommandLineA: m = _Mem(a%&, Len(ms)): ms = _MemGet(m, m.OFFSET, String * 1000)
  8.     ccount = 0: sp0% = 1: sp1% = InStr(ms, " ")
  9.     Do While sp1% > 0
  10.       cmd$(ccount) = _Trim$(Mid$(ms, sp0%, sp1% - sp0%))
  11.       If cmd$(ccount) <> "" Then ccount = ccount + 1
  12.       sp0% = sp1% + 1: sp1% = InStr(sp1% + 1, ms, " ")
  13.     Loop
  14.     cmd$(ccount) = _Trim$(Mid$(ms, sp0%)): If Left$(cmd$(ccount), 1) = Chr$(0) Then ccount = ccount - 1
  15.     _MemFree m
  16.   End If
  17.   If n% < 0 Then
  18.     getCommand$ = _Trim$(Str$(ccount))
  19.   ElseIf n% <= ccount Then
  20.     getCommand$ = cmd$(n%)
  21.   Else
  22.     getCommand$ = ""
  23.   End If
  24.  

30
QB64 Discussion / Re: Command$ parses wildcards in paths
« on: February 28, 2022, 10:16:14 am »
You don't have to make your users do it. You do it and then undo it in code and no one has to know :)

How can I do it?
When entering my program it is already expanded without any possibility for me to stop that from happening?

I'd really want to preserve a way for developers to receive the exact text as passed by the user.
If I want users for example to specify myexe *.ico /s to also include subdirs, there's no way for me to find that out anymore in code :-(
with double quotes the problem persists and single quotes are really not a standard in windows environments

Programmers might have to revert to more complex winapi's to get to the untouched parameters (is that even possible) like it used to be in the old days

Until now, I've always been under the impression that qb64 wants to keep as close as possible to qb4/4.5 PDS7/7.1 and use _NewCommands for new or changed functionality
So especially in this case I can imagine having a Command$ (qb compatible) and _XCommand$ for expanding makes sense

Please reconsider or provide an easy option to retrieve the original parameterstring in code...

Pages: 1 [2] 3