LB Booster
« console programs converted to BBC Basic Linux »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:48am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: console programs converted to BBC Basic Linux  (Read 402 times)
mmiscool
New Member
Image


member is offline

Avatar




PM


Posts: 19
xx console programs converted to BBC Basic Linux
« Thread started on: Jul 31st, 2017, 5:10pm »

I know I can get to the BBC basic source code with the LBB program.

My question is if I wrote my program not using any of the windows GUI stuff could I compile it for Linux and possibly run on BBC basic for rasberry pi.

I know it might sound weird. But I have a program that I would like to get running on a pi and I could get rid of all the gui stuff pretty easily.
« Last Edit: Jul 31st, 2017, 5:11pm by mmiscool » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: console programs converted to BBC Basic Linux
« Reply #1 on: Jul 31st, 2017, 5:56pm »

on Jul 31st, 2017, 5:10pm, mmiscool wrote:
My question is if I wrote my program not using any of the windows GUI stuff could I compile it for Linux and possibly run on BBC basic for rasberry pi.

Yes, in principle you could (it would not end up as a true 'console' program however as that isn't supported by BBC BASIC on Linux)!

One difficulty you might have is that even with no GUI features being used by your LBB program the translation to BBC BASIC might still contain some OS dependencies. For example if you use TIMER it will end up calling a Windows timer API, which would have to be substituted with a Linux (or SDL) equivalent. There are likely to be several other non-GUI features of LB that also rely (if only for reasons of convenience) on the Windows API.

If this is something you want to pursue I would suggest you look at LBB's translation of your code. When it has been able to do a 'direct' translation to equivalent BBC BASIC statements there is every likelihood it will run on Linux or a Raspberry Pi with little or no alteration. If, however, it has had to make calls to emulated code in the LBLIB library (you can recognise such calls as starting PROC_ or FN_, where the underscore is key) then they may - or may not - end up relying on something Windows-specific. It would be necessary to investigate such calls on a case-by-case basis.

I have asked before on this forum whether a 'mainwin-only subset' of LBB, which could run successfully on Linux, Mac OS, Raspberry Pi (and perhaps even Android) might be of interest. The consensus has been that it would probably be too limiting to justify the work involved. But an ad-hoc approach of the kind you suggest may be worth attempting if you are fortunate with the subset of language features that you want to use.

Richard.
User IP Logged

mmiscool
New Member
Image


member is offline

Avatar




PM


Posts: 19
xx Re: console programs converted to BBC Basic Linux
« Reply #2 on: Jul 31st, 2017, 6:13pm »

I would be down with a command line version various other platforms.
User IP Logged

mmiscool
New Member
Image


member is offline

Avatar




PM


Posts: 19
xx Re: console programs converted to BBC Basic Linux
« Reply #3 on: Jul 31st, 2017, 8:29pm »

Unfortunately my script dose take advantage of the timer function. I will have to look at how to replace that in Linux. Any ideas or example.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: console programs converted to BBC Basic Linux
« Reply #4 on: Aug 1st, 2017, 11:11am »

on Jul 31st, 2017, 8:29pm, mmiscool wrote:
Unfortunately my script dose take advantage of the timer function. I will have to look at how to replace that in Linux. Any ideas or example.

If you use TIMER that implies the use of SCAN and/or WAIT which means that the whole LB event-handling mechanism needs to work. Although there's nothing fundamentally dependent on Windows there, realistically I'd have to make the modifications because untangling it from the GUI stuff would be non-trivial.

Richard.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: console programs converted to BBC Basic Linux
« Reply #5 on: Aug 3rd, 2017, 10:09am »

Does your program use SORT (which is written in assembly language, so poses an issue for running on ARM) or FILES (which calls the Windows API)? Neither is necessarily a major problem, but adds to the work that would be needed from my side.

Richard.
User IP Logged

mmiscool
New Member
Image


member is offline

Avatar




PM


Posts: 19
xx Re: console programs converted to BBC Basic Linux
« Reply #6 on: Aug 9th, 2017, 1:30pm »

I don't use any kind of sort functions. Just the serial port and I would need the ability to run an external program and from the command line and capture the result. Similar to the shell$() function in run basic.

The following snippet is one I think you created to add the shell$() function to LB/LBB. It looks windows specific.
Code:
function shell$(command$)
    open "msvcrt" for dll as #msvcrt
    command$ = command$ + " > %temp%\lbbcmd.out"
    calldll #msvcrt, "system", command$ as ptr, r as long
    close #msvcrt
    tmp$ = space$(260)
    calldll #kernel32, "GetTempPathA", 260 as long, tmp$ as ptr, r as long
    open left$(tmp$,r) + "lbbcmd.out" for input as #tmp
    shell$ = input$(#tmp, lof(#tmp))
    close #tmp
end function 
« Last Edit: Aug 9th, 2017, 1:34pm by mmiscool » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: console programs converted to BBC Basic Linux
« Reply #7 on: Aug 9th, 2017, 4:08pm »

on Aug 9th, 2017, 1:30pm, mmiscool wrote:
I don't use any kind of sort functions. Just the serial port

The serial port could be an issue. SDL 2.0 provides no support for serial ports, as far as I am aware. Would you perhaps be able to configure the port from the command line so that your LBB program doesn't need to concern itself with that?

Quote:
I would need the ability to run an external program

What's wrong with the regular LB RUN statement?

Quote:
The following snippet is one I think you created to add the shell$() function to LB/LBB. It looks windows specific.

It would have to be adapted to work on a non-Windows platform, certainly, but I expect you could do that without too much difficulty. Using an absolute file path would make it easier.

Considering all the potential difficulties, I can't see this being a project that it would be sensible to attempt. Too many challenges!

Richard.
User IP Logged

mmiscool
New Member
Image


member is offline

Avatar




PM


Posts: 19
xx Re: console programs converted to BBC Basic Linux
« Reply #8 on: Aug 10th, 2017, 3:22pm »

The run statement provides no feed back from the program that was ran.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: console programs converted to BBC Basic Linux
« Reply #9 on: Aug 10th, 2017, 5:42pm »

on Aug 10th, 2017, 3:22pm, mmiscool wrote:
The run statement provides no feed back from the program that was ran.

Nor does the 'system' API you listed! The "feedback" comes from redirecting stdout to a file, and then reading that file. You can do that using the RUN command, for example:

Code:
    run "dir > %temp%\stdout.txt", wait 

In any case, in Linux (which is the OS we are discussing), the RUN command internally uses the 'system' API so it would work exactly the same as your code.

Richard.
« Last Edit: Aug 10th, 2017, 8:21pm by Richard Russell » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls