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 - SMcNeill

Pages: [1] 2 3 ... 265
1
QB64 Discussion / Re: SEEK # or not SEEK #
« on: April 15, 2022, 02:47:14 pm »
The # is optional in the SEEK statement.

SEEK #52, 1

is the same thing as

SEEK 52, 1

Think of it as being similar to the LET statement.  :)



And Seek works for all our modes -- it just works differently in RANDOM.

Let's say I have a data file that looks like:

ABCDEFGHIJKLMNO

16 bytes in that data file, correct?  (A to O is the file)

Now, if we OPEN thatfile FOR Input, Output, or Binary....

SEEK thatfile, 3   <-- this just moved our file marker to being in front of the third byte -- the "C".

Now, if we OPEN thatfile FOR Random ...  LEN = 4

SEEK thatfile, 3   <-- this just moved the file marker to being in front of the third RECORD -- the "I".  (Since we set our record size as being 4 bytes.  Record 1 is ABCD.  Record 2 is EFGH.  The start of record three is before the "I".)

Seek, with Random files works by records.  With everything else, it works by byte position.

2
QB64 Discussion / Re: An introduction; A note on Wiki
« on: April 15, 2022, 01:26:05 pm »
Makes the whole sub static.

3
QB64 Discussion / Re: An introduction; A note on Wiki
« on: April 15, 2022, 01:01:59 pm »
Always glad to hear when someone enjoys any of my stuff.  Many thanks!  ;)

4
QB64 Discussion / Re: _FileExists not working with wildcards
« on: April 15, 2022, 12:46:52 pm »
Really it's just one line of code? Why not that? Too easy!

Maybe you can ask the guy who suggested it to write you up a demo on how to do it?  ;D

5
QB64 Discussion / Re: An introduction; A note on Wiki
« on: April 15, 2022, 12:42:18 pm »
Welcome @dcromley

Are you talking about static for the whole sub or all the variables in it?
Was this something in earlier QB?

I know you can have Static variables in a Sub but I don't think that's what you mean.

There's no mention of STATIC for the SUB itself:  https://wiki.qb64.org/wiki/SUB

Code: QB64: [Select]
  1. For i = 1 To 5
  2.     foo
  3.  
  4.     x = x + 1
  5.     Print x

Such as the above...

6
QB64 Discussion / Re: SEEK # or not SEEK #
« on: April 15, 2022, 12:37:34 pm »
Open "d:/SequentialFile1" for INPUT as #52
Seek #52, Seek(1)

This won't work at all the way you have it, nor for what you're trying to use it for.   Bare with me a bit, as I try and explain these various commands.

SEEK #55, whatever --- this is a SUB which you're calling.  https://wiki.qb64.org/wiki/SEEK_(statement)   It basically is a way to telling the program to move the file pointer to whatever position you want it at.

, Seek(1) ---  this is the FUNCTION which you're calling.  https://wiki.qb64.org/wiki/SEEK  It basically is a way of your programing asking where the file pointer of some file is currently at.

So:  SEEK #52, Seek(1) is basically saying:
Move the file pointer on (filehandle 52) to wherever the file pointer on (filehandle 1) is currently positioned.

Since you don't have an OPEN whateverFile$ FOR INPUT/OUTPUT AS #1, you're going to get an error as there's no open filehandle 1.



So, that's the FIRST reason why what you're trying isn't going to work.

The second reason is due to you OPENing the file in question FOR INPUT.

SEEK (as the SUB version) will place you directly at whatever byte you want to go to -- it doesn't track record positions at all.   It's only when you OPEN FOR RANDOM, that SEEK will move from one record to the next...

INPUT/OUTPUT/BINARY -- SEEK moves to byte position
RANDOM -- SEEK moves to record position



So, the only way something like this would be somewhat valid would be if:

OPEN "d:/SequentialFile1" For Random AS #52
Seek #52, Seek(52) + 1   'move to next record

Notice how all my file handles reference the same file, and that it's an Open For Random file?

I'm thinking the above is close to what you're shooting for, but I'm not certain as the original isn't really code which can do anything except error on you.  What exactly are you trying to do with the code here, after all?

OPEN "d:/SequentialFile1" For Random AS #52
Seek #52, 1   'move to first record
Seek #52, 3   'move to third record
Seek #52, Seek(52) + 2   'move two records past the current one

7
QB64 Discussion / Re: The QB64 Bible (Work In Progress)
« on: April 14, 2022, 02:02:43 pm »
Small update just to prove to myself that I haven't forgotten about this project.  ;)

Finished up the Screen 32 topic.
Added _BIT type into the discussion.

Next up:  _FLOAT type.  People bring it up all the time, so it needs a nice little bit of documentation on it.  If anyone has any specific questions or ideas they'd like me to address or include when talking about _FLOAT, feel free to bring them up here.

8
QB64 Discussion / Re: Small graphics programming challenge
« on: April 14, 2022, 10:50:35 am »
He stopped halfway...  I've got this on here somewhere, except my version lets you click on the circles and use them as a pop-up menu.  :P

