汎用機メモっとくか

しごと用の(学習メモ&お気に入り保存)。

LibreOfficeマクロ雑記

2021年12月05日 09時23分59秒 | OOoCalcBasic

Libre Office version 5.4.1.2 で下記をトライ。

Main01 は動く
Main02 は put  で
 Basicランタイムエラー
 デバイスI/O エラー
になる。

最新version で試す必要あり。

REM  *****  BASI          C  *****

Type putInt

         tstInt( 2999 ) As  Integer
End Type

Sub Main01
    Dim fileName As String
    
    Dim fileNO    As Integer
    
    Dim tstInt(2)  As  Integer
    tstInt(0)   =    0
    tstInt(1)   =    255
    tstInt(2)   =    -1
    fileName = "C:\Users\user\desktop\libre01.dat"
    fileNO    =  FreeFile()
    
    Open  fileName For Random As fileNO
    Put  #fileNO,   , tstInt(0)
    Put  #fileNO,   , tstInt(1)
    Put  #fileNO,   , tstInt(2)
    Close fileNO
    Msgbox "owari"

End Sub

 

REM  *****  BASIC  *****

Sub Main02
    Dim fileName As String
    Dim fileNO    As Integer
    Dim  ix      As  Long
    Dim  iy     As  Long
    Dim  testInt(4)  As  New putInt    

    For   ix =  0  To  4
        For  iy  =  0  To  2999
            testInt( ix ).tstInt( iy )   =  Int(   Rnd()  *  65536 )   - 32768
        Next
    Next
    
    fileName = "C:\Users\user\desktop\libre100M.bin"
    fileNO    =  FreeFile()
    
    Open  fileName For Random As fileNO
    
    Dim   iz   As  Long
    Dim   px  As  Long
 
    
    For   iz   =   1  To   100
        px   =   Int(  Rnd()  *  5 )   
        Put  #fileNO,   ,  testInt(  px  )
    Next
    Msgbox "owari"

    Close fileNO
End Sub

<20211208STA> Libre Office version 5.4.1.2 でなんとか動かす


Sub Main02_00
    Dim fileName As String
    Dim fileNO    As Integer
    Dim  ix      As  Long
    Dim  iy     As  Long
    Dim  testInt                   As   Integer    
    ' 32768 >   30000  =  ( 14999 + 1 ) * 2
    Dim  putInt00(    14999)  As   Integer
    Dim  putInt01(    14999)  As   Integer
    Dim  putInt02(    14999)  As   Integer
    Dim  putInt03(    14999)  As   Integer
    Dim  putInt04(    14999)  As   Integer    
    
    Dim  Max                       As   Integer
    Max  = 14999
    For   ix =  0  To  4
        For  iy  =  0  To  Max
            testInt  =  Int(   Rnd()  *  65536 )   - 32768
            Select   Case  ix
                Case  0    
                    'PUT  MAX  32768BYTE 
                    putInt00(  iy  )  =  testInt
                Case  1
                    putInt01(  iy  )  =  testInt 
                Case  2
                    putInt02(  iy  )  =  testInt
                Case  3 
                    putInt03(  iy  )  =  testInt
                Case  4 
                    putInt04(  iy  )   =  testInt
            End  Select    
        Next
    Next
    
    fileName = "C:\User\user\desktop\libre02_00_100M.bin"
    fileNO    =  FreeFile  
    Open  fileName For  Binary   As   fileNO
    
    Dim   iz   As  Long
    Dim   px  As  Long
 
    Msgbox "書きます"
    For   iz   =   1  To   1000
           px   =   Int(  Rnd()  *  5 )
           Select   Case  px
                Case  0    
                    Put  #fileNO,   , putInt00
                Case  1
                    Put  #fileNO,   , putInt01
                Case  2
                    Put  #fileNO,   , putInt02
                Case  3 
                    Put  #fileNO,   , putInt03
                Case  4 
                    Put  #fileNO,   , putInt04
            End  Select
    Next
    
    
     Close fileNO
     Msgbox "owari"

End Sub

<20211208END>

Excel2013 構造体64kbの壁あり

Type putInt

         tstInt(29999) As Integer
End Type


 

Rem  *****  BASIC  *****

Sub abcdeMain02()
    Dim fileName As String
    Dim fileNO    As Integer
    Dim ix       As Long
    Dim iy      As Long
    Dim testInt(4)   As putInt

    For ix = 0 To 4
        For iy = 0 To 29999
            testInt(ix).tstInt(iy) = Int(Rnd() * 65536) - 32768
        Next
    Next
    
    fileName = "C:\Users\user\desktop\libre100M.bin"
    fileNO = FreeFile()
    
    Open fileName For Binary As fileNO
    
    Dim iz     As Long
    Dim px    As Long
 
    
    For iz = 1 To 100
        px = Int(Rnd() * 5)
        Put #fileNO, , testInt(px)
    Next
    
    Close fileNO
    
    MsgBox "owari"

End Sub