パラメーターと戻り値の実験 LibreOffice Calc Basic [LibreOffice Calc Basic]
パラメーターと戻り値の実験 LibreOffice Calc Basic
参照サイト https://wiki.openoffice.org/wiki/JA/Documentation/BASIC_Guide/Procedures_and_Functions
Sub Test
Dim A As Integer
A = 10
ChangeValue(A)
' 変数Aを渡して変数Aが処理されて帰って来る,戻り値はAでxは関係ない
Print A '30
Print x '0 NG
Print ChangeValue 'NG
End Sub
x = 20+x
End Function
Sub testURL()
Dim oURL As String
oURL="files:///home/telstar/ピクチャ/027_1000.jpg"
Call url_fileName(oURL)
'戻り値
Print oURL
End Sub
Function url_fileName( fullpass As string)
'パラメーターを受け取りファイルのフルパスからファイル名を取り出す
'戻り値はCall url_fileName(oURL)のoURL
'文字数
'Print len(fullpass)
'Print fullpass
Len_oURL=len(fullpass)
'文字列をmid関数で右から1文字づつ取り出す
For i=Len_oURL To 1 Step -1
'mid(対象文字列,位置,文字数)
a=mid(fullpass,i,1)
'取り出した文字が"/"なら
If a="/" Then
'Loopの何番目か
count_i=i
'文字列の最初の"/"は右から何番目か
count_right=Len_oURL-count_i
'文字列からright関数で右からcount_right分取り出す
fullpass=right(fullpass,count_right)
'Loop終了
i=1
End If
Next i
End Function
Dim oURL As String
oURL="files:///home/telstar/ピクチャ/027_1000.jpg"
Call url_fileName(oURL)
'戻り値
Print oURL
End Sub
Function url_fileName( fullpass As string)
'パラメーターを受け取りファイルのフルパスからファイル名を取り出す
'戻り値はCall url_fileName(oURL)のoURL
'文字数
'Print len(fullpass)
'Print fullpass
Len_oURL=len(fullpass)
'文字列をmid関数で右から1文字づつ取り出す
For i=Len_oURL To 1 Step -1
'mid(対象文字列,位置,文字数)
a=mid(fullpass,i,1)
'取り出した文字が"/"なら
If a="/" Then
'Loopの何番目か
count_i=i
'文字列の最初の"/"は右から何番目か
count_right=Len_oURL-count_i
'文字列からright関数で右からcount_right分取り出す
fullpass=right(fullpass,count_right)
'Loop終了
i=1
End If
Next i
End Function
コメント 0