About X-BASIC'



iOS dependent functions
X68 compatible/Convenient/Card functions
Music functions

"X-BASIC'" is reproduced with the extend of X68000's X-BASIC(below X-BASIC/68) and its high-speed compatible "peke-BASIC".
Original "X-BASIC/68" came with PC SHARP X68000 that predominate in Japan from 1980 to early 1990s.
So, you can use this if you want to make a little program on the iOS, or want to study basic programming.
As of Xcode, this can not make full use of iOS. But this can make a program much easier.
In fact, we aim to build to practically completed program environment which is complete only on iOS.

Except for the machine-dependent statements and functions and commands(this is very important),
you should be able to run many sources with a little modification (Upward-compatible).

Incidentally, this is not the emulator. I do not describe the details of the X68000. Please learn on your own.
(Just using the X-BASIC', you do not need to know anything about X68000.)

// Main screen


The program itself does not have a line number.
However, text editor attach the line numbers internally for management.
Screen will scroll up or down. In addition, you can show from the first program row when you tap the status bar.
There are two display mode as "Edit" and "List". At launching, it is list mode. I describe more information later.

You can do the following in the "Action".
Jump to end of programIt will show the last line of the program list.
Display RUN screenIt will display the results of the previous running screen.
Display Debug screenIt will display the results of the previous debug screen and running screen.
Printout Program ListProgram list is printed out to AirPrint printer.
Printout Debug screenDebug screen id printed out to AirPrint printer.
Printout RUN screenPrevious runnning screen is printed out to AirPrint printer.
If you have not RUN even once, it will not be displayed.
** Notice ** The "Run screen" will be updated when the program actually start running.
In other words, until the actual execution state from the start of the compilation of the program, it remains before.
On the other hand, debug screen will be updated from the time of the start of the compilation.
Therefore, when you view the debug screen when an error occurs during compilation,
debug screen shows this program's, and run screen shows the previous program's.

When you tap the "Search String", you can search for a string in the program.
The search starting position is follows:
If you tap "Linen No. jump", you can jump to the line of No.
(Left is "Staring Search" , right is "Line No. jump".)
 
In the iPad, search string can also be done in the help. (Display the results are different in the editor).


// How to select / save / delete of the BASIC program

When you want to select the BASIC program, please press the  button.
Then program selection menu will open.
The X-BASIC' built-in sample program and user created program are displayed here.
You can select a source type by segment. The numbers written on the segment are the number contained therein.
The program name colored with blue is built-in sample and colored black is user created program.

If you select "Create a new", you create a new program.

When you will run the program that was edit or create a new or you will select another program, 
it confirms you to save the program.
user programbuild-in / Creat a new
Save Overwrite to same program. It can not select when creating a new or built-in sample.
Save as Save with name.

No Save(On Memory) It does not save the program.
If you do not save the program, it continues to be recorded on memory until you load another program. So it can run.
Until you save, it has to check every time in the above timing.
On the contrary, please note that the program disappear when you choose a different program without saving.
The program is saved by the UTF8 character code always.

//---------------------------------------------

If you want to remove the program that you created, you press the so it becomes program delete mode. When you tap, it appears "Delete". And when you tap "Delete" then the program will be deleted.
Incidentally, you can delete your-created program(dipslay with black color) only. Built-in sample(blue) and of course as "Create a new"(red) can not delete. Attention: If you delete the program that is displaying (during editing) currently, and for later, if you will not "save as", the program file is vanished. Please note.


// Program file

The program file converts a character code automatically, and read it.
By default, files that use character only the range of ASCII, or files that use UTF8 are read
directly. SHIFT-JIS files are read with convert to UTF8.

Basically, the character code is recognized automatically (for SHIFT-JIS and UTF8), 
but by a combination of special characters, it sometimes recognize mistakenly.
if so , please use the "forced  SHIFT-JIS mode".

In forced SHIFT-JIS mode and if the program file is SHIFT-JIS, 
read without character code conversion.
(If the program file is UTF8, forced SHIFT-JIS mode is automatically canceled.)
1line length The length of 1 line is max 255 bytes.
It is regardless maximum string length setting.
when you use the multiple-byte character code of UTF8, it can not be measured length by look.
So I recommend you to be 1 line as short as possible.
Newline code The newline code(line ending) can use CR+LF(&h0d+&h0a) or CR only or LF only.
It is automatically identify. However, it can not mix them.
Tab code If the file contains a TAB, it is replaced with four spaces, regardless of the digit position.
In addition, the built-in editor will not be put in TAB.
Line number It can read a X-BASIC/68's program file with line numbers.
However, the line number itself all remove, so error will occur when you are using goto and gosub without label.
Whether or not there is a line number, it will determine in the first line of the program.
If there is no line number in the first line, even if there is a line number in the second line or later,
it will not be removed. (Because it does not remove the dim element line by misjudging.)
Comment If there is /* or // , it regarded as a comment from it to the end of the line.
The empty line(only newlines) is also permitted.
You can describe any letter within the comment.
Indention The indention by space or the tab is free.
Multi-statement If you want to write multiple statement, you need to write ':' for connect them.
When you describe comment after a statement, ':' is necessary basically.
Example:
print a :// display a


// Edit of the program

When you press the "Edit" button, it will be edit mode.
The button changes to the "List", and the line number will disappear.
When you tap on the line you want to edit, the keyboard will be appeared.
 
After editing, you will press the "list".
The button will return to the "Edit" after confirming whether to save the program.
Since renumbering in line when you return to the editing, it may take some time.
The list display position in the list mode and edit mode is not same.
This is due to constraints of iOS system and lack of my technology.

Note that in forced SHIFT-JIS mode, It can not edit. (Because iOS can not edit SHIFT-JIS text directly).


// Settings

X-BASIC' has the following behavior/general settings.

namevaluedescription
Max string length 15-1023(bytes)
Default is 255 bytes.
You set the maximum byte length of one string.
This is not only for variables, it will affect to all string (constant or string addition (a$+b$) or etc).
Work area size of one string on X-BASIC' is fixed. The termination code 1 byte is added. So one string work size will be the setting size+1 bytes.
The work area size of all strings is fixed. So this setting will also affect the maximum number of string variable. If you set shorter length, the number of string variables which can use are increase. On the contrary, if you set longer length , the number of string variables are decrease.

For example, if you set 15 bytes(work is 16bytes) then you can use 16 times more variable than the default setting (because 16*16=256).
If you set 1023 bytes(work is 1024bytes) then you can use 1/4 times less variable than the default setting (becase 1024=256*4).

If you do not have enough string length or if you want to increase the number of string variables (even though reduce the length of the string), you change this setting.

This setting does not influence the speed of the string process.
This value is eble to read by maxStringLength() function(It can not to set.)
Variable auto declear ON=Allowed
OFF=Not allowed
Permission of the automatic declaration of the variables and array. This setting controls the following two items at the same time.
  1. When an undeclared variable came out, automatically be defined as int.
  2. Allowed to ensure an array with no dim statement.
"No dim statement array declaration" is able to ensure an array which format is "type name (the number of elements)".
This specification was hidden in X-BASIC/68.

Default is "OFF".
Please use "Arrow" mode only if you use the BASIC text of the X-BASIC/68 and difficult to fix it.
Forced SHIFT-JIS OFF/ON/AUTO Forced SHIFT-JIS mode, including code conversion at the time of reading the program file, it is a mode in which all the inside processes remain SHIFT-JIS character code.

The program of origin X-BASIC/68, a program that internal processing is strongly dependent on the SHIFT-JIS, please use it.
When you set ON, the character code will be processed as of SHIFT-JIS, statements or functions with similar to X-BASIC/68 are automatically converted to UTF8.
When you set AUTO, system will recognize the character code of the source file, and set to either off / on.
The forced SHIFT-JIS mode is able to change by forcedSJIS() function while running.
displaying string constant print, input, linput, setFunctionKey(), symbol(), prints()
file name string
that is passed to external functions
fopen(), fdelete(), frename(), filelength(),
pngSave(), jpegSave(), imgLoad(), tileImgLoad(),
setFunctionKeyBackgroundImage()
font name string
that is passed to external functions
font(),symbol()
However, it can not correspond to character code processing. You need to convert the SHIFT-JIS to UTF8 code programmatically. (See sample codeSJIS.bas/codeUTF8.bas)
Sprite functions ON/OFF It set whether enable the sprite function.
The sprite requires a large amount of work memory.
Please turn off in this when it comes to memory shortage.
X68 Compatible functions ON/OFF It set whether enable the X68 compatible/convenient/card functions.
When the function names in the existing program is duplicate and it is difficult to modify program, please turn it off.
In addition, unlike the sprite function, even If you will turn it off, the consumption of memory does not change.
Old display compatible ON/OFF Display control of the text screen has changed little at V3.00.
Therefore, the result of display may not same as older version's.
Please try to turn it on when you think the display is abnormal in V3.00.
Error value of fopen() Old(0)/New(-1) In V3.10, I changed the error value of fopen() as same as X-BASIC/68.
If you use old error value, you will set this "Old".
Also you can set the error value by errorCodeFopen() programmatically.
List Font It sets the font to view and edit the program list on the screen.
Some fonts which are not suitable to display the program list has been omitted.
 
It is not related to the font during basic program run.



// About intermediate code compile and the error

When you push , X-BASIC' will be compiled into intermediate code
internally the program of BASIC, and after that, run it.

During compiling the intermediate code, when an error occurs, it will continue to compile from
the next line (skip error line). For this reason, you may receive some error in the subsequent
compilation. Therefore, it is recommended that error fix from top to bottom.
In some cases, more than one error goes away after you correct an error of one
(In particular loop system).

In addition, the compilation always will be made ​​to entire source.
Even if there is end or stop statement on the way, it will be compiled later.
It also compiled where it does not pass through at the time of running.
Example:
int a a=10 if NO then { // It do not come here at the time of running int a <-Variable name is redefinition }
When errors occur, the contents of the error and its row is listed below the program.
When you tap each error, you will jump to that line. You can turn off the error display by pressing . At run time, it is stop by one error occur.


// Run the X-BASIC program

Runtime screen is as follows.
You can break the program by pushing . You can not resume the breaked program. Also, during input / linput / selectMenu()(and so on)/ logoAlert() , / are not effective. At input and linput, it is interrupted immediately after input.
When you break running, or program end, will be disable and will be enable.

When you push , It returns to program list display.

When you push , It runs BASIC program again.
Also you return to the program display, if you select "Display RUN screen" from the , the execution result of the previous screen you can see at any time.
In the "RUN screen" display, Press again to , you will return to the original screen.
Note:

// Debugging support

In this debug support functions, you can do as follow:
To output debug information, you must set debug mode in the program.
For detail, please see debug functions.
Basically, you can set the timing and information type.
And you can store any message to debug screen for knowing program state.
Also, When execute 'stop' statement or when Break pressed, it will output stopped line number.
(The line number at Break may be slightly shifted, sorry.)

When you tap  in running, then debug screen overlaps on the run screen.

When you tap , you can adjust the overlapped condition (permeability of run screen).
When you tap , the debug screen is cleared.

You can RUN while to display the debug screen.
Since the content update of the debug screen is once per a second, display might be slightly delayed.

The debug information is kept until user's clear operation or next run.
If you go back list screen, you can re-display this by the operation : Action-"Display debug screen".

In the debug screen, not only running error but also compile error message.
Both the  running error and the compile error message are stored to debug screen.

Also you can capture the error in startup.bas, conventional it was difficult.
If you want look them, you operate Action-"Diaplay debug screen" (because it is before program running).

// Character code

The internal character code is UTF8 by default, but it is with SHIFT-JIS when you select
"forced SHIFT-JIS mode".
In either case, the range of &h20 to &h7e is identical (ASCII code range).
The character code is totally different from UTF8 and SHIFT-JIS at the same letter.
In addition, the number of bytes does not accord with the width of the appearance in the UTF8.
Please be careful.


ASCII   &h20 to &h7e    1 byte by one character
-code-:-+0-+1-+2-+3-+4-+5-+6-+7-+8-+9-+A-+B-+C-+D-+E-+F-
  20  :     !  "  #  $  %  &  '  (  )  *  +  ,  -  .  / 
  30  :  0  1  2  3  4  5  6  7  8  9  :  ;  <  =  >  ?
  40  :  @  A  B  C  D  E  F  G  H  I  J  K  L  M  N  O 
  50  :  P  Q  R  S  T  U  V  W  X  Y  Z  [  \  ]  ^  _ 
  60  :  `  a  b  c  d  e  f  g  h  i  j  k  l  m  n  o 
  70  :  p  q  r  s  t  u  v  w  x  y  z  {  |  }  ~  *

UTF8
    https://en.wikipedia.org/wiki/UTF8
    One character becomes 2 to 6 bytes. But X-BASIC' supports 2 to 4 bytes character only.

SHIFT-JIS
    The iOS version supports only a range supported in X680x0.
    1/2 and 1/4 corner letter are converted into a basic letter of ASCII.
    One character is 2 bytes.
    https://en.wikipedia.org/wiki/Shift_JIS

X-BASIC' has some UTF-16 functions, 
but please note that it is unable to display directly in X-BASIC'.


&h00 to &h1f and &h7f is the control code.
In particular, &h00 has become a code indicating the end of the string, it can not be
included in the string. The following cords have each meaning.
The behind token is the external function which has equivalent processing (see below).
&h05Clear from cursor to end of line
&h07Sound a beepbeep()
&h09Horizontal tabtab(1)
&h0aNew line
&h0bMove cursor at the home positionhome()
&h0cText screen all clearcls()
&h0dNewline
&h0eReverse newline
&h1aClear from cursor to end of screen
&h1cMove cursor rightcursorMove()
&h1dMove cursor leftcursorMove()
&h1eMove cursor upcursorMove()
&h1fMove cursor downcursorMove()
In addition, the movement result of each control code is not identical to X-BASIC/68 or peke-BASIC.

Other cords movement is undecided justice.


// Location of files and file name terms

Location of the input and output files in the "X-BASIC'" are as follows.
The output file is stored to the "User file area" only.
The input file is searched from "User file area" to "System area" (With some exceptions).
Only user file area pngSave() , jpegSave() , fdelete() , frename()
hcopy() , emailSend() , zipExpand() , zipArchive()
mkdir() , rmdir()
fopen() except "r"
user program program file
(Enable to) Search from user file area to system area fopen() "r" only , filelength() , filecopy()
picLoader() , cutLoader() , bitmapImageFile() , sp_image()
imgLoad() , tileImgLoad() , setFunctionKeyBackgroundImage()
files() , cardInit()
m_ftrk() , m_tone()
program-file
In the system area, there are only sample programs and its data files. 
They are not able to modify and delete.

In the user file area, there are all files(program and data) made by user.
They are able to modify and delete freely.

You can make directory(folder) in this area.
"X-BASIC'" does not have concept of current directoty.
And all program always act so as in the root regardless of the real presence of the directory.
Therefore, when you specify a directory, you do not need the '/' in top of it.

    Example:  "dir/file"  correct
              "/dir/file" wrong

The rules of the filename follows the iOS rules. 
Basically it is same as MacOS.
But filename and directory name must not include surrogate pair character.
Main difference with Windows are follows:
Another rules are almost same.
On the X68000,when TwentyOne is not enable, filename are compared only by with 8bytes-filename and 3bytes-extention.
But on the iOS, filename and extention are compared by all characters.

The files and directories made by user are not deleted automatically at deleting the program which use the files and directories. 
Conversely, such as files will continue to remain as long as the user does not delete with programatically. 
Therefore, Please remove the non use file by fdelete() or rmdir().


// Differences between Japanese version and English version

The X-BASIC' has Japanese and English versions.
Both are almost the same including the character code other than the language of 
the system message.
Here is a summary of the differences.
For more information, please refer to the manual version of both.
  1. Format character of print using "$"
  2. Return value of day$


// Sample programs


Please visit X-BASIC' Support Blog.


Copyright (C) 2012-16 by AIG-Soft
[Return]