Function 関数名 (下限 As 型, 上限 As 型, 値 As 型) As Boolean
関数名 = False
If 値 > 上限 Then
Exit Function
Elseif 値 < 下限 Then
Exit Function
End If
関数名 = True
End Function
また Select を使って書くこともできます↓
Function 関数名 (下限 As 型, 上限 As 型, 値 As 型) As Boolean
関数名 = False
Select Case 値
Case Is > 上限
Exit Function
Case Is < 下限
Exit Function
End Select
関数名 = True
End Function
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '*' at line *
次は、Windows OS のドキュメントフォルダの source.txt ファイルを読み込んで result.tsv を作成するプログラムになります。コーディングの手間を減らすためにファイル名を固定にしています。
Option Declare
Const SOURCE_FILE = {source.txt}
Const CHAR_SET = {UTF-8}
Const RESULT_FILE = {result.tsv}
Const PathPartition0 = {/} ' 初期値
Const PathPartition1 = {\} ' 選択値
Sub Click(Source As Button)
Dim RESULT_SEPARATOR As String
RESULT_SEPARATOR = Chr (9)
Dim sourcefolder As String
Dim pathpartition As String
Dim sourcefilepath, resultfilepath As String
Dim scriptshell As Variant
Dim sourcefile, resultfile As Integer
On Error Resume Next
Set scriptshell = CreateObject ({WScript.Shell})
sourcefolder = scriptshell.SpecialFolders ({MyDocuments})
On Error Goto 0
If 0 = Len (sourcefolder) Then
Print {MyDocuments フォルダが不明}
Exit Sub
End If
pathpartition = PathPartition0
If 0 < Instr (1, sourcefolder, PathPartition1) Then
pathpartition = PathPartition1
End If
sourcefilepath = sourcefolder + pathpartition + SOURCE_FILE
sourcefile = Freefile ()
Err = 0
On Error Resume Next
Open sourcefilepath For Input As sourcefile Charset = CHAR_SET
On Error Goto 0
If 0 < Err Then
Print {ファイルが見つかりません : } + sourcefilepath
Exit Sub
End If
resultfile = Freefile ()
resultfilepath = sourcefolder + pathpartition + RESULT_FILE
On Error Resume Next
Open resultfilepath For Output As resultfile
On Error Goto 0
If 0 < Err Then
Print {ファイルを作成できません : } + resultfilepath
Close sourcefile
Exit Sub
End If
Dim sourceline, currentdirectory As String
currentdirectory = {}
Do Until True = Eof (sourcefile)
Line Input #sourcefile, sourceline
Select Case Left (sourceline, 1)
Case {/}
Select Case Right (sourceline, 1)
Case {:}
currentdirectory = Left (sourceline, Len (sourceline) -1)
End Select
Case {-}
Dim columns (1) As String
Dim position, beforeposition, column As Long
columns (0) = currentdirectory
beforeposition = -1
column = 1
For position = 1 To Len (sourceline)
Select Case Mid (sourceline, position, 1)
Case { }
If (beforeposition + 1) <> position Then
column = column + 1
End If
beforeposition = position
Case Else
If (beforeposition + 1) = position Then
If 8 = column Then
columns (1) = Mid (sourceline, position)
Exit For
End If
End If
End Select
Next
Print #resultfile, Implode (columns, RESULT_SEPARATOR)
End Select
Loop
Close resultfile
Close sourcefile
End Sub
表計算ソフトを開いて、メニューの[開く]から result.tsv を選択して、区切文字をタブに指定して読み込めば完了です。 ls で / 以下すべてを取得しているとき、result.tsv の中身を表計算ソフトへコピペするとメモリ不足エラーが表示されることがあるため注意です。
途中で『Set Folder Permissions ? (Default to Y)』と聞かれたら『Y』と入力します。
エラーがでたとき
Your requirements could not be resolved to an installable set of packages.
Problem 1
- cakephp/cakephp[4.4.0, ..., 4.4.11] require ext-intl * -> it is missing from your system. Install or enable PHP's intl extension.
- Root composer.json requires cakephp/cakephp 4.4.* -> satisfiable by cakephp/cakephp[4.4.0, ..., 4.4.11].
To enable extensions, verify that they are enabled in your .ini files:
- D:\php\php.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-intl` to temporarily ignore these required extensions.