LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-17-2016, 01:21 PM   #1
biosboy4
Member
 
Registered: Aug 2015
Distribution: *DEB, Centos, NXOS
Posts: 242

Rep: Reputation: 38
New Bash Script - guidance requested


Hello,

I need to write a bash script that can automatically pick up .bas files (Visual Basic Log files) and translate them into a spreadsheet. Then of course, dropping them off where they need to go.

Does anyone have any experience with this? I know it is possible to translate them using M$ office but I don't really want to do this with powershell or wine.

Thanks,
 
Old 06-17-2016, 03:54 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 22,277

Rep: Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542
Members may not know anything about a .bas file or its format including me. Can you provide an example.

The easiest the way to translate them into a something any spreadsheet application can read is to convert the files to a CSV (Comma Separated Variable) or tab delimited file.

Last edited by michaelk; 06-17-2016 at 04:19 PM.
 
Old 06-19-2016, 05:12 AM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 18,394
Blog Entries: 12

Rep: Reputation: 5621Reputation: 5621Reputation: 5621Reputation: 5621Reputation: 5621Reputation: 5621Reputation: 5621Reputation: 5621Reputation: 5621Reputation: 5621Reputation: 5621
Quote:
Originally Posted by biosboy4 View Post
I need to write a bash script that can automatically pick up .bas files (Visual Basic Log files) and translate them into a spreadsheet.
they are log files? what sort? and what sort of spreadsheet?
we would need the format of both.
i don't know what "spreadsheet" as a generic term is supposed to mean; maybe the csv previously mentioned is sufficient.
 
Old 06-19-2016, 08:33 AM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
http://file.org/extension/bas says
"Files that contain the .bas file extension are most commonly associated with program source code that has been written in the BASIC programming language."
Source code generally being text?
No mention of them being log files...

I also think some clarity is needed.
Leave out the references to proprietary software/OSs and the wine software.

How would you describe the problem?

Last edited by Habitual; 06-19-2016 at 08:37 AM.
 
Old 06-20-2016, 10:55 AM   #5
biosboy4
Member
 
Registered: Aug 2015
Distribution: *DEB, Centos, NXOS
Posts: 242

Original Poster
Rep: Reputation: 38
Sorry, I got that a little jumbled up.

The Balancer logs balance data to a file called mv6

I rename that file to mv6.csv and open it with excel, then run a decodemodule.bas in a new visual basic window to make the log files readable.

Is this something that can be scripted to work with Libreoffice or Openoffice?
 
Old 06-20-2016, 11:23 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 22,277

Rep: Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542
Maybe, without knowing anything about the VB script I can't say 100% that it could modified to run in Libreoffice or Openoffice. Since the log file appears to be a CSV file already the VB script probably could be rewritten in another language as another option.
 
Old 06-20-2016, 11:26 AM   #7
biosboy4
Member
 
Registered: Aug 2015
Distribution: *DEB, Centos, NXOS
Posts: 242

Original Poster
Rep: Reputation: 38
Here's the module:

Quote:
'
' RH2LogDecodeModule.bas
' Hunter Engineering Company
'
' Date: July 25, 2012
' Author: Erik Hensens
' Description: Implements a Microsoft Excel Visual Basic script that decodes RH2 Balancer log files.
'


' Get the "Lookup Table" multiplier for a given iIndex
' These values are constant and are also used to encode values in the Balancer code
Public Function dGetLookupTableMultiplier(iIndex As Integer) As Double

If (iIndex = 10) Then
dGetLookupTableMultiplier = 73.3841
ElseIf (iIndex = 11) Then
dGetLookupTableMultiplier = 32.7513
ElseIf (iIndex = 12) Then
dGetLookupTableMultiplier = 83.2346
ElseIf (iIndex = 13) Then
dGetLookupTableMultiplier = 41.1273
ElseIf (iIndex = 14) Then
dGetLookupTableMultiplier = 64.7793
ElseIf (iIndex = 15) Then
dGetLookupTableMultiplier = 37.6312
ElseIf (iIndex = 16) Then
dGetLookupTableMultiplier = 93.0908
ElseIf (iIndex = 17) Then
dGetLookupTableMultiplier = 10.8811
ElseIf (iIndex = 18) Then
dGetLookupTableMultiplier = 44.2431
ElseIf (iIndex = 19) Then
dGetLookupTableMultiplier = 37.1286
ElseIf (iIndex = 20) Then
dGetLookupTableMultiplier = 37.6321
ElseIf (iIndex = 21) Then
dGetLookupTableMultiplier = 24.8933
ElseIf (iIndex = 22) Then
dGetLookupTableMultiplier = 39.793
ElseIf (iIndex = 23) Then
dGetLookupTableMultiplier = 42.7322
ElseIf (iIndex = 24) Then
dGetLookupTableMultiplier = 22.1792
ElseIf (iIndex = 25) Then
dGetLookupTableMultiplier = 67.1183
ElseIf (iIndex = 26) Then
dGetLookupTableMultiplier = 72.5404
ElseIf (iIndex = 27) Then
dGetLookupTableMultiplier = 11.6233
ElseIf (iIndex = 28) Then
dGetLookupTableMultiplier = 45.1371
ElseIf (iIndex = 29) Then
dGetLookupTableMultiplier = 69.5235
ElseIf (iIndex = 30) Then
dGetLookupTableMultiplier = 18.4632
ElseIf (iIndex = 31) Then
dGetLookupTableMultiplier = 42.5232
ElseIf (iIndex = 32) Then
dGetLookupTableMultiplier = 93.3048
ElseIf (iIndex = 33) Then
dGetLookupTableMultiplier = 70.0908
ElseIf (iIndex = 34) Then
dGetLookupTableMultiplier = 35.1504
ElseIf (iIndex = 35) Then
dGetLookupTableMultiplier = 81.4528
ElseIf (iIndex = 36) Then
dGetLookupTableMultiplier = 79.3581
ElseIf (iIndex = 37) Then
dGetLookupTableMultiplier = 50.4509
ElseIf (iIndex = 38) Then
dGetLookupTableMultiplier = 70.089
ElseIf (iIndex = 39) Then
dGetLookupTableMultiplier = 88.6324
ElseIf (iIndex = 40) Then
dGetLookupTableMultiplier = 82.8465
ElseIf (iIndex = 41) Then
dGetLookupTableMultiplier = 25.3234
ElseIf (iIndex = 42) Then
dGetLookupTableMultiplier = 19.4906
ElseIf (iIndex = 43) Then
dGetLookupTableMultiplier = 14.9922
ElseIf (iIndex = 44) Then
dGetLookupTableMultiplier = 22.5104
ElseIf (iIndex = 45) Then
dGetLookupTableMultiplier = 87.2123
ElseIf (iIndex = 46) Then
dGetLookupTableMultiplier = 89.0909
ElseIf (iIndex = 47) Then
dGetLookupTableMultiplier = 58.3422
ElseIf (iIndex = 48) Then
dGetLookupTableMultiplier = 76.343
ElseIf (iIndex = 49) Then
dGetLookupTableMultiplier = 78.1058
ElseIf (iIndex = 50) Then
dGetLookupTableMultiplier = 64.3242
ElseIf (iIndex = 51) Then
dGetLookupTableMultiplier = 53.1935
ElseIf (iIndex = 52) Then
dGetLookupTableMultiplier = 91.1288
ElseIf (iIndex = 53) Then
dGetLookupTableMultiplier = 53.2123
ElseIf (iIndex = 54) Then
dGetLookupTableMultiplier = 79.2525
ElseIf (iIndex = 55) Then
dGetLookupTableMultiplier = 52.3583
ElseIf (iIndex = 56) Then
dGetLookupTableMultiplier = 61.973
ElseIf (iIndex = 57) Then
dGetLookupTableMultiplier = 38.1104
ElseIf (iIndex = 58) Then
dGetLookupTableMultiplier = 75.2178
ElseIf (iIndex = 59) Then
dGetLookupTableMultiplier = 68.1285
ElseIf (iIndex = 60) Then
dGetLookupTableMultiplier = 69.4567
ElseIf (iIndex = 61) Then
dGetLookupTableMultiplier = 26.7385
ElseIf (iIndex = 62) Then
dGetLookupTableMultiplier = 11.9872
ElseIf (iIndex = 63) Then
dGetLookupTableMultiplier = 54.0824
ElseIf (iIndex = 64) Then
dGetLookupTableMultiplier = 31.3534
ElseIf (iIndex = 65) Then
dGetLookupTableMultiplier = 51.7813
ElseIf (iIndex = 66) Then
dGetLookupTableMultiplier = 17.8821
ElseIf (iIndex = 67) Then
dGetLookupTableMultiplier = 89.3412
ElseIf (iIndex = 68) Then
dGetLookupTableMultiplier = 91.1731
ElseIf (iIndex = 69) Then
dGetLookupTableMultiplier = 13.197
ElseIf (iIndex = 70) Then
dGetLookupTableMultiplier = 83.6453
ElseIf (iIndex = 71) Then
dGetLookupTableMultiplier = 62.919
ElseIf (iIndex = 72) Then
dGetLookupTableMultiplier = 21.9327
ElseIf (iIndex = 73) Then
dGetLookupTableMultiplier = 44.1937
ElseIf (iIndex = 74) Then
dGetLookupTableMultiplier = 82.783
ElseIf (iIndex = 75) Then
dGetLookupTableMultiplier = 99.1105
ElseIf (iIndex = 76) Then
dGetLookupTableMultiplier = 65.3451
ElseIf (iIndex = 77) Then
dGetLookupTableMultiplier = 99.873
ElseIf (iIndex = 78) Then
dGetLookupTableMultiplier = 81.8615
ElseIf (iIndex = 79) Then
dGetLookupTableMultiplier = 19.9912
ElseIf (iIndex = 80) Then
dGetLookupTableMultiplier = 11.7319
ElseIf (iIndex = 81) Then
dGetLookupTableMultiplier = 27.7633
ElseIf (iIndex = 82) Then
dGetLookupTableMultiplier = 40.243
ElseIf (iIndex = 83) Then
dGetLookupTableMultiplier = 70.1986
ElseIf (iIndex = 84) Then
dGetLookupTableMultiplier = 63.9983
ElseIf (iIndex = 85) Then
dGetLookupTableMultiplier = 92.9831
ElseIf (iIndex = 86) Then
dGetLookupTableMultiplier = 50.6372
ElseIf (iIndex = 87) Then
dGetLookupTableMultiplier = 62.809
ElseIf (iIndex = 88) Then
dGetLookupTableMultiplier = 31.515
ElseIf (iIndex = 89) Then
dGetLookupTableMultiplier = 28.8171
ElseIf (iIndex = 90) Then
dGetLookupTableMultiplier = 22.6627
ElseIf (iIndex = 91) Then
dGetLookupTableMultiplier = 72.0876
ElseIf (iIndex = 92) Then
dGetLookupTableMultiplier = 84.9943
ElseIf (iIndex = 93) Then
dGetLookupTableMultiplier = 43.2086
ElseIf (iIndex = 94) Then
dGetLookupTableMultiplier = 69.8423
ElseIf (iIndex = 95) Then
dGetLookupTableMultiplier = 98.7742
ElseIf (iIndex = 96) Then
dGetLookupTableMultiplier = 80.8234
ElseIf (iIndex = 97) Then
dGetLookupTableMultiplier = 92.6302
ElseIf (iIndex = 98) Then
dGetLookupTableMultiplier = 62.538
ElseIf (iIndex = 99) Then
dGetLookupTableMultiplier = 14.3301
Else
dGetLookupTableMultiplier = 0
End If

End Function


' The routine that goes through the worksheet and decodes the numeric cells
Sub RH2LogDecodeRoutine()

' Text variables
Dim szThisCellString As String
Dim sziLookupTableIndexString As String
Dim szValueString As String
Dim szFileName As String

' Boolean variables
Dim bThisCellPositive As Boolean

' Numeric variables
Dim iLookupTableIndex As Integer
Dim dEncodedValue As Double
Dim dLookupMultiplier As Double
Dim dDecodedValue As Double
Dim iFirstColumnToDecode As Integer

' Set the file name
szFileName = ActiveWorkbook.Name

' If this is the measurements file
If Mid(szFileName, 1, 1) = "m" Then

' Start at the third column
iFirstColumnToDecode = 3

' Or, if this is the calibration file
ElseIf Mid(szFileName, 1, 1) = "c" Then

' Start at the third column
iFirstColumnToDecode = 3

' Or, if this is the eCal autospin file
ElseIf Mid(szFileName, 1, 1) = "e" Then

' Start at the third column
iFirstColumnToDecode = 3

' Or, if we don't recognize the file
Else

' Start at the first column
iFirstColumnToDecode = 1

End If


' For every used cell in the active worksheet
For Each Cell In ActiveSheet.UsedRange.Cells

' If this is a column we want to decode
If Cell.Column > (iFirstColumnToDecode - 1) Then

