Jump to content
IGNORED

BASIC / XB Translator (TidBit)


matthew180

Recommended Posts

WOW! OK, Later today I will post another update. Same game, nothing changed except some more code optimizing.

After Loading the game: 6734 PROGRAM FREE

After running the game: 6590 PROGRAM FREE

 

I think I have plenty of space to continue development. Gotta run off to work now. L8rs...

  • Like 1
Link to comment
Share on other sites

TidBit has been updated to V3.0. Lots of changes and bug fixes that were not discovered yet. I rewrote the internal parser to recognize *less*, thus making it simpler and thus less prone to errors. My website has been updated with the latest, and so has the download file in the first post of this thread.

  • Like 1
Link to comment
Share on other sites

I know nothing of PHP.

http://php.net/manual/en/intro-whatis.php

 

PHP is an interpreted scripting language, much like BASIC, XB, Java, Ruby, Python, JavaScript, etc. It has been around a long time and was designed primarily for building web applications. However, it is a very nice general purpose scripting language too. Running a PHP script is also just like any of those languages, you need to feed the script into the interpreter.

 

I downloaded php for windows but it did not have an installer.

 

You don't need an installer. Just unzip to a folder where you want the PHP interpreter to live.

 

I saw notes on the tidbit page about adding paths so instead of doing that, I just decompressed to my tidbit folder.

That is fine, you only need to add PHP to your PATH if you don't want to type the full path to the PHP interpreter every time you run it.

 

I run php, it opens a prompt,

It does not work like that. Start a command prompt in windows:

 

right-click the Start Icon

select: Run

type: cmd

hit enter

 

Now change to the directory where you extracted PHP and type: php -v

 

You should see some version information. Now you can run PHP scripts by typing: php <script_name>

 

I run all 3 of the tidbit php files and nothing. Just kinda sits there.

You actually did not run anything, so it just sits there.

 

Do I need to install PHP from a different source?

Nope, the php.net website it the place to get php.

 

Yes I can add paths to windows no problem.

If you want to. It will make running PHP scripts easier since you won't have to always type the full path to the PHP interpreter.

 

I think this is the latest version of php, not sure. First time ever doing anything with it. It came in a zip file : php-7.0.10-nts-Win32-VC14-x86.zip source: http://windows.php.net/download/

That one is fine. Also, Google is your friend. I'm glad to help, but you can usually get faster results with a little searching.

 

Once you have PHP working, you will probably want to run TidBit using the tidbit_cmd.php script. TidBit itself is written as a library (technically a Class) and is contained in tidbit.php. This script will do nothing on its own. I have included two other PHP scripts (tidbit_cmd.php and tidbit_web.php) depending on how you want to run TidBit. Using the command line will be the fastest and easiest for you so go that route for now.

 

To use tidbit_cmd.php you use the following syntax:

 

php tidbit_cmd.php <input source> <starting line> <line increment> [<output file>]

 

Parameters in [ ] are optional, everything else is mandatory. For example, if you have an input source file called test.bas, you convert it like this:

 

php tidbit_cmd.php test.bas 100 10

 

That will output the converted program to the command line and you can copy and paste to Classic99 or another emulator. If you want the output code to go to a file, then add an output filename as the last parameter:

 

php tidbit_cmd.php test.bas 100 10 test_output.bas

 

The file test_output.bas will be created if it does not exist, and overwritten if it does.

 

I hope this helps. Being comfortable with a DOS or unix command line helps.

Edited by matthew180
  • Like 1
Link to comment
Share on other sites

Thanks Matthew, my php ignorance is deliberate. I know it's primarily for webpages and that alone kept me from it. Personal reasons I may get in to some day. My only recent interest is strictly tidbit without internet related. But that was a much less priority since I'm almost always near an internet connection. My lack of interest in php kept me from researching even the basics. I pretty much shrugged it off. But since you took the time to post all of that info, I won't waste your time and will make an effort to get it going.

 

Moving to coding more these days has me spread pretty thin so jumping on anything new outside of XB right now is usually met with disdain. Much like my resistance to TidBit to start with. And yet now, I can't imagine not using it going forward.

 

Your all very persuasive, thank you for being so. I suppose distractions can be very rewarding sometimes. 8D

Edited by Sinphaltimus
Link to comment
Share on other sites

Well, just because you are using a program written in some language does not mean you have to learn that language. I.e. you don't need to know PHP to run TidBit. You just need to know how to run the script, which is the same process for most scripting languages (for Python you have the run the python interpreter, for Java you have to have the JVM installed, etc.) A lot of scripting languages have wrappers for running in Windows, and I'm sure PHP does too, somewhere out there. But IMO it is easier to just run from the command line.

 

