Here is a new decompressor + auto-indentor + autospacer.
You can choose the size of indentation:
-1 Tab
0 No indentation
1+ Number of spaces for an indent
example:
before
input "Enter a TRICKY sum here: ",sum$ : answer# = equation(sum$+")") : print "Answer: ",answer# : wait key : end
function equation(equat$) : for d = 1 to len(equat$) : char$ = mid$(equat$,d) : if char$ = "+" : tot# = dosum(tot#,equat$,d,sumtype) : equat$ = right$(equat$,len(equat$)-d) : d = 0 : sumtype = 1 : endif : if char$ = "-" : tot# = dosum(tot#,equat$,d,sumtype) : equat$ = right$(equat$,len(equat$)-d) : d = 0 : sumtype = 2 : endif : if char$ = "*" : tot# = dosum(tot#,equat$,d,sumtype) : equat$ = right$(equat$,len(equat$)-d) : d = 0 : sumtype = 3 : endif : if char$ = "/" : tot# = dosum(tot#,equat$,d,sumtype) : equat$ = right$(equat$,len(equat$)-d) : d = 0
sumtype = 4 : endif : if char$ = "^" : tot# = dosum(tot#,equat$,d,sumtype) : equat$ = right$(equat$,len(equat$)-d) : d = 0 : sumtype = 5 : endif : if char$ = "(" : equat$ = right$(equat$,len(equat$)-d) : if sumtype = 0 : tot# = equation(equat$) : else : if sumtype = 1 : tot# = tot#+equation(equat$) : else : if sumtype = 2 : tot# = tot#-equation(equat$) : else : if sumtype = 3 : tot# = tot#*equation(equat$) : else : if sumtype = 4 : tot# = tot#/equation(equat$) : else
tot# = tot#^equation(equat$) : endif : endif : endif : endif : endif : sumtype = 0 : count = 1 : while count <> 0 : dec d : nchar$ = left$(equat$,1) : equat$ = right$(equat$,len(equat$)-1) : if nchar$ = "(" : inc count : endif : if nchar$ = ")" : dec count : endif : endwhile : endif : if char$ = ")" : tot# = dosum(tot#,equat$,d,sumtype) : equat$ = right$(equat$,len(equat$)-d) : sumtype = 0 : d = 0
exitfunction tot# : endif : next d
endfunction tot# : function dosum(tot#,equat$,d,sumtype) : if sumtype = 0 : tot# = tot#+val(left$(equat$,d-1)) : else : if sumtype = 1 : tot# = tot#+val(left$(equat$,d-1)) : else : if sumtype = 2 : tot# = tot#-val(left$(equat$,d-1)) : else : if sumtype = 3 : tot# = tot#*val(left$(equat$,d-1)) : else : if sumtype = 4 : tot# = tot#/val(left$(equat$,d-1)) : else : tot# = tot#^val(left$(equat$,d-1)) : endif : endif : endif : endif : endif
endfunction tot#
after (with a value of 4)
input "Enter a TRICKY sum here: ",sum$
answer# = equation(sum$+")")
print "Answer: ",answer#
wait key
end
function equation(equat$)
for d = 1 to len(equat$)
char$ = mid$(equat$,d)
if char$ = "+"
tot# = dosum(tot#,equat$,d,sumtype)
equat$ = right$(equat$,len(equat$)-d)
d = 0
sumtype = 1
endif
if char$ = "-"
tot# = dosum(tot#,equat$,d,sumtype)
equat$ = right$(equat$,len(equat$)-d)
d = 0
sumtype = 2
endif
if char$ = "*"
tot# = dosum(tot#,equat$,d,sumtype)
equat$ = right$(equat$,len(equat$)-d)
d = 0
sumtype = 3
endif
if char$ = "/"
tot# = dosum(tot#,equat$,d,sumtype)
equat$ = right$(equat$,len(equat$)-d)
d = 0
sumtype = 4
endif
if char$ = "^"
tot# = dosum(tot#,equat$,d,sumtype)
equat$ = right$(equat$,len(equat$)-d)
d = 0
sumtype = 5
endif
if char$ = "("
equat$ = right$(equat$,len(equat$)-d)
if sumtype = 0
tot# = equation(equat$)
else
if sumtype = 1
tot# = tot#+equation(equat$)
else
if sumtype = 2
tot# = tot#-equation(equat$)
else
if sumtype = 3
tot# = tot#*equation(equat$)
else
if sumtype = 4
tot# = tot#/equation(equat$)
else
tot# = tot#^equation(equat$)
endif
endif
endif
endif
endif
sumtype = 0
count = 1
while count <> 0
dec d
nchar$ = left$(equat$,1)
equat$ = right$(equat$,len(equat$)-1)
if nchar$ = "("
inc count
endif
if nchar$ = ")"
dec count
endif
endwhile
endif
if char$ = ")"
tot# = dosum(tot#,equat$,d,sumtype)
equat$ = right$(equat$,len(equat$)-d)
sumtype = 0
d = 0
exitfunction tot#
endif
next d
endfunction tot#
function dosum(tot#,equat$,d,sumtype)
if sumtype = 0
tot# = tot#+val(left$(equat$,d-1))
else
if sumtype = 1
tot# = tot#+val(left$(equat$,d-1))
else
if sumtype = 2
tot# = tot#-val(left$(equat$,d-1))
else
if sumtype = 3
tot# = tot#*val(left$(equat$,d-1))
else
if sumtype = 4
tot# = tot#/val(left$(equat$,d-1))
else
tot# = tot#^val(left$(equat$,d-1))
endif
endif
endif
endif
endif
endfunction tot#
Just drag and drop the .dba file onto the exe. The original will only be opened for reading.
If you find any bugs, then plz tell me. I have only tested it on the original compressor, and the advanced compressor.
Download (370kb .zip) attached