Author Topic: A Replacement Method for Data Statements  (Read 10961 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
A Replacement Method for Data Statements
« on: January 31, 2022, 01:30:22 pm »
Welcome @MrGW454

I saw you difficulty on Discord, here is alternate to DATA statements

Code: QB64: [Select]
  1. _Title "Replacement Method for Data statements" 'b+ 2022-01-31
  2.  
  3. 'our Data as string(s)
  4. dat$ = "bplus,SMcNeill,FellippeHeitor,vince,"
  5. dat$ = dat$ + "Qwerkey,Ashish,Luke,RCcola87,MrGW454"
  6.  
  7. 'Load into this array
  8. ReDim members$(1 To 1) ' use REDIM for dynamic array that we can change size of
  9. Split dat$, ",", members$() ' Load data into members$()
  10.  
  11. 'Show it worked
  12. For i = 1 To UBound(members$)
  13.     Print members$(i)
  14.  
  15. ' note: I buggered this twice now, FOR base 1 array REDIM MyArray (1 to 1) AS ... the (1 to 1) is not same as (1) which was the Blunder!!!
  16. 'notes: REDIM the array(0) to be loaded before calling Split '<<<< IMPORTANT dynamic array and empty, can use any lbound though
  17. 'This SUB will take a given N delimited string, and delimiter$ and create an array of N+1 strings using the LBOUND of the given dynamic array to load.
  18. 'notes: the loadMeArray() needs to be dynamic string array and will not change the LBOUND of the array it is given.  rev 2019-08-27
  19. Sub Split (SplitMeString As String, delim As String, loadMeArray() As String)
  20.     Dim curpos As Long, arrpos As Long, LD As Long, dpos As Long 'fix use the Lbound the array already has
  21.     curpos = 1: arrpos = LBound(loadMeArray): LD = Len(delim)
  22.     dpos = InStr(curpos, SplitMeString, delim)
  23.     Do Until dpos = 0
  24.         loadMeArray(arrpos) = Mid$(SplitMeString, curpos, dpos - curpos)
  25.         arrpos = arrpos + 1
  26.         If arrpos > UBound(loadMeArray) Then ReDim _Preserve loadMeArray(LBound(loadMeArray) To UBound(loadMeArray) + 1000) As String
  27.         curpos = dpos + LD
  28.         dpos = InStr(curpos, SplitMeString, delim)
  29.     Loop
  30.     loadMeArray(arrpos) = Mid$(SplitMeString, curpos)
  31.     ReDim _Preserve loadMeArray(LBound(loadMeArray) To arrpos) As String 'get the ubound correct
  32.  
  33.  

Offline MrGW454

  • Newbie
  • Posts: 6
    • View Profile
Re: A Replacement Method for Data Statements
« Reply #1 on: January 31, 2022, 02:17:00 pm »
I really appreciate the follow up on this and the helpful suggestion/example.

Is this an official open bug for QB64 right now?

Thanks!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: A Replacement Method for Data Statements
« Reply #2 on: January 31, 2022, 02:19:29 pm »
I really appreciate the follow up on this and the helpful suggestion/example.

Is this an official open bug for QB64 right now?

Thanks!

No bug really, Data statements work everywhere except where you tried it in a Pi apparently.

Offline George McGinn

  • Global Moderator
  • Forum Regular
  • Posts: 210
    • View Profile
    • Resume
Re: A Replacement Method for Data Statements
« Reply #3 on: February 01, 2022, 12:06:09 pm »
I have DATA statements working on ARM processors, including the Raspberry PI.

I am testing changes to the QB64 install script that will detect whether or not it is being installed on a ARM or RPI, change the required files and download the prerequisite libraries, which does not occur now.

If you want to test this script on your RPI, let me know and I will post a copy of it here.

The only issue I am running into is getting InForm to run on an ARM processor. QB64 so far is fine.
 

No bug really, Data statements work everywhere except where you tried it in a Pi apparently.
____________________________________________________________________
George McGinn
Theoretical/Applied Computer Scientist
Member: IEEE, IEEE Computer Society
Technical Council on Software Engineering
IEEE Standards Association
American Association for the Advancement of Science (AAAS)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: A Replacement Method for Data Statements
« Reply #4 on: February 01, 2022, 12:11:38 pm »
Be really cool getting QB64 working on those devices.

I checked out a Pi a couple years ago, the screen was smaller than a phone's, not going to work with old eyes!, I returned the kit and appreciate my laptop all the more!

But that kind of thing is the base of young computer hobbyists for today!

Offline MrGW454

  • Newbie
  • Posts: 6
    • View Profile
Re: A Replacement Method for Data Statements
« Reply #5 on: March 09, 2022, 12:46:36 pm »
I have DATA statements working on ARM processors, including the Raspberry PI.

I am testing changes to the QB64 install script that will detect whether or not it is being installed on a ARM or RPI, change the required files and download the prerequisite libraries, which does not occur now.

If you want to test this script on your RPI, let me know and I will post a copy of it here.

The only issue I am running into is getting InForm to run on an ARM processor. QB64 so far is fine.

Hi George,

I would appreciate it if you could share the solution for getting DATA statements working on a Raspberry Pi.  I'm happy to test and post my results.

Thank you!

Offline tomxp411

  • Newbie
  • Posts: 28
    • View Profile
Re: A Replacement Method for Data Statements
« Reply #6 on: March 09, 2022, 02:26:07 pm »
No bug really, Data statements work everywhere except where you tried it in a Pi apparently.

I actually found a but in the READ statement that was fixed within an hour of me reporting it. @MrGW454 if you are not running the latest version, you'll want to compile from source. If you have a packaged binary, you may still have the bug, since there has not been an official release since then. Meaning you would still have the bug where READ sometimes grabs the last line of source code, rather than the correct DATA value.

Also... could you post the original Discord message, so we know what the actual problem is?
« Last Edit: March 09, 2022, 02:31:20 pm by tomxp411 »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: A Replacement Method for Data Statements
« Reply #7 on: March 09, 2022, 02:31:24 pm »
I actually found a but in the READ statement that was fixed within an hour of me reporting it. @MrGW454 if you are not running the latest version, you'll want to compile from source.

Also... could you post the original Discord message, so we know what the actual problem is?

Ha! you can't blame him if I started thread.

I didn't know bug was fixed so quickly what was it?

Offline tomxp411

  • Newbie
  • Posts: 28
    • View Profile
Re: A Replacement Method for Data Statements
« Reply #8 on: March 09, 2022, 02:33:17 pm »
Be really cool getting QB64 working on those devices.

I checked out a Pi a couple years ago, the screen was smaller than a phone's, not going to work with old eyes!, I returned the kit and appreciate my laptop all the more!

But that kind of thing is the base of young computer hobbyists for today!

You probably got one of the handheld portable kits. The Pi is designed to use any HDMI display, so you can use it on any modern TV or computer monitor.

Offline MrGW454

  • Newbie
  • Posts: 6
    • View Profile
Re: A Replacement Method for Data Statements
« Reply #9 on: March 09, 2022, 03:15:57 pm »
I actually found a but in the READ statement that was fixed within an hour of me reporting it. @MrGW454 if you are not running the latest version, you'll want to compile from source. If you have a packaged binary, you may still have the bug, since there has not been an official release since then. Meaning you would still have the bug where READ sometimes grabs the last line of source code, rather than the correct DATA value.

Also... could you post the original Discord message, so we know what the actual problem is?

I'll grabbed the latest source and compile.

Here's the link to the message I left on Discord:

https://discord.com/channels/592061709485735966/592061709485735974/937745171163017226

.. and here's the message text:

Code: QB64: [Select]
  1. [10:24 AM] MrGW454: Hello - not sure if this is the correct place to ask for assistance with QB64 compiler issues.
  2.  
  3. I have a BASIC program that compiles fine under Linux (64 bit) and Windows using the latest QB64 from git.  It will not compile correctly on a Raspberry Pi 4.
  4. Since there is no binary package available for QB64 on the Pi, I compiled the source (after editing the "../internal/c/common.h" file and adding "#define QB64_NOT_X86" at the top.
  5.  
  6. The error I get when compiling the BASIC program I have is:
  7.  
  8. QB64 Compiler V2.1
  9.  
  10. Beginning C++ output from QB64 code...
  11. [..................................................] 100%
  12.  
  13. Compiling C++ code into executable...
  14. ERROR: C++ compilation failed.
  15. Check ./internal/temp/compilelog.txt for details.
  16.  
  17.  
  18. pi@raspberrypi:~/source/qb64-git $ cat internal/temp/compilelog.txt
  19. objcopy: architecture i386 unknown
  20. g++: error: ../temp/data.o: No such file or directory
  21.  
  22.  
  23.  
  24. It looks like QB64 is trying to compile for i386 and not ARM.  Strange thing is, some other (smaller) BASIC programs I wrote are compiling fine.
  25. I tried doing some searching online, but no luck so far.
  26.  
  27. Thanks for any help someone might be able to provide!
  28. [10:26 AM] MrGW454: I should clarify, that QB64 (the program) works.  The IDE comes up and everything.  I just can't get one specific BASIC program I have to compile.  I did not want to confuse anyone thinking I was having issues trying to compile QB64 itself.  Thanks.
  29.  

Offline tomxp411

  • Newbie
  • Posts: 28
    • View Profile
Re: A Replacement Method for Data Statements
« Reply #10 on: March 09, 2022, 03:37:00 pm »
Thanks. That helps.

I am not sure if I've actually used QB64 on my Pi. I have been meaning to try it, as I want my programs to work on Linux, as well as Windows. I'll have to remember to start testing on the Pi, once in a while.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: A Replacement Method for Data Statements
« Reply #11 on: March 09, 2022, 03:52:11 pm »
Quote
FellippeHeitor — 01/31/2022
Do you use DATA statements?
It is known not to work on arm
You'll need a workaround for now
Store your data another way
MrGW454 — 01/31/2022
I sure do.  Let me see what I can do.  I'm requesting access to the QB64 forum.  Is that mentioned in there/.
FellippeHeitor — 01/31/2022
It's been brought up before


Don't see where it's been fixed.

That's why I offered a work around DATA statements. Maybe putting the DATA into an array doesn't work?

Offline MrGW454

  • Newbie
  • Posts: 6
    • View Profile
Re: A Replacement Method for Data Statements
« Reply #12 on: March 09, 2022, 04:05:24 pm »
Thanks. That helps.

I am not sure if I've actually used QB64 on my Pi. I have been meaning to try it, as I want my programs to work on Linux, as well as Windows. I'll have to remember to start testing on the Pi, once in a while.

I pulled current development source from git.  It successfully compiled for the RPi but I still get the same error when trying to compile my BASIC source code.  If I remove the DATA statement references, it works. 

The exact same BASIC code compiles fine in QB64 under Windows or Linux (x86 or x64).  It just doesn't work for ARM.

Offline MrGW454

  • Newbie
  • Posts: 6
    • View Profile
Re: A Replacement Method for Data Statements
« Reply #13 on: March 09, 2022, 04:09:00 pm »
Don't see where it's been fixed.

That's why I offered a work around DATA statements. Maybe putting the DATA into an array doesn't work?

Hi bplus,

Your method does appear to work.  I'm not the original author of the BASIC code and did forward your solution to them.  We both appreciated your quick response on this.

I was just following up on since I feel the DATA statement issue should be resolved for ARM architectures and make it behave like the other platforms.

 


Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: A Replacement Method for Data Statements
« Reply #14 on: March 09, 2022, 05:13:28 pm »
Quote
I was just following up on since I feel the DATA statement issue should be resolved for ARM architectures and make it behave like the other platforms.

Right! I think it a point of pride that the team make QB64 as cross platform as possible. I don't know if any have ARM OS to test code?