Index: trunk/Include/basic/function.sbp
===================================================================
--- trunk/Include/basic/function.sbp	(revision 457)
+++ trunk/Include/basic/function.sbp	(revision 497)
@@ -1,8 +1,3 @@
 'function.sbp
-
-
-#ifndef _INC_FUNCTION
-#define _INC_FUNCTION
-
 
 Const _System_PI = 3.14159265358979323846264
@@ -10,12 +5,4 @@
 Const _System_SQRT2 = 1.41421356237309504880168872421
 Const _System_Log_N = 7 As Long
-
-
-#require <Classes/System/Math.ab>
-#require <Classes/System/DateTime.ab>
-#require <Classes/System/Text/StringBuilder.ab>
-#require <Classes/ActiveBasic/Math/Math.ab>
-#require <Classes/ActiveBasic/Strings/Strings.ab>
-
 
 '------------- サポート関数の定義 -------------
@@ -243,13 +230,13 @@
 '------------
 
-Function Asc(buf As String) As StrChar
+Function Asc(buf As String) As Char
 	Asc = buf[0]
 End Function
 
-Function Chr$(code As StrChar) As String
+Function Chr$(code As Char) As String
 	Chr$ = New String(code, 1)
 End Function
 
-#ifndef __STRING_IS_NOT_UNICODE
+#ifdef UNICODE
 Function AscW(s As String) As UCSCHAR
 	If String.IsNullOrEmpty(s) Then
@@ -275,5 +262,5 @@
 Function ChrW(c As UCSCHAR) As String
 	If c <= &hFFFF Then
-		Return New String(c As StrChar, 1)
+		Return New String(c As Char, 1)
 	ElseIf c <= &h10FFFF Then
 		c -= &h10000
@@ -390,8 +377,8 @@
 
 Function Space$(length As Long) As String
-	Return New String(&h20 As StrChar, length)
-End Function
-
-Sub _ecvt_support(buf As *StrChar, count As Long, size As Long)
+	Return New String(&h20 As Char, length)
+End Function
+
+Sub _ecvt_support(buf As *Char, count As Long, size As Long)
 	Dim i As Long
 	If buf[count] = 9 Then
@@ -410,10 +397,10 @@
 End Sub
 
-Sub _ecvt(buffer As *StrChar, value As Double, count As Long, ByRef dec As Long, ByRef sign As Boolean)
+Sub _ecvt(buffer As *Char, value As Double, count As Long, ByRef dec As Long, ByRef sign As Boolean)
 	Dim i As Long, i2 As Long
 
 	'値が0の場合
 	If value = 0 Then
-		ActiveBasic.Strings.ChrFill(buffer, count As SIZE_T, &h30 As StrChar)
+		ActiveBasic.Strings.ChrFill(buffer, count As SIZE_T, &h30 As Char)
 		buffer[count] = 0
 		dec = 0
@@ -442,5 +429,5 @@
 
 	For i = 0 To count - 1
-		buffer[i] = Int(value) As StrChar
+		buffer[i] = Int(value) As Char
 		value = (value-CDbl(Int(value))) * 10
 	Next
@@ -471,5 +458,5 @@
 	End If
 	Dim dec As Long, sign As Boolean
-	Dim buffer[32] As StrChar, temp[15] As StrChar
+	Dim buffer[32] As Char, temp[15] As Char
 	Dim i = 0 As Long
 
@@ -585,8 +572,8 @@
 End Function
 
-Function String$(n As Long, s As StrChar) As String
+Function String$(n As Long, s As Char) As String
 	Return New String(s, n)
 End Function
-		
+
 #ifdef _AB4_COMPATIBILITY_STRING$_
 Function String$(n As Long, s As String) As String
@@ -594,8 +581,7 @@
 		'Throw ArgumentOutOfRangeException
 	End If
-
 	Dim buf = New System.Text.StringBuilder(s.Length * n)
 	Dim i As Long
-	For i = 0 To n
+	For i = 1 To n
 		buf.Append(s)
 	Next
@@ -603,9 +589,11 @@
 #else
 Function String$(n As Long, s As String) As String
+	Dim c As Char
 	If String.IsNullOrEmpty(s) Then
-		Return New String(0 As StrChar, n)
-	Else
-		Return New String(s[0], n)
-	End If
+		c = 0
+	Else
+		c = s[0]
+	End If
+	String$ = New String(c, n)
 End Function
 #endif
@@ -613,7 +601,5 @@
 Function Time$() As String
 	Dim time = System.DateTime.Now
-
 	Dim buf = New System.Text.StringBuilder(8)
-
 	'hour
 	If time.Hour < 10 Then
@@ -640,8 +626,8 @@
 End Function
 
-Function Val(buf As *StrChar) As Double
+Function Val(buf As *Char) As Double
 	Dim i As Long, i2 As Long, i3 As Long, i4 As Long
 	Dim temporary As String
-	Dim TempPtr As *StrChar
+	Dim TempPtr As *Char
 	Dim dbl As Double
 	Dim i64data As Int64
@@ -665,5 +651,5 @@
 				If Not (0<=i3 And i3<=7) Then Exit While
 
-				TempPtr[i]=i3 As StrChar
+				TempPtr[i]=i3 As Char
 				i++
 			Wend
@@ -688,5 +674,5 @@
 				End If
 
-				TempPtr[i]=i3 As StrChar
+				TempPtr[i]=i3 As Char
 				i++
 			Wend
@@ -703,8 +689,8 @@
 	Else
 		'10進数
-#ifdef __STRING_IS_NOT_UNICODE
+#ifdef UNICODE
+		swscanf(buf,"%lf",VarPtr(Val))
+#else
 		sscanf(buf,"%lf",VarPtr(Val))
-#else
-		swscanf(buf,ToWCStr("%lf"),VarPtr(Val))
 #endif
 	End If
@@ -981,5 +967,5 @@
 
 Function _System_IsLowSurrogate(c As WCHAR) As Boolean
-	Return &hDC00 <= c And c < &hE000 
+	Return &hDC00 <= c And c < &hE000
 End Function
 
@@ -1000,4 +986,2 @@
 	_System_GetHashFromWordArray = hash As Long
 End Function
-
-#endif '_INC_FUNCTION
