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 - Jon Richfield

Pages: [1]
1
QB64 Discussion / Re: Nulls strings BUG?
« on: June 13, 2020, 09:37:49 am »
Yes, I certainly am creating a character file (though not necessarily printable characters), but that does not mean that being able to specify low-values is not a useful facility in dealing with sequenced files in matching etc. In this it corresponds to High-values for end of file or end of procedure facilities, instead of say, checking for end of file or end of string every time.

In the same program I am in fact using high values (X"FF") by entering "[alt][255]" as someone recently pointed out helpfully. This alt-character facility seems to work for everything but X"00", which I then had intended to use, but have found the editor unable to handle.

Now, there still are options I can manage, such as using a hex editor on my Basic source file, but that seems an eccentric measure to have recourse to in such a powerful facility as QB64. I thought that the developers would like to know of the bug. If not, OK, I'll manage. Thanks anyway.

2
QB64 Discussion / Nulls strings BUG?
« on: June 13, 2020, 04:35:44 am »
Trying to enter a string of nulls seems to do all sorts of nasty stuff to the editor.
How did I get the following text into the editor? I wrote it into a .BAS file, then opened the file with QB64.

OPEN "C:\TEMP\lowvals.bas" FOR OUTPUT AS #1
PRINT #1, "   CONST NULL = " + CHR$(34) + CHR$(0) + CHR$(34)
PRINT #1, "   CONST NULLS = " + CHR$(34) + STRING$(8, CHR$(0)) + CHR$(34)
PRINT #1, "   N$ = NULLS"
PRINT #1, "   PRINT N$"
CLOSE
END

OK?
Now run that file and it should create a BAS file that works, more or less.
Now, run that BAS file and see that it works, even though those strings contain nulls, not spaces.
So copy one of those const statements and paste it into that same program, or another , say with 4 nulls instead of 8. And see what happens.

If you persist in trying to make it work with your mouse or by using ALT[0], funny things happen, like switching the mouse buttons etc, and your not being able to close the string's quotes.

Am I doing something wrong, or is there an outstanding correction?


3
QB64 Discussion / Re: Opening files
« on: June 12, 2020, 02:45:43 am »
If you have Windows and don't want to worry about Linux or Mac users (ie doing a cross platform app) there are easier ways.

.....

The majority of this code is spent with selecting an item from an array, in this case an array of directories or of files when you press f. You could use simpler techniques. LoadDirs and LoadFiles are main routines for getting folders and files from current directory if I recall correctly.

Forgive my blundering; I still haven't mastered the facilities in this forum. 😳 Everything in time 😉

4
QB64 Discussion / Re: Opening files
« on: June 12, 2020, 02:42:24 am »
Thanks bplus,

That will take a bit of reading, but looks as though it is in the right direction.

5
QB64 Discussion / Re: Opening files
« on: June 10, 2020, 12:16:12 pm »
Thanks Petr and Codeguy. I'll have to go into this to see what best applies to my requirements.

6
QB64 Discussion / Opening files
« on: June 08, 2020, 02:56:06 am »
Suppose I wish to process a file in a QB64 program. Of course I can read in the file name and path from the keyboard; however, often one wants to click on a file in a directory display and open the file with the program in question.
Can anyone please direct me to instructions for how to do that sort of thing.

Thanks for any suggestions.

7
Please see the original dumb question for the background.

I am converting a very old MS VB sort, so old that I had forgotten how I had written it, and had assumed that the subroutine statement at the head was part of my design at the time. However, it only later came back to me that all the apps that VB creates are in the form of Private SUBs.  Then I had problems with Const statements for unprintable characters, till some of our helpful spirits in the forum solved them for me. (Thanks again folks!)

But I was going nuts with incomprehensible diagnostics (one at a time!) about all the constants being taken as if they were new undefined variables.

Only after the penny dropped did I realise that the SUB statement was a VB contribution, and not relevant to the program, and was messing up the contexts. When I commented out the SUB statement the problem went away. I don't know whether my problem is unusual or not, but in case anyone else works on converting VB programs, and gets funny diagnostics, it might be something to think about.

Wish me luck in achieving a working program, now that the diagnostics are gone.




