Author Topic: Dumb question #365B.101  (Read 4228 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline Jon Richfield

  • Newbie
  • Posts: 14
    • View Profile
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

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Dumb question #365B.101
« Reply #1 on: June 06, 2020, 10:58:51 am »
Hi Jon,

2 dumb questions back at you:

Do you know about or remember fixed strings, you can control the number of bytes?

Do you know about Binary conversion tools here:
https://www.qb64.org/forum/index.php?topic=1602.0
But QB64 v1.4 updates might now include these conversion tools.

Forgive me if you are insulted by my questions, I do very little bit / byte manipulations, just trying to help.
« Last Edit: June 06, 2020, 11:00:12 am by bplus »

Offline Jon Richfield

  • Newbie
  • Posts: 14
    • View Profile
Re: Dumb question #365B.101
« Reply #2 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 👍😃

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Dumb question #365B.101
« Reply #3 on: June 06, 2020, 03:49:08 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.   ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline moises1953

  • Newbie
  • Posts: 55
    • View Profile
Re: Dumb question #365B.101
« Reply #4 on: June 07, 2020, 01:01:07 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.  

Offline Jon Richfield

  • Newbie
  • Posts: 14
    • View Profile
Re: Dumb question #365B.101
« Reply #5 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.


Marked as best answer by Jon Richfield on June 07, 2020, 07:43:05 pm

Offline Jon Richfield

  • Newbie
  • Posts: 14
    • View Profile
Re: Dumb question #365B.101
« Reply #6 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.