Microsoft Small Basic

Program Listing: TCN337
binario[1]=2
TextWindow.WriteLine("from how many digits do you want to make the conversion bigger implies slower")
TextWindow.WriteLine("maximum12= which implies very slow")
TextWindow.WriteLine("from how many digits do you want to make the conversion")
z=TextWindow.ReadNumber()
power= Math.Power(2,z)

Convert:

'this is to make an index of ordered binary amounts
i=i+1
If i>power Then
Goto finish
EndIf
number = i

While number > 0
temp= Math.Remainder( number,2 )
If temp=0 Then
temp=2
EndIf
Stack.PushValue("Bin" temp )
If temp=0 Then
temp=2
EndIf
number = Math.Floor( number / 2 )
EndWhile

bin = 0

While Stack.GetCount("Bin") > 0
bin = Text.Append( bin Stack.PopValue("Bin") )
EndWhile

TextWindow.ForegroundColor = "Yellow"




bin=Text.GetSubTextToEnd (bin,2)

binario[i+1]=bin
TextWindow.WriteLine(binario[i])

Goto Convert


finish:



TextWindow.WriteLine("plz wait while the matrix creates, unless you have a very fast pc go for a snack")
' i make a second index that count 1,2,1,2,3,4,1,2,3,4,5,6,7,8,1,2,3... this would be the first transformation
For j=1 To power
b[j][0]=binario[j]
EndFor



j=1
For i=0 To 1
j=j+1
b[j][1]=b[j][0]
EndFor
For i=0 To 4-1
j=j+1
b[j][1]=b[j][0]
EndFor
For i=0 To 8-1
j=j+1
b[j][1]=b[j][0]
EndFor
For i=0 To 16-1
j=j+1
b[j][1]=b[j][0]
EndFor
For i=0 To 32-1
j=j+1
b[j][1]=b[j][0]
EndFor
For i=0 To 64-1
j=j+-1
b[j][1]=b[j][0]
EndFor
For i=0 To 128-1
j=j+1
b[j][1]=b[j][0]
EndFor
For i=0 To 256-1
j=j+1
b[j][1]=b[j][0]
EndFor
For i=0 To 512-1
j=j+1
b[j][1]=b[j][0]
EndFor

For i=0 To 1024-1
j=j+1
b[j][1]=b[j][0]
EndFor

For i=0 To 2048-1
j=j+1
b[j][1]=b[j][0]
EndFor








'this is to make all posible transformations so eventually all binary numbers get transformed t0 0,1, 10 or 11
For x=1 To power/8
TextWindow.WriteLine( "plz wait while the matrix creates,it will take a couple of minutes "+(power /8-x))

For i=0 To power
b[i][x]=b[i-8][x-1]
EndFor



EndFor

'this is to make a short sample of the matrix
For i=1 to 20
TextWindow.WriteLine(b[i][1]+"*"+b[i][2]+"*"+b[i][3]+"*"+b[i][4]+"*"+b[i][5]+"*"+b[i][6]+"*"+b[i][7]+"*"+b[i][8])
EndFor

re:
TextWindow.WriteLine("enter binary number with 2 STANDING AS 0 like 22122121 ")
TextWindow.WriteLine("remember that the 0 to the left in this case a 2 doesnt count")

q= TextWindow.ReadNumber()
For p=1 To 20
'this is to neglect the zeroes to the left
If Text.StartsWith(q,"2") Then
q= Text.GetSubTextToEnd(q,2)
EndIf
EndFor
'sets the maxium digits size to convert that depends on the size of the matrix
if Text.GetLength(q)>z then
TextWindow.WriteLine("the number has to be"+z+" digits maximum")
Goto re
EndIf
numb=q
'it searches the number in the first index
For i=0 To power
If numb= b[i][0] then
index=i
Goto tag
EndIf
EndFor
tag:
'then transforms it to the right
trans=0
repeat:
trans=trans+1
numb=b[index][trans]




If numb=1 or numb=2 or numb=12 or numb=11 or numb=122 or numb=121or numb=112or numb=111Then
Goto finish2
EndIf

Goto repeat
finish2:
TextWindow.WriteLine("the compiled number is "+numb+" after "+trans+" transformations")

TextWindow.WriteLine("enter number to decompile")
dec= TextWindow.ReadNumber()
TextWindow.WriteLine("enter number of transformations")
tr= TextWindow.ReadNumber()
'every final number after finishing counting to the right is 0,1,10 or 11

If dec=2 then
four=1
EndIf

If dec=1 then
four=2
EndIf

If dec=12 then
four=3
EndIf

If dec=11 then
four=4
EndIf

If dec=122 then
four=5
EndIf

If dec=121 then
four=6
EndIf

If dec=112 then
four=7
EndIf

If dec=111 then
four=8
EndIf


' now i count to the left from the basic chunk to decompress
answer=b[tr*8+four][0]
TextWindow.WriteLine(answer)




Goto re