8
QB64 Discussion / Re: Dumb question #365B.101
« on: June 07, 2020, 11:42:57 pm »
Also you can type [Alt][2][5][5] 8 times betwen "".
Code: QB64: [Select]
  1. [font=courier]
  2. CONST HiVal = "        " ' [Alt][2][5][5]. The char 255 is invisible like the space
  3. FOR i% = 1 TO LEN(HiVal)
  4.   PRINT ASC(HiVal, i%);
  5. NEXT i%
  6. [/font]
  7.  

Much thanks. That was the specific thing I was trying to achieve. I just could not remember how to create the arbitrary byte values as literals.

It did however leave me with more problems popping out of the woodwork. I think I'll post the newly revealed diagnostics in a separate response, because there are some less obvious incompatibilities. thanks for now.

9
QB64 Discussion / Re: Dumb question #365B.101
« on: June 07, 2020, 11:29:10 pm »
How do I instead define a variable string with an 8-byte string of ASCII-255 characters? I have tried several versions of &HFF expressions without success..

User$ = STRING$(8, CHR$(255))



DIM HiVal$ AS STRING tosses an error for redundancy.  Either use:

DIM HiVal$

Or use:

DIM HiVal AS STRING

There's no need to use $ with AS STRING.   ;)

Thanks SMcNeill; that made sense, and was the original form that I had used, but the pitch was queered by other problems as yet unsorted. However your putting it so explicitly solved that one at least. Your patient reply much appreciated. More in my reply to moises1953 anon.


10
QB64 Discussion / Re: Dumb question #365B.101
« on: June 06, 2020, 03:29:01 pm »
Hi bplus,

it is past crash time round here, so I'll only have a proper look at your reply tomorrow. 
But I just had to say this much, whether your questions prove useful when I wake up or not,
there is NO WAY I am about to take offence when a friend tries to be helpful.

Many thanks till Sunday 👍😃

11
QB64 Discussion / Dumb question #365B.101
« on: June 06, 2020, 07:15:20 am »
Hi anyone,

I am no programmer anymore, using QB64 just as a lazy convenience tool, but I found a need for an old sort I wrote for another purpose more than 20 years ago in MS VB and am in the process of trying to translate it instead of rewriting it.

I expected to suffer of course, but ...

Now, most of it is not causing obvious drama, though more keeps surfacing, but as an old assembly language programmer, I like to access the data in native format, and the original program used the concept of high values, strings of bytes with all one-bits, and in particular I was trying to create 8-byte strings of high values or referring to them as a CONST "********"

When that did not work though Const LowVal = "" DID work (apparently) I tried to create the string with DIM pluss assignment, and all went pear-shaped.