I like PHP a lot, it is a very nice general purpose scripting language with very powerful and easy to use associative arrays, string handling, file handling, etc. It also has a very relaxed syntax that is very C-ish / Java-ish. If you know any of C, C++, Java, JavaScript, etc. then you pretty much know PHP and will be right at home. An small example of the relaxed syntax is the use of "else if". You can type "elseif" or "else if" and it does not care. This might seem like a small thing, but depending on what language you are coming from you will have habits, and in PHP, either way it will "just work". And that is a Good Thing. Anyway, I digress.

 

Let me know if you find any other bugs in TidBit.

  • Like 1
Link to comment
Share on other sites

OK, I attempted to make this a simple as possible. D:\php is the directory I'm in at a cmd prompt.
I copied the bas file to the same directory along with tidbit.
Attempted without full path and with. I get the same results.

my bas files are just plain text files of the source where I changed the extension to bas from txt with a rename.

 

ZOMBtiV035_source.bas

D:\PhP>php tidbit_cmd.php d:\php\zombie035_source.bas 100 10 d:\php\zombi035n.bas Warning: file_get_contents(d:\php\zombie035_source.bas): failed to open stream: No such file or directory in D:\PhP\tidbit_cmd.php on line 36
 
Cannot read input file: d:\php\zombie035_source.bas
 
 
D:\PhP>
Edited by Sinphaltimus
Link to comment
Share on other sites

Some odd behavior noted using TidBit:

 

In this first screen shot I show the TidBit screen and behind it is Notepad++ (simpy for the built in line numbers)

 

To the point:

 

TidBit translates this incorrectly:

IF C=0 THEN RETURN ELSE _FALL

TidBit's Translation: 920 IF C=0 THEN RETURN ELSE _FALL

 

attachicon.gifTidBit3.png

 

TidBit translates this correctly:

IF C<>0 THEN _FALL ELSE RETURN

TidBit's Translation: 920 IF C<>0 THEN 2020 ELSE RETURN

 

attachicon.gifTidBit4.png

 

Here's the source code for the above examples:

 

attachicon.gifZOMBtiV034_source.txt

 

Doing it here as well.

 

attachicon.gifTidBit5.png

 

And again, this fixed it

 

attachicon.gifTidBit6.png

 

EDIT: I can't seem to get TidBit working locally so I'm using TidBit on the net from here: >>TidBit<<

 

Funny... I wrote Panzer Strike entirely using TidBit and never encountered that error. Good catch!

On a side note, I should state that Panzer Strike would likely never have materialized were it not for TidBit. It was just too complex to code using the line by line standard TI editor, particularly when it came to debugging. In TidBit, it's a snap to move blocks of code around, whereas with the standard editor that would be a nightmare...

One more time: Thank You Matt!!!

  • Like 3
Link to comment
Share on other sites

OK, I attempted to make this a simple as possible. D:\php is the directory I'm in at a cmd prompt.

I copied the bas file to the same directory along with tidbit.

Attempted without full path and with. I get the same results.

 

my bas files are just plain text files of the source where I changed the extension to bas from txt with a rename.

Make sure your file names are correct (the windows cmd prompt supports tab-completion). The error is basically telling you that the input source file cannot be found. I downloaded the file and ran the test below. My PHP executable in in C:\php and I have added it to my path.

 

 

post-24952-0-18020800-1474087706_thumb.png

zombi035n.bas

Link to comment
Share on other sites

 

Have you thought about creating a compiler for TidBit (on the PC side I mean)?

Thought about it, but I don't really like line number BASIC very much so there is little motivation.

 

The xdt99: cross-development tools has the xbas99, a TI BASIC and TI Extended BASIC lister and encoder. Maybe that one could do the job ?

 

;)

 

 

Link to comment
Share on other sites

 

Hmm, I was talking about a compiler from TidBit BASIC to machine code :?.

 

Yep, you said compiler and not encoder, so I thought so ("to machine code" versus "to TI BASIC"). Then Matthew answered your question with something about really not liking line number BASIC, and line numbers shouldn't really be relevant for a TidBit BASIC to machine code compiler. And when you didn't react to that, ... I thought you'd both be thinking encoders.

 

:sleep:

Edited by sometimes99er
Link to comment
Share on other sites

 

Hmm, I was talking about a compiler from TidBit BASIC to machine code :?.

 

Ah, I misunderstood. Now that is something I have thought about. However, that becomes a new compiled language, and I would not model it after XB.

 

 

Thank you! Now I have PHP installed. On to TidBit...

 

I'm glad to hear you got it going.

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...