bc finally freaking worked

This commit is contained in:
EverythingWindows 2022-11-05 22:24:30 +07:00
parent 06623f4cb1
commit ed6f6ee29d
9 changed files with 213 additions and 105 deletions

View file

@ -12,6 +12,7 @@
Strings.AvailableFeature(6) = "2"
Strings.AvailableFeature(7) = "2"
Strings.AvailableFeature(8) = "2"
Strings.AvailableFeature(9) = "2"
End Sub
Public Sub FreeRoamMode()
@ -26,6 +27,7 @@
Strings.AvailableFeature(6) = "3"
Strings.AvailableFeature(7) = "1"
Strings.AvailableFeature(8) = "1"
Strings.AvailableFeature(9) = "1"
End Sub
Public Sub GodMode()
@ -40,5 +42,6 @@
Strings.AvailableFeature(6) = "2"
Strings.AvailableFeature(7) = "2"
Strings.AvailableFeature(8) = "2"
Strings.AvailableFeature(9) = "2"
End Sub
End Module

View file

@ -34,6 +34,9 @@
End If
End If
End If
If Strings.AvailableFeature(9) = "0" Then
Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "(bc | 10 CP) Basic Calculator"
End If
End If
End Sub
@ -106,6 +109,13 @@
Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & ManHeader(0) & Environment.NewLine & Environment.NewLine & "ShiftOS port of Neofetch, A command-line system information tool" & Environment.NewLine & Environment.NewLine & ManHeader(1)
Terminal.BadCommand = False
End If
Case "bc"
If Strings.AvailableFeature(9) = "0" Then
ManHeader(0) = "Basic Calculator"
ManHeader(1) = "75 CP"
Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & ManHeader(0) & Environment.NewLine & Environment.NewLine & "Basic Calculator for simple calculation" & Environment.NewLine & Environment.NewLine & ManHeader(1)
Terminal.BadCommand = False
End If
Case Else
Terminal.BadCommand = False
Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "Shiftorium: Bad command or not available"
@ -142,6 +152,9 @@
Case "shiftfetch"
Shiftorium_InstallFeatures(True, "shiftfetch", 8, 75)
Terminal.BadCommand = False
Case "bc"
Shiftorium_InstallFeatures(True, "bc", 9, 75)
Terminal.BadCommand = False
Case Else
Terminal.BadCommand = False
Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "Shiftorium: Bad command or not available"
@ -162,6 +175,7 @@
Strings.AvailableFeature(1) = "1"
Strings.AvailableFeature(2) = "0"
Strings.AvailableFeature(5) = "0"
Strings.AvailableFeature(9) = "0"
success = True
Case "print"
Strings.AvailableFeature(2) = "1"
@ -190,6 +204,8 @@
success = True
Case "shiftfetch"
Strings.AvailableFeature(8) = "1"
Case "bc"
Strings.AvailableFeature(9) = "1"
success = True
End Select
If success = False Then

View file

@ -3,7 +3,7 @@
Public Shared ComputerInfo(4) As String
Public Shared IsFree As Boolean
Public Shared OnceInfo(0) As String
Public Shared AvailableFeature(8) As String
Public Shared AvailableFeature(9) As String
Public Shared CLIInterpreter As String
Public Shared SaveFile As String
@ -46,11 +46,13 @@
'6 = Time by Minutes [Showing time in minutes form since midnight] (0.2.2) (default : 0)
'7 = Time by Hours [Showing time in hours form since midnight] (0.2.2) (default : 0)
'8 = Shiftfetch [ShiftOS port of Neofetch, A command-line system information tool] (0.2.3) (default : 0)
'9 = bc [Basic Calculator for ShiftOS] (0.2.3) (default : 0)
'
'Features bought hierarchy :
'ShiftOS Help Manual (MAN) (20 CP)
'Terminal Clear (CLEAR) (25 CP)
'>Terminal Print (PRINT) (30 CP)
'>Basic Calculator (BC) (75 CP)
'>>Terminal Display Driver (50 CP)
'>>>Terminal InfoBar (55 CP)
'>>>Shiftfetch (75 CP)

View file

@ -108,6 +108,13 @@ Public Class Terminal
Case ""
AdvancedCommand = False
BadCommand = False
Case "bc"
If Strings.AvailableFeature(9) = "1" Then
ChangeInterpreter = True
AppHost("bc")
AdvancedCommand = False
BadCommand = False
End If
Case "clear"
If Strings.AvailableFeature(1) = "1" Then
TextBox1.Text = Nothing
@ -170,11 +177,6 @@ Public Class Terminal
TextBox1.Text = TextBox1.Text & Environment.NewLine
AdvancedCommand = False
BadCommand = False
Case "pause"
ChangeInterpreter = True
AppHost("pause")
AdvancedCommand = False
BadCommand = False
Case "reboot"
TextBox1.Text = Nothing
AdvancedCommand = False
@ -267,6 +269,12 @@ Public Class Terminal
Dim TempUsage As String = "'" & mancommand & "' Usage: "
Select Case mancommand
'In process to convert every command from printing from code to printing from text file
Case "bc"
If Strings.AvailableFeature(9) = "1" Then
TempUsage = TempUsage & "bc"
TextBox1.Text = TextBox1.Text & TempUsage & Environment.NewLine & Environment.NewLine & My.Resources.man_bc & Environment.NewLine
BadCommand = False
End If
Case "clear"
If Strings.AvailableFeature(1) = "1" Then
TempUsage = TempUsage & "clear"
@ -358,89 +366,85 @@ Public Class Terminal
End Sub
Private Sub txtterm_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If CurrentInterpreter = "pause" Then
TerminateApp()
Else
If e.KeyCode = Keys.T AndAlso e.Control Then
Me.Hide()
e.SuppressKeyPress = True
End If
If e.KeyCode = Keys.T AndAlso e.Control Then
Me.Hide()
e.SuppressKeyPress = True
End If
Select Case e.KeyCode
Case Keys.ShiftKey
Select Case e.KeyCode
Case Keys.ShiftKey
TrackPos = TrackPos - 1
Case Keys.Alt
TrackPos = TrackPos - 1
Case Keys.CapsLock
TrackPos = TrackPos - 1
Case Keys.ControlKey
TrackPos = TrackPos - 1
Case Keys.LWin
TrackPos = TrackPos - 1
Case Keys.RWin
TrackPos = TrackPos - 1
Case Keys.Right
If TextBox1.SelectionStart = TextBox1.TextLength Then
TrackPos = TrackPos - 1
Case Keys.Alt
TrackPos = TrackPos - 1
Case Keys.CapsLock
TrackPos = TrackPos - 1
Case Keys.ControlKey
TrackPos = TrackPos - 1
Case Keys.LWin
TrackPos = TrackPos - 1
Case Keys.RWin
TrackPos = TrackPos - 1
Case Keys.Right
If TextBox1.SelectionStart = TextBox1.TextLength Then
TrackPos = TrackPos - 1
End If
Case Keys.Left
If TrackPos < 1 Then
e.SuppressKeyPress = True
TrackPos = TrackPos - 1
Else
TrackPos = TrackPos - 2
End If
Case Keys.Up
e.SuppressKeyPress = True
TrackPos = TrackPos - 1
Case Keys.Down
e.SuppressKeyPress = True
TrackPos = TrackPos - 1
End Select
If e.KeyCode = Keys.Enter Then
e.SuppressKeyPress = True
If TextBox1.ReadOnly = True Then
Else
ReadCommand()
If ChangeInterpreter = True Then
DoChildCommand()
PrintPrompt()
TextBox1.Select(TextBox1.Text.Length, 0)
Else
DoCommand()
PrintPrompt()
TextBox1.Select(TextBox1.Text.Length, 0)
End If
End If
'If command = "clear" Then
' PrintPrompt()
' TextBox1.Select(TextBox1.Text.Length, 0)
'Else
' PrintPrompt()
' TextBox1.Select(TextBox1.Text.Length, 0)
'End If
TrackPos = 0
Else
If e.KeyCode = Keys.Back Then
Else
TrackPos = TrackPos + 1
End If
End If
If e.KeyCode = Keys.Back Then
Case Keys.Left
If TrackPos < 1 Then
e.SuppressKeyPress = True
TrackPos = TrackPos - 1
Else
If TextBox1.SelectedText.Length < 1 Then
TrackPos = TrackPos - 1
Else
e.SuppressKeyPress = True
End If
TrackPos = TrackPos - 2
End If
Case Keys.Up
e.SuppressKeyPress = True
TrackPos = TrackPos - 1
Case Keys.Down
e.SuppressKeyPress = True
TrackPos = TrackPos - 1
End Select
If e.KeyCode = Keys.Enter Then
e.SuppressKeyPress = True
If TextBox1.ReadOnly = True Then
Else
ReadCommand()
If ChangeInterpreter = True Then
DoChildCommand()
PrintPrompt()
TextBox1.Select(TextBox1.Text.Length, 0)
Else
DoCommand()
PrintPrompt()
TextBox1.Select(TextBox1.Text.Length, 0)
End If
End If
'If command = "clear" Then
' PrintPrompt()
' TextBox1.Select(TextBox1.Text.Length, 0)
'Else
' PrintPrompt()
' TextBox1.Select(TextBox1.Text.Length, 0)
'End If
TrackPos = 0
Else
If e.KeyCode = Keys.Back Then
Else
TrackPos = TrackPos + 1
End If
End If
If e.KeyCode = Keys.Back Then
If TrackPos < 1 Then
e.SuppressKeyPress = True
Else
If TextBox1.SelectedText.Length < 1 Then
TrackPos = TrackPos - 1
Else
e.SuppressKeyPress = True
End If
End If
End If