* How do I define a constant of a string of length of 8 bytes with all 1-bits. (Defining an empty string Const as "" looks happy).
* How do I instead define a variable string with an 8-byte string of ASCII-255 characters? I have tried several versions of &HFF expressions without success
* I was using option explicit in VB and kept it in QB64 (I like that option) and Dim HiVal as STRING I get all sorts of pain like getting diagnostics about missing commas (well, there WAS no comma, sure, but I could not find any reference to which comma with what meaning or where. (eg DIM HiVal$ AS STRING    gets me a missing comma. Dim HiVals as string gets me variable not defined. etc)
* If I finally quiet that diagnostic then I get more diagnostics in which it fails to recognise variables as string variables in spite of having DIMmed *everything*
* If I remove option explicit, then  LineRead = LowVal (lowval is COnst ="", and Lineread is DIMmed as string)  gets me illegal string-number conversion.

*Just wistfully, If there is one feature I would LOVE, it would be to be able to redefine data values so that say, I could create an _UNSIGNED _Integer64 variable, and treat it as say, a string of 64 bit values or an 8-byte string. (Yes, I know, but if things go wrong, I would have no one else to blame. I yearn for the old macro Assembler days (snifff...)

Now, if I can get this all fixed up, then I was going to upload a suitable version of the sort as a utility in thanks for the pleasure QB64, but at the moment I am treading water and going down. Anyone who would like to see the code is welcome, but I did not want to display 200+ lines just here without first having chewed it over first.

Please help, anyone with sufficient patience.
Thanks apologetically,
Jon

12
QB64 Discussion / Re: _Integer64 arithmetic misbehaves
« on: October 30, 2019, 02:06:50 pm »
Hi bplus, thanks for the welcome; Much appreciated.

As for finding the maximal value, I found _integer64 quite domesticated once I learnt not to be careless about mixing it with other modes. Works well with both integer arithmetic and logical functions such as XOR.

To see the maximim, try this quick scribble:
_DEFINE A-Z AS _UNSIGNED _INTEGER64
CLS
PRINT "Possible values of numbers with increasing numbers of repeated 1-bits from 1 to 64 in unsigned words."
I = 1
FOR J = 1 TO 80
    PRINT USING "########################"; J, I
    I = I + I + 1
    IF J MOD 20 = 0 THEN
        INPUT "Press Enter-key to continue"; x$
        LOCATE CSRLIN - 1, 1
    END IF
NEXT
PRINT "Note how the number remains constant once the 64-bit word is full."

13
QB64 Discussion / Re: _Integer64 arithmetic misbehaves
« on: October 30, 2019, 11:43:57 am »
Replying (partly) to my own question.

I had a sudden satori. I removed the Deflng statement, and inserted a _Define A-Z _Unsigned _integer64 statement at the top.

That seems to have worked magic on automatic intermediate values, and suddenly my test code at least seems to work correctly.

It seems a rather brutal solution, but not impossible.

Is there any policy concerning intermediate values that needs re-thinking? If not, where do I find a statement on the principles QB64 adheres to?

Thanks for attention so far.

14
QB64 Discussion / _Integer64 arithmetic misbehaves
« on: October 30, 2019, 11:03:50 am »
Unless of course I am misbehaving...

Some months ago I was messing about with primorials, can't remember why, and things went pear-shaped. wrong results, in spite of trying _unsigned etc. (Unsigned would have suited me fine, maybe I was tinkering with encryption, in which case truncation on overflow would be perfect, and I had a vague idea that in a previous version I did actually get truncation, but I am unsure.)

Anyway, I scribbled a bit of code to test the stuff (in case I errr... was fouling up) and it seemed unfortunately not to be the case, because then I could have fixed it myself.

OK, so here follows the test source. Please run it for yourself, either to prove that I fouled up (I hope!) or to consider fixing up the QB arithmetic. (I am running on a W10 desktop with a plain Intel processor, plenty of memory etc, and all the QB I have run so far has behaved itself much better than I have.) Here goes:
OPTION BASE 0
Top = 14
DIM Primorial(Top), Prims(Top), P AS _UNSIGNED _INTEGER64
P = 2 ^ 62
PRINT "Start:"
PRINT USING "##########################"; P
PRINT USING "##########################"; P * 2
PRINT USING "##########################"; P + P
PRINT USING "##########################"; P * 4
PRINT USING "##########################"; P + P + P + P
DEFLNG I-N
DATA 0002,0003,0005,0007,0011,0013,0017,0019,0023,0029,0031,0037
DATA 0041,0043,0047,0053,0059,0061,0067,0071,0073,0079,0083,0089
DATA 0097,0101,0103,0107,0109,0113,0127,0131,0137,0139,0149,0151
DATA 0157,0163,0167,0173,0179,0181,0191,0193,0197,0199,0211,0223
FOR I = 1 TO Top
    READ Prims(I)
NEXT
Primorial(0) = 1
FOR I = 1 TO Top
    Primorial(I) = Primorial(I - 1) * Prims(I)
    PRINT USING "##########################"; Prims(I), Primorial(I), Primorial(I) \ Primorial(I - 1)
NEXT
END

You will note that at the start of the code, the pure binary arithmetic has behaved well: values for 2^62 ok. 2^63 OK, allowing for overflow into the sign position, and 2^64 might as well give 0, given that the only 1-bit had gone to bit heaven. I reckon I could live with that one way or another, but have a look at the primorials.

The code is simple, if undocumented: multiply successive primes from a READ list, giving successive primorials. At the end of the line, divide the putative primorial by the previous primorial, which should give the current prime, but in several cases does not, because the current primorial is wrong.

Up to primorial 19 it is fine, but primorial 23 comes out 6 short, which error propagates to higher levels with elaborations.

Please assist, someone.

Pages: [1]