***************************************************************************

	N88-BASIC / Be88-BASIC
		English reference manual (Functions)
			by SHINTA

***************************************************************************



===== Quick description =====

 This document is a function reference about N88-BASIC or Be88-BASIC.
 This may include something unsupported by Be88-BASIC, supported by only N88-BASIC.
 See reference book of N88-BASIC for more information.



===== Overview =====


[ General functions ]

SEARCH


[ Text screen ]

CSRLIN
POS
SPC
TAB


[ Graphic screen ]

[1] POINT
[2] POINT


[ Alithmetic functions ]

ABS
ATN
CDBL
CINT
COS
CSNG
EXP
FIX
INT
LOG
RND
SGN
SIN
SQR
TAN


[ 1-byte string ]

ASC
CHR$
HEX$
INSTR
LEFT$
LEN
MID$
OCT$
RIGHT$
SPACE$
STR$
STRING$
VAL


[ 2-byte string ( Japanese ) ]

AKCNV$
JIS$
KACNV$
KEXT$
KINSTR
KLEN
KMID$
KNJ$


[ File control ]

EOF
INPUT$

[ Key control ]

INKEY$


[ Time / Date ]

DATE$
TIME$


[ I/O port ]

INP



===== Legend =====

* Description * says the action in easy.
* Format * is general format. Items inserted between [ and ] is abbreviate.
* Example * is cencrete expression. You can copy and paste these strings to Main Window and run ( probably ...).



===== Reference =====


[ ABS ]

* Description *	Absolute value.
* Format *		ABS(<Expression>)
* Example *		PRINT ABS(-5.37)


[ AKCNV$ ]

* Description *	Convert 1-byte string to 2-byte string.
* Format *		AKCNV$(<String>)
* Example *		WIDE$=AKCNV$("ABC abc 123")

 You must set Run Window's font to Japanese font ( Haru etc. ) in Preferences Window.


[ ASC ]

* Description *	Character code ( ASCII code ).
* Format *		ASC(<String>)
* Example *		CC=ASC("Z")

 Get character code of the first character in <String>.


[ ATN ]

* Description *	Arc tangent.
* Format *		ATN(<Expression>)
* Example *		ANGLE=ATN(3.14159/2)

 Get arc tangent in radian.


[ CHR$ ]

* Description *	Character.
* Format *		CHR$(<Expression>)
* Example *		PRINT CHR$(65)

 Get character correspondending to the character code specified by <Expression>.


[ CINT ]

* Description *	Convert float or double to integer.
* Format *		CINT(<Expression>)
* Example *		A%=CINT(3.5/B!)

 Round <Expression> off.


[ COS ]

* Description *	Cosin.
* Format *		COS(<Expression>)
* Example *		YPOS=R*COS(ANGLE)

 Get cosin in radian.


[ CSNG ]