View file

@ -2,6 +2,15 @@
Public ShouldChange As Boolean = False
'This is for GTN's RAM
Public TheNumber As Integer = 0
Public FreezeText As String
Public BC_ReadNumbers As Integer
Public BC_Numbers1 As String
Public BC_Numbers2 As String
Public BC_ThriceMoreValue As Integer
Public BC_ThriceMoreCount As Integer
Public BC_CurrentNumber As String
Public BC_Result As Integer
Public BC_Operation2 As String
Public Sub ChangeCP(Addition As Boolean, NeededCP As Integer)
Dim TempCP As Integer = Convert.ToInt32(Strings.ComputerInfo(2))
@ -15,17 +24,24 @@
Public Sub AppHost(App As Object)
Select Case App
Case "bc"
Terminal.DefaultPrompt = "> "
Terminal.TextBox1.Text = "bc (Basic Calcultator)" & Environment.NewLine & "Copyright, Free Software Foundation." & Environment.NewLine & "ShiftOS port by DevX." & Environment.NewLine & "This is free software with ABSOLUTELY NO WARRANTY." & Environment.NewLine
Terminal.CurrentInterpreter = "bc"
ShouldChange = True
Case "guess" 'Guess the Number
Terminal.DefaultPrompt = "Your answer: "
Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "Guess the Number" & Environment.NewLine & "Guess the correct number between 1 and 50 and you'll get anything between 1 to 5 Codepoints" & Environment.NewLine & "Type 'exit' to terminate this game"
Terminal.CurrentInterpreter = "guess"
GTN_GenerateNumber()
ShouldChange = True
Case "pause" 'Pause function
Terminal.DefaultPrompt = "Press any key to continue..."
Terminal.CurrentInterpreter = "pause"
Terminal.TextBox1.ReadOnly = True
ShouldChange = True
'Revisit Later
'Case "pause" 'Pause function
' Terminal.TextBox1.ReadOnly = True
' Terminal.DefaultPrompt = "Press any key to continue..."
' Terminal.CurrentInterpreter = "pause"
' FreezeText = Terminal.TextBox1.Text
' ShouldChange = True
Case "shiftoriumfx" 'ShiftoriumFX : Advanced Shiftorium
Terminal.DefaultPrompt = "Navigate> "
Terminal.CurrentInterpreter = "shiftoriumfx"
@ -42,9 +58,7 @@
Public Sub TerminateApp()
Terminal.ChangeInterpreter = False
Terminal.CurrentInterpreter = "terminal"
Terminal.PrintPrompt()
Terminal.AssignPrompt()
Terminal.TextBox1.ReadOnly = False
End Sub
Public Sub DoChildCommand()
@ -60,11 +74,9 @@
Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "Invalid value!"
End Try
End Select
Case "pause"
TerminateApp()
Case "shiftoriumfx"
Select Case Terminal.command
'Case ""
Case ""
Case "exit"
TerminateApp()
@ -72,6 +84,75 @@
ShiftoriumFX_DisplayPackages()
Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & Environment.NewLine & "Type any package you want to investigate" & Environment.NewLine & "Invalid package or bad command"
End Select
Case "bc"
Select Case Terminal.command
Case "jim"
Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "69, the funni number" & Environment.NewLine & "gotcha!"
Case "ojas"
Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "dis calculator is very gud" & Environment.NewLine & "it counts from another universe"
Case "exit"
TerminateApp()
Case Else
BC_ReadNumbers = 0
BC_ThriceMoreValue = 1
BC_Numbers1 = Nothing
BC_Numbers2 = Nothing
BC_Operation2 = Nothing
BC_CurrentNumber = Nothing
BC_Result = Nothing
Dim GetText As String
Try
Do
GetText = Terminal.command.Chars(BC_ReadNumbers)
Select Case GetText
Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
BC_CurrentNumber = BC_CurrentNumber & GetText
Case "+", "-", "*", "/"
Dim BC_Numbers3 As Integer
Select Case BC_ThriceMoreValue
Case 1
BC_Numbers1 = BC_CurrentNumber
BC_CurrentNumber = Nothing
BC_Operation2 = GetText
BC_ThriceMoreValue = BC_ThriceMoreValue + 1
Case >= 2
BC_Numbers2 = BC_CurrentNumber
BC_Counting(BC_Numbers1, BC_Numbers2, BC_Operation2)
BC_Numbers3 = BC_Result
BC_Numbers1 = BC_Numbers3
BC_Numbers2 = Nothing
BC_CurrentNumber = Nothing
BC_ThriceMoreValue = BC_ThriceMoreValue + 1
End Select
BC_Operation2 = GetText
Case "."
Terminal.TextBox1.Text = Terminal.TextBox1.Text & "Decimals aren't supported yet!"
Case Else
'BC_Counting(BC_Numbers1, BC_Numbers2, BC_Operation2)
End Select
BC_ReadNumbers = BC_ReadNumbers + 1
Loop
Catch ex As Exception
BC_Numbers2 = BC_CurrentNumber
BC_CurrentNumber = Nothing
End Try
BC_Counting(BC_Numbers1, BC_Numbers2, BC_Operation2)
BC_ThriceMoreValue = Nothing
Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & BC_Result
End Select
End Select
End Sub
Public Sub BC_Counting(FirstNum As Integer, SecondNum As Integer, Operation As String)
Select Case Operation
Case "+"
BC_Result = FirstNum + SecondNum
Case "-"
BC_Result = FirstNum - SecondNum
Case "*"
BC_Result = FirstNum * SecondNum
Case "/"
BC_Result = FirstNum / SecondNum
End Select
End Sub