9
QB64 Discussion / Re: QB64 Bounty List
« on: April 14, 2022, 09:01:10 am »
1. A good Inkey$ like alternative for $console:only on Win and Linux would give much business value for me

There's _CINP for Windows, which does what you're talking about, though it's never been ported into Linux yet.

10
Programs / Re: Better Bench by Ed Davis
« on: April 11, 2022, 05:49:55 pm »
I purposefully did not try to optimize it for any single language, but rather wanted the same code for each language.

All I was doing was as I was asked here:

Can anyone make a significant drop?

It's hard to make a drop in speeds, without making any changes to the code to help optimize for speed.  ;)

But, I agree -- you can't compare apples to pineapples.  Speed tests between systems/languages should match so you can compare the performance between those systems/languages without skewing the results. 

11
Programs / Re: Better Bench by Ed Davis
« on: April 11, 2022, 05:20:05 pm »
 
Screenshot.png


Best I can come up with, without trying to revert to mem or compiler flags, is about 4.9 seconds on my laptop.

Code: QB64: [Select]
  1. 'DefLng A-Z
  2. 'Dim As Double x, y, xx, yy, start
  3. start = Timer(.001)
  4. accum = 0
  5. count = 0
  6. While count < 1545
  7.     leftedge = -420
  8.     rightedge = 300
  9.     topedge = 300
  10.     bottomedge = -300
  11.     xstep = 7
  12.     ystep = 15
  13.  
  14.     maxiter = 200
  15.  
  16.     y0 = topedge
  17.     While y0 > bottomedge
  18.         x0 = leftedge
  19.         While x0 < rightedge
  20.             y = 0
  21.             x = 0
  22.             thechar = 32
  23.             xx = 0
  24.             yy = 0
  25.             i = 0
  26.             While i < maxiter And xx + yy <= 800
  27.                 xx = Int((x * x) / 200)
  28.                 yy = Int((y * y) / 200)
  29.                 If xx + yy > 800 Then
  30.                     thechar = 48 + i
  31.                     If i > 9 Then
  32.                         thechar = 64
  33.                     End If
  34.                 Else
  35.                     temp = xx - yy + x0
  36.                     If (x < 0 And y > 0) Or (x > 0 And y < 0) Then
  37.                         y = (-Int((-x * y) / 100)) + y0 ' << this line was revised in later post
  38.                     Else
  39.                         y = Int(x * y / 100) + y0
  40.                     End If
  41.                     x = temp
  42.                 End If
  43.  
  44.                 i = i + 1
  45.             Wend
  46.             x0 = x0 + xstep
  47.             accum = accum + thechar
  48.         Wend
  49.         y0 = y0 - ystep
  50.     Wend
  51.  
  52.     If count Mod 300 = 0 Then
  53.         Print accum,
  54.     End If
  55.     count = count + 1
  56.  
  57. Print accum
  58. Print Timer(.001) - start; " seconds"
  59.  
  60. 'This is the output:
  61.  
  62. Print "Compared to expected output of: "
  63. Print "200574 60372774 120544974 180717174 240889374 301061574 309886830"

Only 2 real changes here:

1) I made all variables _DOUBLE type.  When it comes to optimizing speed, QB64 always seems to run better if you can stick with all variables of the same type -- either go all integers, or all floats, if you want speed.  Mixing them seems to always slow things down.

2) I took out the negative multiplication and swapped to negation, which we always process fast.  (-1 * x isn't as efficient as -x, for example.)

Nothing else stares out obviously to me as a means to run the code faster, without going to _MEM access or tweaking compiler options for -fastmath. 

12
Programs / Re: Better Bench by Ed Davis
« on: April 11, 2022, 04:41:57 pm »
   y = (-1 * Int((-1 * x * y) / 100)) + y0   <-- isn't a negative * negative = positive?  How is this any different from the ELSE case?

13
Programs / Re: Just a silly "Hello World" Marquis
« on: April 11, 2022, 12:24:13 pm »
Should I be embarrassed that in my copy that command works?

Not at all!  My personal version of QB64 has a lot of little odd tweaks that the official version doesn't have.  It's nice to be able to mod your own.  ;)

14
QB64 Discussion / Re: Scaling
« on: April 09, 2022, 11:10:19 pm »
Quick demo: 
Code: QB64: [Select]
  1. Print "Hello SCALING World!"
  2.     _Limit 30
  3.  

Compile.  Run.  Grab corner of screen with mouse and drag to desired size so you can see what's on the screen. 

15
QB64 Discussion / Re: Scaling
« on: April 09, 2022, 11:04:57 pm »
I happened to be resurrecting some 'old' QB programs, mainly dealing with particles, and noticed an annoying recurrence. Most of them use a screen size of around 320x200+...  On my screen, 1920x1080, it seems to be no bigger than a business card in comparison...

My question is; Does QB64 have an inbuilt function to scale the size of the image so that the 320x240 display can 'stretched' to fit a larger screen? It is not an issue or a big deal. I am just curious to know.

J

$RESIZE is what you're looking for.

Pages: [1] 2 3 ... 265