Today is Halloween, a day filled with chills, fear, and Jamie Lee Curtis. What’s interesting about horror movies is that the roots of fear often lie in the past. Michael Myers was confined to a mental hospital for decades before his infamous Halloween rampage. midsummer It represents centuries of tradition. savage It is rooted in sins committed a generation ago. Freddy Krueger was a manifestation of the sins of the protagonist’s parents. No, even Dracula is a threat that has been lurking centuries before our story begins.
To celebrate this, let’s take a look at some code below. david. As with many classic horrors, the seeds of this sin were planted years before David arrived.
In 1991, Microsoft released the first version of Visual Basic. This language evolved until his release of VB6 in 1998. Mainstream support ended in 2005 and extended support ended in 2008, but like any real horror, VB6 isn’t really dead yet. Development tools will continue to run on all 32-bit versions of Windows.
A long time ago, Davide’s predecessor decided to implement an enterprise resource planning system in VB6. It grew and evolved and became something that could no longer be controlled. That resulted in him 2.5 million lines of code. It was incorporated into the company, taking over every core business function and quickly becoming essential.
We can compare it to so many horror monsters – shapeshifters that gradually replace parts of the company with themselves.bacteria from the last of us, will take over the brains of the company.Let’s compare it blobThis may also be the most accurate description of the coding techniques used in building it.
Here is the code that evaluates the formula entered by the user.
Option Explicit
Dim AA$(26)
Dim VV#(26)
Dim B$(26)
Dim OP$(26)
Dim RANGO(26) As Integer
Dim P$(27)
Dim OPN#(2), COPN$(26)
Dim CV%
Public scrCtl As MSScriptControl.ScriptControl
Dim bCreated As Boolean
Dim strUltCodart As String
Dim strUltFormula As String
Dim nEsito As Integer
Public Function FormulaControlla(strFormula As String) As Boolean
17000 Rem --- Input = FORMULA$, Output = AA$(__),CV%,OK%=1 se FORMULA$ non buona
Dim Formula$, f$, CP%, CN%, FLAGP%, c$, OK%, LX%, s%, A$, B$, AB%, BB%, BRANGO%, CRANGO$
FormulaControlla = True
Exit Function
Formula$ = strFormula
17010 f$ = Formula$ + Chr$(0): CP% = 0: CN% = 0: CV% = 0: FLAGP% = 0: c$ = "": OK% = 0
17020 LX% = Len(Formula$)
17030 For s% = 1 To LX%
17040 A$ = Mid$(f$, s%, 1): B$ = Mid$(f$, s% + 1, 1)
17050 AB% = Asc(A$): BB% = Asc(B$)
17060 If A$ >= "0" And A$ <= "9" Then If (B$ >= "a" And B$ <= "z") Or B$ = "(" Then OK% = 1: GoTo 17230 Else CN% = CN% + 1: GoTo 17230
17070 If A$ = "*" Or A$ = "/" Or A$ = "+" Or A$ = "-" Then If B$ = "*" Or B$ = "/" Or B$ = "+" Or B$ = "-" Or B$ = Chr$(0) Or B$ = ")" Then OK% = 1: GoTo 17230 Else GoTo 17130
17080 If A$ = "(" Then If B$ = ")" Or B$ = "*" Or B$ = "/" Or B$ = "+" Or B$ = Chr$(0) Then OK% = 1: GoTo 17230 Else CP% = CP% + 1: GoTo 17130
17090 If A$ = ")" Then If B$ = "(" Or (B$ >= "0" And B$ <= "9") Or (B$ >= "a" And B$ <= "z") Or B$ = "." Then OK% = 1: GoTo 17230 Else CP% = CP% - 1: GoTo 17130
17100 If A$ >= "a" And A$ <= "z" Then If (B$ >= "0" And B$ <= "9") Or (B$ >= "a" And B$ <= "z") Or B$ = "(" Or B$ = "." Then OK% = 1: GoTo 17230 Else GoTo 17130
17110 If A$ = "." Then If Not (B$ >= "0" And B$ <= "9") Then OK% = 1: GoTo 17230 Else CN% = CN% + 1: FLAGP% = FLAGP% + 1: GoTo 17230
17120 OK% = 1: GoTo 17230
17130
17140 If CN% = 0 Then GoTo 17180
17150 If FLAGP% > 1 Then OK% = 1: GoTo 17230
17160 CV% = CV% + 1: AA$(CV%) = Mid$(f$, s% - CN%, CN%)
17170 CN% = 0: FLAGP% = 0
17180 CV% = CV% + 1: AA$(CV%) = A$
17190 If A$ = "*" Or A$ = "/" Or A$ = "+" Or A$ = "-" Then GoTo 17200 Else GoTo 17230
17200 If A$ = "-" And c$ = "(" Or A$ = "-" And s% = 1 Then BRANGO% = 3 + 3 * CP%: CRANGO$ = Right$(" " + str$(BRANGO%), 2): AA$(CV%) = ">" + CRANGO$: GoTo 17230
17210 If A$ = "-" Or A$ = "+" Then BRANGO% = 1 + 3 * CP%: CRANGO$ = Right$(" " + str$(BRANGO%), 2): AA$(CV%) = AA$(CV%) + CRANGO$
17220 If A$ = "*" Or A$ = "/" Then BRANGO% = 2 + 3 * CP%: CRANGO$ = Right$(" " + str$(BRANGO%), 2): AA$(CV%) = AA$(CV%) + CRANGO$
17230
17240 If OK% = 1 Then s% = LX%
17250 c$ = A$
17260 Next s%
17270 If CN% = 0 Then GoTo 17310
17280 If FLAGP% > 1 Then OK% = 1: GoTo 17310
17290 CV% = CV% + 1: AA$(CV%) = Mid$(f$, s% - CN%, CN%)
17300 CN% = 0: FLAGP% = 0
17310 If CN% > 0 Or FLAGP% <> 0 Or CP% <> 0 Then OK% = 1
17320 If OK% = 1 Then FormulaControlla = False Else FormulaControlla = True
End Function
Public Sub FormulaGenPolacca()
18800 Rem --- ROUTINE che, data la NOTAZIONE INTERA
18810 Rem --- GENERA LA NOTAZIONE POLACCA
18820 Rem --- Input = AA$(__), CV%, Output = P$(__)
Dim i As Integer, j As Integer, K As Integer, CONTA As Integer, MAXI%, l As Integer
Dim NUOVA%, KK%, M As Integer
18830 i = 0: j = 1: l = 0: K = 1: CONTA = 0: MAXI% = CV%
18835 If NUOVA% = 1 Then NUOVA% = 0: For KK% = 1 To 26: VV#(KK%) = 0: Next KK%
18840 For KK% = 1 To 26: B$(KK%) = "": OP$(KK%) = "": RANGO(KK%) = 0: P$(KK%) = "": Next KK%: P$(26) = ""
18850 Rem
18860 If CONTA > 0 Then CONTA = CONTA + 1
18870 i = i + 1
18880 If AA$(i) = "(" Or AA$(i) = ")" Then If i = MAXI% Then l = l + 1: OP$(l) = "T": RANGO(l) = 0: GoTo 18910 Else GoTo 18870
18890 If AA$(i) >= "a" And AA$(i) <= "z" Or Asc(AA$(i)) = 46 Or Asc(AA$(i)) > 47 And Asc(AA$(i)) < 58 Then If i = MAXI% Then B$(j) = AA$(i): l = l + 1: OP$(l) = "T": RANGO(l) = 0: GoTo 18910 Else B$(j) = AA$(i): GoTo 18870
18900 l = l + 1: OP$(l) = Left$(AA$(i), 1): RANGO(l) = Val(Right$(AA$(i), 2))
18910 If B$(j) <> "" Then P$(K) = B$(j): K = K + 1: j = j + 1
18920 If l = 1 And i = MAXI% Then GoTo 19020
18930 If l = 1 Then GoTo 18850
18940 If RANGO(l) > RANGO(l - 1) Then CONTA = CONTA + 1: GoTo 18850
18950 If CONTA = 0 Then P$(K) = OP$(l - 1): K = K + 1: RANGO(l - 1) = 0: GoTo 19020
18960 For M = 1 To CONTA + 1
18970 If M = l Then M = CONTA + 1: GoTo 19010
18980 If RANGO(l - M) = 0 Then GoTo 19010
18990 If RANGO(l) > RANGO(l - M) Then GoTo 19010
19000 P$(K) = OP$(l - M): K = K + 1: RANGO(l - M) = 0
19010 Next M
19020 If OP$(l) = "T" Then P$(K) = OP$(l) Else GoTo 18850
19030
End Sub
Public Function FormulaValutaPolacca() As Double
19500 Rem --- ROUTINE che, data la NOTAZIONE POLACCA
19510 Rem --- CALCOLA il VALORE DELLA FORMULA
19515 Rem --- Input = P$(__), Output = RISULTATO#,ERRORE%=1 se Division by zero
Dim K As Integer, ERRORE%, OPR$, Q%, NO%, R As Integer, ABC$, RIS#, Risultato#, X$
19520 FormulaValutaPolacca = 0: K = 0: ERRORE% = 0
19530 K = K + 1
19540 If P$(K) >= "a" And P$(K) <= "z" Or Asc(P$(K)) = 46 Or Asc(P$(K)) > 47 And Asc(P$(K)) < 58 Then GoTo 19530
19550 OPR$ = P$(K): P$(K) = "": Q% = 1: While P$(K - Q%) = "": Q% = Q% + 1: Wend: COPN$(2) = P$(K - Q%): P$(K - Q%) = ""
19560 If OPR$ <> ">" And OPR$ <> "T" Then NO% = 1: Q% = 2: While P$(K - Q%) = "": Q% = Q% + 1: Wend: COPN$(1) = P$(K - Q%): P$(K - Q%) = "" Else NO% = 2
19570 Rem-----
19580 For R = 2 To NO% Step -1
19590 If Not (COPN$(R) >= "a" And COPN$(R) <= "z") Then OPN#(R) = Val(COPN$(R)): GoTo 19610
19600 ABC$ = COPN$(R): OPN#(R) = FormulaAssegna(ABC$)
19610 Next R
19620 Rem-----
19630 Rem-----
19640 If OPR$ = "T" Then RIS# = OPN#(2): GoTo 19710
19650 If OPR$ = ">" Then RIS# = -OPN#(2): GoTo 19700
19660 If OPR$ = "*" Or OPR$ = "x" Then RIS# = OPN#(1) * OPN#(2): GoTo 19700
19670 If OPR$ = ":" Or OPR$ = "/" Then If OPN#(2) <> 0 Then RIS# = OPN#(1) / OPN#(2): GoTo 19700 Else Risultato# = 0: ERRORE% = 1: GoTo 19730
19680 If OPR$ = "+" Then RIS# = OPN#(1) + OPN#(2): GoTo 19700
19690 If OPR$ = "-" Then RIS# = OPN#(1) - OPN#(2)
19700 Rem-------
19710 If OPR$ = "T" Then GoTo 19720 Else X$ = str$(RIS#): P$(K) = Right$(X$, Len(X$) - 1): GoTo 19530
19720 Risultato# = RIS#
19730 FormulaValutaPolacca = Risultato#:
19740 If ERRORE = 1 Then MsgBox "Attenzione: Divisione per 0 nella valutazione della formula.", vbCritical, bsTtlErr
End Function
Public Function FormulaAssegna(ABC$) As Double
19800 Rem --- assegna i valori alle variabili operatori -------
19801 Rem --- input ABC$ , globale vv#() output VV# -------
Dim NN%, BVV#
19810 NN% = Asc(ABC$) - 96
If NN% = 1 Or NN% = 2 Or NN% = 3 Or NN% = 11 Or NN% = 14 Then
BVV# = VV#(NN%): FormulaAssegna = BVV#: GoTo Fine
End If
19830 If VV#(NN%) <> 0 Then
BVV# = VV#(NN%): FormulaAssegna = BVV#: GoTo Fine
End If
19860 BVV# = CDbl(InputBox("Inserire il valore della variabile <" + ABC$ + "> =", "Richiesta valore parametro", "0"))
19880 VV#(NN%) = BVV#
19900 FormulaAssegna = BVV#
Fine:
End Function
Public Sub FormulaChiama(strFormula As String)
Dim bOk As Boolean
Dim Risultato#
30200 Rem --- CALCOLO QUANTITA
30205
30210 bOk = FormulaControlla(strFormula): If bOk = False Then Risultato# = 0 Else FormulaGenPolacca: Risultato# = FormulaValutaPolacca
End Sub
The only ray of hope is the first line – at least they used Option Explicit
This forces you to declare the variable (rather than simply creating it each time you use it). Everything else is horror. VB6 did it do not have Requires line number. This means that the responsible developer started using an older version of BASIC. Or even worse: This code was born in an older version of basic. Or, perhaps worse, the developers couldn’t imagine flow control without it. GoTo
because there is. many One of them.
This code was obviously originally written in Italian, but the fact that it is written in another (natural) language does not make it unintelligible to me. The code itself is cryptic and complicated, so want Worried that solving this puzzle would invite the Cenobites to tear me apart, I decided to decipher it.
Davide adds, “The tragic thing about this story is that it actually works out most of the time.”
This world holds real horrors, inescapable nightmares, and legacy code that needs to be maintained, waiting for vulnerable developers. Can a developer trapped by this monster ever hope to escape?
And finally, as a bonus story about the horrors of technology, I told a creepy campfire story about Thomas Midgley Jr. on stage this weekend. Sorry for the mobile video. The man who sold the world.
Continuously monitors server configuration changes and reports any configuration changes. Get started with Otter today!