View file

@ -60,15 +60,6 @@ Namespace My.Resources
End Set
End Property
'''<summary>
''' Looks up a localized string similar to .
'''</summary>
Friend ReadOnly Property BuildString() As String
Get
Return ResourceManager.GetString("BuildString", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to 0.2.2.
'''</summary>
@ -78,6 +69,15 @@ Namespace My.Resources
End Get
End Property
'''<summary>
''' Looks up a localized string similar to A basic command-line tool for simple calculation..
'''</summary>
Friend ReadOnly Property man_bc() As String
Get
Return ResourceManager.GetString("man_bc", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Clears all contents of the terminal.
'''</summary>

View file

@ -117,13 +117,13 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="BuildString" xml:space="preserve">
<value />
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="CurrentVersion" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\CurrentVersion.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="man_bc" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\man manuals\bc.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="man_clear" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\man manuals\clear.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>

View file

@ -0,0 +1 @@
A basic command-line tool for simple calculation.

View file

@ -196,6 +196,7 @@
</ItemGroup>
<ItemGroup>
<None Include="Resources\CurrentVersion.txt" />
<Content Include="Resources\man Manuals\bc.txt" />
<Content Include="Resources\man Manuals\clear.txt" />
<Content Include="Resources\man Manuals\codepoint.txt" />
<Content Include="Resources\man Manuals\guess.txt" />