Advertisement
Mark2020H

How to automate and use Libre Office Basic for IOT and many other applications (Spread sheets)

Sep 25th, 2024
242
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 4.20 KB | Source Code | 0 0
  1. REM https://www.dropbox.COM/.../AIys-JZv9Q4QypkbGPHJ5FI...
  2. REM Subject  ::   LibreOffice Calc AND USING this  AS per  media shown further down  at this link here
  3. REM https://www.facebook.COM/mark.harrington.14289/videos/1187026392576183
  4. REM
  5. REM I will  be posting this  , " code only " ON   paste bin   in a few  minutes so that  you can VIEW  , download  , study etc
  6. REM
  7. REM Alfred Adukobirre Adukobilla  ,  Jacqui Nosy Gcingca   AND may even interest  yourself  Blessing Emejulu , Brian Yearwood  , Pallab Nandi ,  also many other people who may be interested TO see how this IS done
  8. REM
  9. REM PS READ the notes  contained at  Dropbox link mentioned above in   First link
  10. REM Note  NB ****  This works only with  Libre Calc  IF you want TO  expand this TO  Microsoft Office THEN  you will have TO change  code TO VBA  ***
  11. REM
  12. REM A good exorcise FOR you at ANY rate  
  13. REM
  14. REM Learn , enjoy AND expand your skills
  15. REM
  16. REM Have a good evening all AND  take care
  17.  
  18.  
  19.  
  20.  
  21.  
  22. REM  *****  BASIC  *****
  23. REM ***  MD Harrington  kent London  DA6 8NP
  24. REM  ***** DATE TODAY IS 25:09/2024 TIME : 00:00 HRS
  25.  
  26. SUB PrintArrayForC
  27.  DIM oSheet AS Object
  28.     DIM oRange AS Object
  29.     DIM oCell AS Object
  30.  
  31.     ' Access the first sheet (Sheet1)
  32.     oSheet = ThisComponent.Sheets(0)
  33.    
  34.     ' Access the merged cell range (B26:J27)
  35.     oRange = oSheet.getCellRangeByName("B26:J27")
  36.    
  37.     ' Access the first cell in the merged range
  38.     oCell = oRange.getCellByPosition(0, 0) ' The first cell of the merged range (B26)
  39.    
  40.     ' Update the value in the first cell of the merged range
  41.     oCell.STRING =  CreateCharArrayFromColumn()
  42. END SUB
  43.  
  44.  
  45. SUB ClearData
  46. DIM oSheet AS Object
  47.     DIM oRange AS Object
  48.     DIM oCell AS Object
  49.  
  50.     ' Access the first sheet (Sheet1)
  51.     oSheet = ThisComponent.Sheets(0)
  52.    
  53.     ' Access the merged cell range (B26:J27)
  54.     oRange = oSheet.getCellRangeByName("B26:J27")
  55.    
  56.     ' Access the first cell in the merged range
  57.     oCell = oRange.getCellByPosition(0, 0) ' The first cell of the merged range (B26)
  58.    
  59.     ' Update the value in the first cell of the merged range
  60.     oCell.STRING = ""
  61.  
  62. END SUB
  63.  
  64.  
  65.  
  66. FUNCTION CreateCharArrayFromColumn() AS STRING
  67.     DIM oSheet AS Object
  68.     DIM oCell AS Object
  69.     DIM i AS INTEGER
  70.     DIM startRow AS INTEGER
  71.     DIM endRow AS INTEGER
  72.     DIM resultString AS STRING
  73.     DIM value AS STRING
  74.  
  75.     ' Access the first sheet (Sheet1)
  76.     oSheet = ThisComponent.Sheets(0)
  77.    
  78.     ' Define the start and end rows (J7 to J16 means row 6 to row 15 in 0-indexed)
  79.     startRow = 6  ' J7
  80.     endRow = 15   ' J16
  81.    
  82.     ' Initialize the result string with the initial text
  83.     resultString = "unsigned char m_array [10] = { "
  84.    
  85.     ' Loop through the cells in column J (index 9) from J7 to J16
  86.     FOR i = startRow TO endRow
  87.         ' Access the current cell in column J
  88.         oCell = oSheet.getCellByPosition(9, i)
  89.        
  90.         ' Get the cell's value as a string (you can also use .getValue if they are numbers)
  91.         value = oCell.getString()
  92.        
  93.         ' Append the value to the result string
  94.         resultString = resultString & value
  95.        
  96.         ' Add a comma between values, but avoid it after the last one
  97.         IF i < endRow THEN
  98.             resultString = resultString & ", "
  99.         END IF
  100.     NEXT i
  101.    
  102.     ' Close the array declaration in the string
  103.     resultString = resultString & " };"
  104.    
  105.     ' Return the final string
  106.     CreateCharArrayFromColumn = resultString
  107. END FUNCTION
  108.  
  109.  
  110. REM Notes about other code
  111. REM These  functions are built in
  112. REM =CONCAT("0x",DEC2HEX(H7,2))  this  IS entered into column J
  113. REM =CONCAT("0b000",C7:G7)  this IS entered into Column I
  114. REM =BIN2DEC(MID(I7,3,8)) this IS entered into Column H
  115.  
  116. ' bare in mind  that you have to understand what these functions  do   but this
  117. ' is how I  work out truth tables  to plug into code
  118. ' Ive produced this to show  you   how to use   spreadsheets  to your advantage  using
  119. ' With automation in mind  
  120. ' You can  do much more than just this  and its possiblities are endless
  121. ' auto email , networking , security , iot  you name it
  122. ' That is all in your hands  and how you  implement  knowledge
  123.  
  124.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement