Joe Caverly
08-04-2025, 20:56
Not many people realize that you can use .NET Framework dlls with compilers such as PowerBasic.
I have translated a PowerBasic program,
which I wrote back in 2014,
to work with thinBasic.
When I run the following code,
Hebrew.tbasicc,
using thinbasicc.exe,
it returns
Nissan 10, 5785
which is the same as
April 8, 2025.
'---Load Console Module
Uses "Console"
dim Hebrew as IDispatch
dim TheYear as String
Dim TheMonth as string
Dim TheDay as string
dim LeapYear as string
Dim HebrewDate as string
Hebrew = CreateObject("System.Globalization.HebrewCalendar")
TheYear = Str$(Hebrew.GetYear(Date$(0)))
If Hebrew.IsLeapYear(TheYear) Then
LeapYear = "Y"
else
LeapYear = "N"
end if
TheDay = Str$(Hebrew.GetDayOfMonth(Date$(0)))
TheDay = TrimFull$(TheDay)
TheMonth = Hebrew.GetMonth(Date$(0))
TheMonth = TrimFull$(TheMonth)
Select Case Val(TheMonth)
Case 1
TheMonth = "Tishrei"
Case 2
TheMonth = "Cheshvan"
Case 3
TheMonth = "Kislev"
Case 4
TheMonth = "Tevet"
Case 5
TheMonth = "Shevat"
Case 6
If LeapYear = "Y" Then
TheMonth = "Adar Alef"
Else
TheMonth = "Adar"
End If
Case 7
If LeapYear ="Y" Then
TheMonth = "Adar Beit"
Else
TheMonth = "Nissan"
End If
Case 8
If LeapYear = "Y" Then
TheMonth = "Nissan"
Else
TheMonth = "Iyar"
End If
Case 9
If LeapYear "Y" Then
TheMonth = "Iyar"
Else
TheMonth = "Sivan"
End If
Case 10
If LeapYear "Y" Then
TheMonth = "Sivan"
Else
TheMonth = "Tamuz"
End If
Case 11
If LeapYear = "Y" Then
TheMonth = "Tamuz"
Else
TheMonth = "Av"
End If
Case 12
If LeapYear = "Y" Then
TheMonth = "Av"
Else
TheMonth = "Elul"
End If
Case 13
TheMonth = "Elul"
'
' This should never be executed
'
Case Else
TheMonth = CStr(Hebrew.GetMonth(Date$(0)))
End Select
TheMonth = TrimFull$(TheMonth)
HebrewDate = TheMonth + " " + TheDay + "," + TheYear
Hebrew = Nothing
PrintL HebrewDate
PrintL
You can use any .NET language,
such as C# or VB.NET,
to create your own .NET Framework dll for use with thinBasic.
VB.NET (or C#) might also work with thinBasic via External Compiler Interop,
just like FreeBASIC or PowerBASIC.
Joe
I have translated a PowerBasic program,
which I wrote back in 2014,
to work with thinBasic.
When I run the following code,
Hebrew.tbasicc,
using thinbasicc.exe,
it returns
Nissan 10, 5785
which is the same as
April 8, 2025.
'---Load Console Module
Uses "Console"
dim Hebrew as IDispatch
dim TheYear as String
Dim TheMonth as string
Dim TheDay as string
dim LeapYear as string
Dim HebrewDate as string
Hebrew = CreateObject("System.Globalization.HebrewCalendar")
TheYear = Str$(Hebrew.GetYear(Date$(0)))
If Hebrew.IsLeapYear(TheYear) Then
LeapYear = "Y"
else
LeapYear = "N"
end if
TheDay = Str$(Hebrew.GetDayOfMonth(Date$(0)))
TheDay = TrimFull$(TheDay)
TheMonth = Hebrew.GetMonth(Date$(0))
TheMonth = TrimFull$(TheMonth)
Select Case Val(TheMonth)
Case 1
TheMonth = "Tishrei"
Case 2
TheMonth = "Cheshvan"
Case 3
TheMonth = "Kislev"
Case 4
TheMonth = "Tevet"
Case 5
TheMonth = "Shevat"
Case 6
If LeapYear = "Y" Then
TheMonth = "Adar Alef"
Else
TheMonth = "Adar"
End If
Case 7
If LeapYear ="Y" Then
TheMonth = "Adar Beit"
Else
TheMonth = "Nissan"
End If
Case 8
If LeapYear = "Y" Then
TheMonth = "Nissan"
Else
TheMonth = "Iyar"
End If
Case 9
If LeapYear "Y" Then
TheMonth = "Iyar"
Else
TheMonth = "Sivan"
End If
Case 10
If LeapYear "Y" Then
TheMonth = "Sivan"
Else
TheMonth = "Tamuz"
End If
Case 11
If LeapYear = "Y" Then
TheMonth = "Tamuz"
Else
TheMonth = "Av"
End If
Case 12
If LeapYear = "Y" Then
TheMonth = "Av"
Else
TheMonth = "Elul"
End If
Case 13
TheMonth = "Elul"
'
' This should never be executed
'
Case Else
TheMonth = CStr(Hebrew.GetMonth(Date$(0)))
End Select
TheMonth = TrimFull$(TheMonth)
HebrewDate = TheMonth + " " + TheDay + "," + TheYear
Hebrew = Nothing
PrintL HebrewDate
PrintL
You can use any .NET language,
such as C# or VB.NET,
to create your own .NET Framework dll for use with thinBasic.
VB.NET (or C#) might also work with thinBasic via External Compiler Interop,
just like FreeBASIC or PowerBASIC.
Joe