* Description *	Convert integer or double to float.
* Format *		CSNG(<Expression>)
* Example *		A!=CSNG(5.7*B#)


[ CSRLIN ]

* Description *	Row of cursor.
* Format *		CSRLIN
* Example *		YPOS=CSRLIN

 Get virtical position of cursor.


[ DATE$ ]

* Description *	Date.
* Format *		DATE$
* Example *		PRINT "Today is ";DATE$

 Get date in the format "yy/mm/dd".


[ EOF ]

* Description *	Check End of File.
* Format *		EOF(<File number>)
* Example *		IF EOF(1) THEN CLOSE 1

 If the file specified by <File number> goals to end, EOF returns true (-1). Otherwise, EOF returns false (0).


[ EXP ]

* Description *	Exponential of e.
* Format *		EXP(<Expression>)
* Example *		E=EXP(1)


[ FIX ]

* Description *	Integer.
* Format *		FIX(<Expression>)
* Example *		KB=FIX(FILESIZE/1024)

 FIX and INT differ when <Expression> is negative value.


[ HEX$ ]

* Description *	Convert number in dec to string in hex.
* Format *		HEX$(<Expression>)
* Example *		A$=HEX$(32)

 HEX$ returns the follow values.

===================================
<Expression>		String in hex
===================================
     0 ~ 32767		   "0" ~ "7FFF"
 32768 ~ 65535		"8000" ~ "FFFF"
-32768 ~     1		"8000" ~ "FFFF"
===================================


[ INKEY$ ]

* Description *	Pressed key.
* Format *		INKEY$
* Example *		IF INKEY$="4" THEN GOSUB *GOLEFT

 If no key is pressed, INKEY$ returns null string.
 INKEY$ doesn't output pressed key to text screen. INKEY$ doesn't wait for pressing key.


[ INP ]

* Description *	Value of input port.
* Format *		INP(<Port number>)
* Example *		IF INP(&HE0) AND &HEF THEN GOSUB *GOLEFT

 If &HE0 <= <Port number> <= &HEC, INP returns key state. Otherwise, INP returns 0 currently.
 The following fig is key sense.

=======================================================================
Port
Addr	Bit 7	Bit 6	Bit 5	Bit 4	Bit 3	Bit 2	Bit 1	Bit 0
=======================================================================
&HE0	Num 7	Num 6	Num 5	Num 4	Num 3	Num 2	Num 1	Num 0
&HE1	Enter	Num .	Num ,	Num =	Num +	Num *	Num 9	Num 8
&HE2	G		F		E		D		C		B		A		@
&HE3	O		N		M		L		K		J		I		H
&HE4	W		V		U		T		S		R		Q		P
&HE5	-(=)	^		](})	\(|)	[({)	Z		Y		X
&HE6	7(')	6(&)	5(%)	4($)	3(#)	2(")	1(!)	0(~)
&HE7	_		/(?)	.(>)	,(<)	;(+)	:(*)	9())	8(()
&HE8	Ctrl	Shift	Kana	Alt		Delete	Right	Up		Home
&HE9	Esc		Space	F5		F4		F3		F2		F1		Stop
&HEA	Caps	Num /	Num -	Copy	End		Left	Down	Tab
&HEB													Page Up	Page Dn
&HEC	Insert	F10		F9		F8		F7		F6		XFER	BS
=======================================================================

 If key is pressed, bit is 0. If key isn't pressed, bit is 1.
 For example, if F key is pressed, INP(&HE2) is &HBF ( 10111111 ). If M key and H key are pressed, INP(&HE3) is &HDE ( 11011110 ).
 INP can check multiple key state at once.
 INP may only work well with Japanese keyboard or Japanese keymap.


[ INPUT$ ]

* Description *	Get string specifying length.
* Format *		INPUT$(<Length> [,[#]<File number>])
* Example *		YN$=INPUT$(1)

 Get string whose length is <Length> from keyboard.
 <File number> is unsupported currently.
 INPUT$ doesn't output inputted string to text screen. INPUT$ waits for input.


[ INSTR ]

* Description *	Find string.
* Format *		INSTR([<Position>,] <String 1>, <String 2>)
* Example *		A=INSTR("AppleOrangeBanana", "Orange")
				B=INSTR(5, SRC$, "C")

 Find <String2> in <String 1>. If <String 2> is found, INSTR returns the position. Otherwise, returns 0.
 <Position> specifies the search begin position. If <Position> is abbreviated, 1 is taken.
 If <String 2> is null string, INSTR returns <Position>.


[ INT ]

* Description *	Floor.
* Format *		INT(<Expression>)
* Example *		DICE=INT(RND*6)+1

 FIX and INT differ when <Expression> is negative value.


[ JIS$ ]

* Description *	Kanji code.
* Format *		JIS$(<String>)
* Example *		A$=JIS$(KMID$("漢字",2,1))

 Convert first 2 characters of <String> to kanji code ( 4 figures in hex ).
 Care KI code (&H1B4B) that is inserted at the begining of kanji string. So, you need to use KMID$ to eliminate KI code.
 KI code and KO code (&H1B48) aren't supported by Be88-BASIC.


[ KACNV$ ]

* Description *	Convert 2-byte string to 1-byte string.
* Format *		KACNV$(<String>)
* Example *		PRINT KACNV$("ＡＢＣ１２３")


[ KEXT$ ]

* Description *	Extract specified kind string.
* Format *		KEXT$(<String>, <Function>)
* Example *		A$=KEXT$(B$, 1)

 If <Function> is 0, KEXT$ extract 1-byte string. If <Function> is 1, KEXT$ extract 2-byte string.


[ KINSTR ]

* Description *	Find string ( 2-byte OK ).
* Format *		KINSTR([<Position>,] <String 1>, <String 2>)
* Example *		A=KINSTR(B$,C$)

 KINSTR is similar to INSTR, but, KINSTR count 2-byte string as 1 character.


[ KLEN ]

* Description *	Count specified string.
* Format *		KLEN(<String> [,<Function>])
* Example *		NUMASCII=KLEN(A$, 1)

 See below for <Function>.
	0	: All characters.
	1	: 1-byte characters.
	2	: 2-byte characters ( Exclude KI / KO code ).
	3	: 2-byte characters.
	4	: 2-byte half characters.
	5	: KI / KO codes ( Unsupported ).
 If <Function> is abbreviated, 0 is taken.


[ KMID$ ]

* Description *	Extract string ( 2-byte OK ).
* Format *		KMID$(<String>, <Expression 1> [,<Expression 2>])
* Example *		A$=KMID$(B$,5,3)

 KMID$ is similar to MID$, but, KMID$ counts 2-byte character as 1.


[ KNJ$ ]

* Description *	Convert kanji code to kanji.
* Format *		KNJ$(<String>)
* Example *		PRINT KNJ$("1B4B")+KNJ$("316D")+KNJ$("1B48")

 If you use string got by KNJ$ actually, you need to join KI code (&H1B4B) and KO code (&H1B48).


[ LEFT$ ]

* Description *	Extract string from left side.
* Format *		LEFT$(<String>, <Expression>)
* Example *		PRINT LEFT$("LeftMiddleRight",4)

 Extract <Expression> characters from left side of <String>.


[ LEN ]

* Description *	Number of bytes.
* Format *		LEN(<String>)
* Example *		FOR I=1 TO LEN(A$):PRINT ASC(MID$(A$,I,1)):NEXT

 Get number of bytes of <String>.


[ LOG ]

* Description *	Log(Ln).
* Format *		LOG(<Expression>)
* Example *		PRINT LOG(EXP(3))


[ MID$ ]

* Description *	Extract string.
* Format *		MID$(<String>, <Expression 1> [,<Expression 2>])
* Example *		PRINT MID$("LeftMiddleRight",5,6)

 Extract <Expression 2> characters from <String>'s position <Expression 1>.


[ OCT$ ]

* Description *	Convert number in dec to string in oct.
* Format *		OCT$(<Expression>)
* Example *		A$=OCT$(32)

 OCT$ returns the follow values.

=======================================
<Expression>		String in hex
=======================================
     0 ~ 32767		     "0" ~  "77777"
 32768 ~ 65535		"100000" ~ "177777"
-32768 ~     1		"100000" ~ "177777"
=======================================


[ [1] POINT ]

* Description *	LP.
* Format *		POINT(<Function>)
* Example *		X=POINT(0)

 Get LP ( Last Referenced Point ).
 See below for <Function>.
	0	: LP's X in world coordinate.
	1	: LP's Y in world coordinate.
	2	: LP's X in screen coordinate.
	3	: LP's Y in screen coordinate.
 World coordinate isn't supported currently.


[ [2] POINT ]

* Description *	Dot color in gaphic screen.
* Format *		POINT (Sx, Sy)
* Example *		COL=POINT(100, 100)

 Get palette number of (Sx, Sy).


[ POS ]

* Description *	Col of cursor.
* Format *		POS(<Expression>)
* Example *		XPOS=POS(0)

 Get horizontal position of cursor.
 <Expression> is dummy, but, needed.


[ RIGHT$ ]

* Description *	Extract string from right side.
* Format *		RIGHT$(<String>, <Expression>)
* Example *		PRINT RIGHT$("LeftMiddleRight",5)

 Extract <Expression> characters from right side of <String>.


[ RND ]

* Description *	Random value.
* Format *		RND [(<Expression>)]
* Example *		A=RND

 If <Expression> is 0, RND returns same thing as previous value. Otherwise, RND returns random value.


[ SEARCH ]

* Description *	Search in array.
* Format *		SEARCH(<Array variable name>, <Number> [,<Begin subscript>] [,<Step>])
* Example *		POSITION=SEARCH(A, 777, 0, 5)

 Search <Number> in <Array variable name> and returns the position as subscript. If <Number> isn't exist in the <Array variable name>, SEARCH returns -1.
 If <Begin subscript> is abbreviated, 0 is taken.
 <Step> is the step of search. If <Step> is abbreviated, 1 is taken.


[ SGN ]

* Description *	Sign.
* Format *		SGN(<Expression>)
* Example *		LEVEL=LEVEL+SGN(SCORE)

 SGN returns 1 if <Expression> is positive, returns 0 if 0, returns -1 if negative.


[ SIN ]

* Description *	Sin.
* Format *		SIN(<Expression>)
* Example *		XPOS=R*SIN(ANGLE)

 Get sin in radian.


[ SPACE$ ]

* Description *	Space string.
* Format *		SPACE$(<Expression>)
* Example *		A$="***"+SPACE$(10)+"***"

 Get space string whose length is <Expression>.


[ SPC ]

* Description *	Output spaces.
* Format *		SPC(<Expression>)
* Example *		PRINT NAME$;SPC(5);SCORE

 If <Expression> overs columns of text screen, <Expression> MOD column is taken.


[ SQR ]

* Description *	Square root.
* Format *		SQR(<Expression>)
* Example *		D=(-B+SQR(B*B-4*A*C))/2*A


[ STR$ ]

* Description *	Convert number to string.
* Format *		STR$(<Expression>)
* Example *		LABEL="WINDOW"+STR$(ID)


[ STRING$ ]

* Description *	Join characters.
* Format *		STRING$(<Expression>, |<ASCII code>|)
				                      |  <String>  |
* Example *		A$=STRING$(30, 65)
				A$=STRING$(30, "A")

 Join <ASCII code> or first character of <String> <Expression> times.


[ TAB ]

* Description *	Output spaces.
* Format *		TAB(<Expression>)
* Example *		PRINT NAME$;TAB(30);SCORE

 TAB is similar to SPC, but, <Expression> represents position from left of text screen.


[ TAN ]

* Description *	Tangent.
* Format *		TAN(<Expression>)
* Example *		Y=X*TAN(ANGLE)

 Get tangent in radian.


[ TIME$ ]

* Description *	Time.
* Format *		TIME$
* Example *		PRINT "Now ";TIME$

 Get current time in the format "hh:mm:ss".


[ VAL ]

* Description *	Convert string to number.
* Format *		VAL(<String>)
* Example *		A=VAL("&H30")

 <String> can be oct, dec, hex, float or double.