' Get the text in this cell
szThisCellString = Cell.Text

' If the first character is a dash
If Mid(szThisCellString, 1, 1) = "-" Then

' This cell is negative
bThisCellPositive = False

' Or, if the first character is not a dash
Else

' This cell is positive
bThisCellPositive = True

End If

' If the value in this cell is negative
If bThisCellPositive = False Then

' The iIndex into the lookup table is the second two characters in the cell
sziLookupTableIndexString = Mid(szThisCellString, 2, 2)

' The value is everything else in the cell besides the iIndex into the lookup table
szValueString = Mid(szThisCellString, 4, Len(szThisCellString) - 3)

' Or, if the value in this cell is positive
Else

' The iIndex into the lookup table is the first two characters
sziLookupTableIndexString = Mid(szThisCellString, 1, 2)

' The value is everything else in the cell besides the iIndex into the lookup table
szValueString = Mid(szThisCellString, 3, Len(szThisCellString) - 2)

End If

' Get the lookup table iIndex as an integer
iLookupTableIndex = CInt(sziLookupTableIndexString)

' Get the lookup multiplier for this lookup table iIndex
dLookupMultiplier = dGetLookupTableMultiplier(iLookupTableIndex)

' Get the value to decode as a double
dEncodedValue = Val(szValueString)

' If the lookup multiplier is zero
If dLookupMultiplier = 0 Then

' This is an error, set the decoded value to zero
dDecodedValue = 0

' Or, if the lookup multiplier is non-zero
Else

' Get the decoded value
dDecodedValue = dEncodedValue / dLookupMultiplier

End If

' If this cell is negative
If bThisCellPositive = False Then

' Make the decoded value negative
dDecodedValue = dDecodedValue * -1

End If

' At this point, we have the decoded value, dDecodedValue
' Next, just replace the cell with this decoded value
Cell.Value = dDecodedValue

End If

Next

End Sub
 
Old 06-20-2016, 12:12 PM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 22,277

Rep: Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542Reputation: 4542
Not a Libreoffice basic expert by any means but a first glance I don't see anything that can not be converted.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help and guidance bash scripting Linux hatesme Linux - Newbie 7 07-30-2014 07:53 AM
Guidance Requested: Cutting and Pasting MathType mlindeburg Programming 0 07-12-2014 03:35 PM
[SOLVED] virtual machine on Slackware - guidance requested linuxbird Linux - Virtualization and Cloud 7 06-03-2012 12:31 PM
PAM, depreciated-modules guidance requested (not x-posted) MarkFilipak Linux - Newbie 10 10-06-2009 03:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration