Beside, nested loop and not-nested loop, loop can also be defined into forever loop and not-forever loop.
So, based on the mechanic, loops can also divided into:
1. Nested loop
2. Not-nested loop
And, types of loop based on lifetime:
1. Forever
2. Not-forever or limited
So, in this tutorial we will learned with not-nested loop, forever loop and not-nested loop, not-forever loop.
You know, there are 2 types of loop based on lifetime. Forever loop and not-forever loop. And, there are 3 types of loop maker: For, while and if.. goto..
3 Loop maker:
1. For
2. While
3. If.. Goto..
2 Types of loop based on lifetime:
1. Forever
2. Not-forever or limited
Both can be made with loop maker.
For example:
1. Forever
1.1 Forever loop with For loop
You can make forever loop using for by using a very,very big number. So it looks like forever because of length of the number, but it is not.
for i = 0 To 9999999999999999999999999
TextWindow.WriteLine(i)
EndFor
1.2. Forever loop with While loop
You can also make forever loop by using while loop by using a very, very big number, so it also looks like forever because of length of the number, but it is not.
While i < 999999999999999999999999999
TextWindow.WriteLine(i)
i = i + 1
EndWhile
1.3. Forever loop with If.. Goto.. Loop
This the last type and actually it is the best kind of making forever loop.
up:
TextWindow.WriteLine(i)
i = i + 1
Goto up
2. Not-forever
2.1 Not-forever loop with For loop
Creating not-forever loop with for loop is easy, you just need to define the number not big enough as the limit.
Example:
For i = 0 To 100
TextWindow.WriteLine(i)
EndFor
2.2 Not-forever loop with While loop
Creating not-forever loop with While loop is easy, the same as For loop, you just need to define the number that is not big enough as the limit.
For example like below:
while i < 100
TextWindow.WriteLine(i)
i = i + 1
EndWhile
2.3 Not-forever with If.. Goto.. Loop
Okay, to make not-forever loop or limited loop with If.. Goto.. Loop is quite difficult. But it is okay, you will got it.
In this, if.. goto.. loop type you will need the help of iterator variable (in this case i variable), same as with While loop example and off course, you need the help of a label to jump to.
So, iterator variable, the increments expression for iterator, goto expression and a label.
For example
up:
TextWindow.WriteLine(i)
If i < 100 Then
i = i + 1
Goto up
EndIf
In this tutorial we will learn about shifting partly array's element and remove the trail. This often needed in some cases of programming.
For instance, we have array:
ourarray[10]
For i = 0 To 10
ourarray[i] = i
EndFor
TextWindow.WriteLine("Enter the start of shifted components of the main array: ")
start = textwindow.Read()
For i = start To 10
ourarray[i-1] = ourarray[i]
EndFor
oa_l = Array.GetItemCount(ourarray)
For i = 0 To oa_l - 1
TextWindow.Write(ourarray[i])
TextWindow.Write(",")
Program.Delay(1000)
EndFor
1. Days before firewall
Everyone can easily create socket user program then the user program contacted someone else on the internet to say:
1. status of the program; alive or not alive.
2. Give or send the contain of a file.
In this tutorial, I will show you how two types of code's execution speed based on my experience.
1. Fast execution time, hard to write code, compact code, short code.
2. Slower execution time, easier to write code, divided or non-compact code, long code.
You can combine compact code and non-compact code on your programs.
In every programming, there are case when you need dynamic looping.
There are two types of dynamic looping
1. Dynamic nested looping
2. Dynamic non-nested loop
'This is also why OSPF is limit its neighbors. I'm just guess so.
Dynamic nested loop is used when you want to generate password for password cracker program, for instance 8 digits password, 9 digits password, and 10 digits password.
And for folder iteration program, like dir /S command on cmd windows.
In this tutorial, we will learn about how to make video intro like matrix. You can watch the video below to see. You can also uses this program as a video therapy when you want to sleep (I found out that this program can be a video therapy when I stared the code running too long; it kinda give me some calm effect to my brain) or you can use it as video banner of your youtube video.
The program is dividing the width of the graphics window with the area the determined by the user, the result is x.
This is kinda confusing but the point is x, and the loop start from 0 to x - 1.
There are problems that arise:
1. You need to be continuous between the cloters number
2. How to make the Text always in front position not in the back position.
3. Etc,.
You can watch the movie here:
In this program, we devide it in two:
1. The first version
2. The last completed version
TextWindow.WriteLine("Hello, welcome to the matrix board created with Small Basic.")
TextWindow.WriteLine("Created by: Jesus Christ, the Lord and Messiah.")
TextWindow.WriteLine("1. Enter what background color that you want to use: ")
bc = TextWindow.Read()
TextWindow.WriteLine("2. Enter what font color that you want to use: ")
fc = TextWindow.Read()
TextWindow.WriteLine("3. Enter the font size that you want to use (default is 12): ")
fs = TextWindow.Read()
TextWindow.WriteLine("4. Enter the font name that you wan to use (for ex. Times New Roman)")
fn = TextWindow.Read()
TextWindow.WriteLine("5. Enter the font space : ")
fsp = TextWindow.Read()
TextWindow.WriteLine("6. Enter the text that you want to enter: ")
tte = TextWindow.Read()
TextWindow.WriteLine("7. Enter the size of the text that you want to use: ")
sott = TextWindow.Read()
TextWindow.WriteLine("8. Enter the x position of the text that you want to use: ")
xpt = TextWindow.Read()
TextWindow.WriteLine("9. Enter the y position of the text that you want to enter: ")
ypt = TextWindow.Read()
'Set the graphics settings based on the input from the user
GraphicsWindow.BackgroundColor = bc
GraphicsWindow.BrushColor = fc
GraphicsWindow.FontSize = fs
GraphicsWindow.FontName = fn
For i = 0 to nocpw
td = Text.GetCharacter(Math.GetRandomNumber(100))
TextWindow.WriteLine(td)
ts[i] = Shapes.AddText(td)
Shapes.Move(ts[i],i*ics,0)
'group = group + 1
'Program.Delay(100)
EndFor
maks = i
While continue = 1
For i = 0 To Array.GetItemCount(ts) - 1
x = Shapes.GetLeft(ts[i])
y = Shapes.GetTop(ts[i])
'TextWindow.WriteLine(x)
'TextWindow.WriteLine(y)
Shapes.Move(ts[i],x,y+fs)
'Program.Delay(100)
EndFor
'This part is for adding new sprites
For j = 0 to nocpw
'maks = maks + 1
i = maks + j
td = Text.GetCharacter(Math.GetRandomNumber(100))
'TextWindow.WriteLine(td)
ts[i] = Shapes.AddText(td)
Shapes.Move(ts[i],j*ics,0)
'TextWindow.WriteLine("Testing")
'Program.Delay(100)
EndFor
maks = i
endwhile
sub nantiajalah
For i = 0 To Array.GetItemCount(ts) - 1
Shapes.Move(ts[i],Shapes.GetTop(ts[i]),shapes.GetLeft(ts[i])+ fs)
'Program.Delay(1000)
'gt = Shapes.gettop(ts[i])
'gl = Shapes.GetLeft(ts[i])
'TextWindow.WriteLine("gt : " + gt + ", gl : " + gl)
EndFor
endsub
This is the completed version:
GraphicsWindow.Show()
GraphicsWindow.Width = Desktop.Width
GraphicsWindow.Height = Desktop.Height
GraphicsWindow.Top = 0
GraphicsWindow.Left = 0
GraphicsWindow.Title = "Jesus Christ the Lord and Messiah - Graphicswindow"
TextWindow.Title = "Jesus Christ the Lord and Messiah - Textwindow"
'TextWindow.WriteLine("")
TextWindow.WriteLine("Hello, welcome to the matrix board created with Small Basic.")
TextWindow.WriteLine("Created by: Jesus Christ, the Lord and Messiah.")
TextWindow.WriteLine("Year: 2020, amid of Coronavirus outbreak.")
TextWindow.WriteLine("Ok, lets begin...")
TextWindow.WriteLine("=============================================================")
TextWindow.WriteLine("")
TextWindow.WriteLine("1. Enter what background color that you want to use (default is orange): ")
bc = TextWindow.Read()
TextWindow.WriteLine("2. Enter what font color that you want to use (default is yellow): ")
fc = TextWindow.Read()
TextWindow.WriteLine("3. Enter the font size that you want to use (default is 12): ")
fs = TextWindow.Read()
TextWindow.WriteLine("4. Enter the font name that you want to use (default is Times New Roman): ")
fn = TextWindow.Read()
TextWindow.WriteLine("5. Enter the area width of each character (default is 5): ")
wec = TextWindow.Read()
TextWindow.WriteLine("6. Enter the text that you want to enter (default Jesus Christ is the Lord and Messiah!): ")
tte = TextWindow.Read()
TextWindow.WriteLine("7. Enter the size of the text that you want to use (default is 12): ")
sott = TextWindow.Read()
TextWindow.WriteLine("8. Enter the x position of the text that you want to use (default is 0): ")
xpt = TextWindow.Read()
TextWindow.WriteLine("9. Enter the y position of the text that you want to enter (default is 0): ")
ypt = TextWindow.Read()
TextWindow.Write("Ok, Lets draw")
For i = 0 To 2
TextWindow.write(".")
Program.Delay(1000)
EndFor
'This part is for Userinput validation
If bc = "" Then
bc = "Orange"
Else
EndIf
If fc = "" Then
fc = "Yellow"
Else
EndIf
If fn = "" Then
fn = "Times New Roman"
Else
EndIf
If wec = "" Then
wec = 5
Else
EndIf
If tte = "" Then
tte = "Jesus Christ is the Lord and Messiah!"
Else
EndIf
If xpt = "" Then
xpt = 0
Else
EndIf
If ypt = "" Then
ypt = 0
Else
EndIf
If sott = "" Then
sott = 36
GraphicsWindow.FontSize = 36
Else
GraphicsWindow.FontSize = sott
EndIf
If fs = "" Then
fs = 12
GraphicsWindow.FontSize = 12
Else
GraphicsWindow.FontSize = fs
EndIf
'TextWindow.WriteLine("sott is this: " + sott)
'TextWindow.WriteLine("fs is this: " + fs)
GraphicsWindow.BackgroundColor = bc
GraphicsWindow.FontName = fn
'TextWindow.WriteLine("ini i : " + i - 1)
'Program.Delay(5000)
'Goto eof
'TextWindow.WriteLine(i)
'maks = i
'TextWindow.WriteLine("maks : " + maks)
While continue = 1
'This part is for moving all sprite down one fontsize to the bottom
For i = 0 To Array.GetItemCount(ts) - 1
'TextWindow.WriteLine(ts)
'Program.Delay(5000)
'TextWindow.WriteLine("Ini nilai panjang ts: "+ Array.GetItemCount(ts))
'Goto eof
'Program.Delay(100)
x = Shapes.GetLeft(ts[i])
y = Shapes.GetTop(ts[i])
Shapes.Move(ts[i],x,y+wec)
'TextWindow.WriteLine("Total elemen adalah: " + array.GetItemCount(ts) - 1)
'TextWindow.WriteLine("ini adalah i penurunan: " + i)
'TextWindow.WriteLine("Ini adalah elemennya nilai: " + ts[i])
'Program.Delay(500)
EndFor
'TextWindow.WriteLine(ts)
'TextWindow.WriteLine("jumlah yang telah diturunkan : " + i - 1)
'TextWindow.WriteLine("###############################")
'Program.Delay(5000)
'This part is for creating new sprites for total nocpw
start = Array.GetItemCount(ts)
For i = 0 to spot - 1
'TextWindow.WriteLine(ts)
'Program.Delay(5000)
'td = Text.GetCharacter(Math.GetRandomNumber(100))
td = Math.GetRandomNumber(99)
'TextWindow.WriteLine("dibawah: " + i +", td : " + td)
'TextWindow.WriteLine("nilai: "+ td)
GraphicsWindow.BrushColor = fc
GraphicsWindow.FontSize = fs
ts[i+start] = Shapes.AddText(td)
Shapes.Move(ts[i+start],i*wec,0)
'Program.Delay(5000)
EndFor
'TextWindow.WriteLine("Total element hingga sekarang: " + Array.GetItemCount(ts)-1)
'TextWindow.WriteLine("###############################")
'Program.Delay(5000)
maks = i
'This part is for recreating the text, so it can't get behind the rainning characters
'A.k.a this is for the shape get in front of the rainning character
FACT
1. DNS server program can be tested locally and interlocally using local program like cmd or using other host on the LAN network.
2. This the result of the local testing, using command:
nslookup www.google.com 127.0.0.1
in command prompt window or cmd.
3. You can't use wireshark to capture local traffic. So, you need to rely on the output of the python:
4. The \x is define that the next 2 characters are hex characters. For example \x00
5. \x03 is end of text.
6. When someone asks, you need to answer.
7. UDP Header is always 8 byte.
8. The DNS query length is = UDP length - 8 byte - (2 byte * 8)
In this tutorial we will create a diagonal matrix with random number values. The program is like below:
TextWindow.WriteLine("Enter the matrix size that you like to enter: ")
ms = TextWindow.Read()
For i = 0 To ms
For j = 0 To ms
if array[i][j] <> 0 Then
If i <> j then
array[i][j] = Math.GetRandomNumber(10)
array[j][i] = array[i][j]
ElseIf i = j then
array[i][j] = 0
EndIf
EndIf
EndFor
EndFor
Creating diagonal zero matrix is essentially give value to both (i,j) and (j,i) if (i,j) is still empty or still not initialized yet for how many rows and colomns that you like.
Fact about mesh
Every line is neighbor list of that line or a.k.a of that element. So for instance you want to make a program like this: print all the neighbor and the neighbor
Print all the neighbor of the first first neighbor of node 1
textwindow.writeline("Enter the node: ")
node = textwindow.read()
textwindow.writeline("Enter the neighbor you want to print its neighbor:")
neighbor = textwindow.read()
or this can be said like this:
textwindow.writeline("Enter the node: ")
node = textwindow.read()
textwindow.writeline("Enter the index of the neighbor that you want us to print its neighbor: ")
firstneighborindex = textwindow.read()
I want to make a black and white image to have punctuation or other characters in the black pixels.
'GraphicsWindow.FontSize = 10
'GraphicsWindow.FontName =
wide = 5
GraphicsWindow.FontSize = wide
GraphicsWindow.DrawImage("C:\Users\Totardo\Downloads\flower-black-a-white-pattern-vector-224732.jpg",0,0)
For i = 0 To 1080 Step wide
For j = 0 To 823 Step wide
black_count = 0
For k = 0 To wide
For l = 0 To wide
'GraphicsWindow.FillEllipse(i+k,j+l,1,1)
test[i+k][j+l]=GraphicsWindow.GetPixel(i+k,j+l)
pc = GraphicsWindow.GetPixel(i+k,j+l)
TextWindow.WriteLine(i+k+","+j+l+","+pc)
If pc <> "#FFFFFF" Then
'TextWindow.WriteLine("Not pure white")
black_count = black_count + 1
'TextWindow.WriteLine("black_count is:" + black_count)
'Program.Delay(1000)
EndIf
Sub aloha
For i = 0 To array.GetItemCount(test[i])
For j = 0 To Array.GetItemCount(test[j])
GraphicsWindow.BrushColor = test[i][j]
GraphicsWindow.FillEllipse(i,j,1,1)
EndFor
EndFor
EndSub
GraphicsWindow.Clear()
For i = 0 To 200
For j = 0 To 200
GraphicsWindow.DrawText(i,j,paint_new[i][j])
EndFor
EndFor
In this tutorial we will learn how to make histogram program; that is program that count how many pixel a pixel color are in an image.
So the program like this:
TextWindow.WriteLine("1. Enter the file path of the image: ")
ifp = TextWindow.Read()
TextWindow.WriteLine("2. Enter the width information image: ")
wii = TextWindow.Read()
TextWindow.WriteLine("3. Enter the height information image: ")
hii = TextWindow.Read()
'1. Load or draw the image
GraphicsWindow.DrawImage(ifp,0,0)
'2. Get all the pixel's color information from pixel index 0,0 to 200,200
For i = 0 To hii
For j = 0 To wii
'get all the pixel's color information
pc = GraphicsWindow.GetPixel(i,j)
If i = 0 And j = 0 Then
col_arr[0][0] = pc
col_arr[0][1] = 1
Goto quit
EndIf
'Checking with col_arr array (col_arr stands for color array)
For k = 0 To array.GetItemCount(col_arr) - 1
If pc = col_arr[k][0] Then
col_arr[k][1] = col_arr[k][1] + 1
max = 1 'to trace the length of the row of the col_array
Goto quitloopk
Else
If k = Array.GetItemCount(col_arr) - 1 Then
col_arr[max][0] = pc
col_array[max][1] = 1
max = max + 1
EndIf
EndIf
quit:
EndFor
quitloopk:
EndFor
EndFor
TextWindow.WriteLine("No."+"Color"+"Number of pixels")
For i = 0 To Array.GetItemCount(col_arr) - 1
TextWindow.WriteLine(i +","+col_arr[i][0]+":"+col_arr[i][1]+" Pixels")
EndFor
In this tutorial we will learn about how to determine color of a pixel is it white or not using small basic.
The image will be traveled or traced up and down not to the right.
This code is the simplest way, you can use hex to decimal converter if you want.
GraphicsWindow.DrawImage("C:\Users\Totardo\testing.png",0,0)
For i = 0 To 200
For j = 0 To 200
TextWindow.WriteLine("i : " + i + ", j : " + j)
pc = GraphicsWindow.GetPixel(i,j)
GraphicsWindow.FillEllipse(i,j,10,10)
If pc <> "#000000" Then
TextWindow.WriteLine("It's not black i.e. it is white")
Else
TextWindow.WriteLine("It is black")
EndIf
Program.Delay(1000)
EndFor
EndFor
In this tutorial, we will played with multi-array in SMALL basic, and doing stuff like:
1. Printing all element forward; from the first element to the last element.
2. Printing all elements backward; from the last element to the first element.
3. Printing range of elements of a row or line
4. Printing range of elements of a colomn
5. Printing few of elements of a line.
6. Printing few of elements of a colomn.
7. Printing all element of a row
8. Printing all element of a colomn
9. Printing all element of two rows
10. Printing cyclic row
10.
6. Printing a specific or an element of a row
7. Printing a specific or an element of a colomn
8. Diagonal left
9. Diagonal right
Pre-requisite
So, to be able to work this material, you need to learn:
1. How to create multi-array in SMALL Basic
2. Nested for in SMALL Basic
So, welcome to the journey of multi-dimension array! It is fun journey! FACT
1. Notice that we use an example that consist of square matrix, it means the length for the column is the same for all the row.
2. So, we can use array.getitemcount(ourarray) operation to get the length of each for row and for colomn of our array - ourarray.
3. It is often good to think multi array as m-floor building with n-room in each floor.
But we devide this tutorial as:
1. Just printing the element matrix
2. Playing arithmatic with matrix like add, substract, divide, or multiply.
First, off course, we need to build a multi array; a 3 dimension array; a 3 row times 3 colomn array, how? like below:
But first, you know, you can make matrix 2 row times 2 colomns like below:
ourarray[0][0] = 1
ourarray[0][1] = 1
ourarray[1][0] = 0
ourarray[1][1] = 0
But it to small for us to play. So, we will make a matrix with 3 row times 3 colomn instead. Like below:
ourarray[0][0] = 1
ourarray[0][1] = 1
ourarray[0][2] = 0
ourarray[1][0] = 0
ourarray[1][1] = 0
ourarray[1][2] = 1
ourarray[2][0] = 1
ourarray[2][1] = 1
ourarray[2][2] = 0
And then printing out 1. Printing all element forward
For i = 0 To Array.GetItemCount(ourarray) - 1
For j = 0 To Array.GetItemCount(ourarray) - 1
TextWindow.WriteLine(ourarray[i][j])
EndFor
EndFor
2. Printing out backward
You will notice that both of the loop variable are minus
For i = Array.GetItemCount(ourarray) - 1 to 0 step -1
For j = Array.GetItemCount(ourarray) - 1 To 0 Step -1
TextWindow.WriteLine("This is our array [" +i+"]["+j+"]: "+ ourarray[i][j])
EndFor
EndFor
3. Printing range of elements of a row
For instance, I want to print element column range from colomn 0 to element colomn 1 of a row, for instance row 1.
The range itself, I put into an array called range. So the program is below:
row = 1
range_col[0] = 0
range_col[1] = 1
For i = row To row
For j = range_col[0] To range_col[1]
TextWindow.WriteLine("This is our array [" + i + "]["+ j +"] : " + ourarray[i][j])
EndFor
EndFor
Notice that the row loop variable, i.e. i is stick to the number of the row that you want to retrieve.
4. Printing range of elements of a colomn
Printing range of elements of a colomn is printing start from and end with.
The range itself as example 3, I put into an array called. So the program is below:
col = 1
range_row[0] = 1
range_row[1] = 2
For i = range_row[0] to range_row[1]
For j = col To col
TextWindow.WriteLine("This is our array [" + i + "][" + j + "] :" + ourarray[i][j])
EndFor
EndFor
5. Printing few elements of a colomn
The difference this printing few of elements of a colomn and printing range of element (example 4) is this will print uncontinuos elements. While printing range of element prints continous elements start from start point, end from end point.
In this example, we will print element's value of elemen 0 and elemen 2.
For i = row to row
For j = 0 To Array.GetItemCount(ourarray) - 1
For k = 0 To Array.GetItemCount(fewcol) - 1
If j = fewcol[k] then
TextWindow.WriteLine("This is our array [" + i + "][" + j + "]: " + ourarray[i][j])
EndIf
EndFor
EndFor
endfor
As you notice, here we use three loops, that are loop i, lo
6. Printing few elements of a row
The difference this printing few of elements of a row and printing few element
7. Printing few elements of a col
For i = 0 to Array.GetItemCount(ourarray) - 1
For j = col To col
For k = 0 To Array.GetItemCount(fewrow) - 1
If i = fewrow[k] then
TextWindow.WriteLine("This is our array [" + i + "][" + j + "]: " + ourarray[i][j])
EndIf
EndFor
EndFor
endfor
7. Printing all element of a row
The clue when printing all element of a line is: the line loop variable is stick to the number of the line that you like to print, but the colomn loop variable is changing.
For example:
5. Printing all element of a colomn
The clue when printing all element of a colomn is: the colomn loop variable is stick to the number of the colomn that you like to print, but the line loop variable is changing.
For example below we want to print all the element's value of colomn 2:
For i = 0 to 2
For j = 1 to 1
textwindow.writeline(ourarray[i][j])
endfor
endfor
6. Printing
8. Printing diagonal left or decline diagonal (if we look or start from the left side of the matrix)
Printing diagonal left using loop is unique; it only uses 1 loop not two as like other examples. So like this:
For i = 0 to Array.GetItemCount(ourarray) - 1
j = i
textwindow.writeline(ourarray[i][j])
endfor
If you use two loops it would produce "printing all elements" program.
9. Printing diagonal right or incline diagonal (if we look or start from the left side of the matrix)
Printing diagonal right or incline diagonal is uniqe, because one of the loop is counting backward that is the colomn
For i = 0 to array.getitemcount(ourarray)
for j = array.getitemcount(ourarray) - 1 to 0 step -1
textwindow.writeline(ourarray[i][j])
endfor
endfor
Notice
10. Printing cyclic row
This is when you want to print from different row other than row 0 and then back to behind your start or desired row.
For instance, I started printing all colomns start from row 1 to row 2 and then back to row 0.
textwindow.writeline("Enter the source or the start: ")
source = textwindow.read()
For i = source To array.GetItemCount(ourarray) - 1
For j = 0 To Array.GetItemCount(ourarray[i]) - 1
TextWindow.WriteLine(ourarray[i][j])
EndFor
EndFor
If source > 0 Then
For i = 0 To source
For j = 0 to Array.GetItemCount(ourarray[i]) - 1
TextWindow.WriteLine(ourarray[i][j])
endfor
EndFor
EndIf
'1. Check or list the neighbor of the source_node
TextWindow.WriteLine("Enter the center node: ")
the_center = TextWindow.Read()
'1. Get the count of center's neighbor
TextWindow.WriteLine("")
cn = Array.GetItemCount(matrix[the_center])
TextWindow.WriteLine(cn)
'2. Get the list of center's neighbor (index that have value 1)
j = 0
for i = 0 To cn - 1
If matrix[the_center][i] = 1 Then
neighbor_1[j]=i
j = j + 1
EndIf
EndFor
'3. display the neighbor_1 list
For i = 0 To array.GetItemCount(neighbor_1) - 1
TextWindow.WriteLine("This is neighbor " + i + " element :" + neighbor_1[i])
EndFor
Graph can be expressed with 2 dimensional array or matrix. More precise, it is an array or matrix that mirroring diagonally and the diagonal elements are all zero values.
So,
The algorithm to accomplishes path or route determination is search neighbor's neighbors to search a neighbor, more like search folder inside a subfolders to search a subfolder.
It will reduced.
PRE-REQUISITE
1. Learn 2 dimensional array
Path determination consist of components:
1. Source
2. Destination
3. Map
4. Arrays of path or route
In this tutorial we will discuss about AND, OR and XOR logic.
You know, small basic is not provide the logic so we will built the function by our self.
So, we will built tree sub procedure:
1. Logic AND code
2. Logic OR code
3. Logic XOR code
Pre-requisite
1. You need to study the truth table of each operation.
2. This program is simply implementing the truth table inside a sub procedure, with simple if condition. So, don't worry. You need to learn how to use elseif. Elseif is how to define another if in the same level if the if.
Facts
1. If you watch carefully, all the IF condition are all use AND keyword, despite OR or XOR operation.
2. Truth table how to memorize it:
Shortcut for OR, if one of any of the input is 1, then the output is 1.
Shortcut for XOR, if both of the input are different, then the output are 1.
Shortcut for AND, if only both of the input are 1, then the output are 1.
1. Logic AND
x = 1
y = 1
LogicAND()
TextWindow.WriteLine("The result are: " + result)
Sub LogicAND
If x = 0 And y = 0 Then
result = 0
ElseIf x = 0 and y = 1 then
result = 0
elseif x = 1 and y = 0 then
result = 0
elseif x = 1 and y = 1 then
result = 1
EndIf
EndSub
2. Logic OR
Sub logicOR
If x = 0 And y = 0 Then
result = 0
ElseIf x = 0 and y = 1 then
result = 1
elseif x = 1 and y = 0 then
result = 1
elseif x = 1 and y = 1 then
result = 1
EndIf
EndSub
3. Logic XOR
Sub logicXOR
If x = 0 And y = 0 Then
result = 0
ElseIf x = 0 and y = 1 then
result = 1
elseif x = 1 and y = 0 then
result = 1
elseif x = 1 and y = 1 then
result = 0
EndIf
EndSub
In this tutorial, we will discuss conversion between Decimal to other system like binary, octal and hexadecimal.
So in this case we essentially discuss about:
1. Decimal to binary conversion program.
2. Decimal to octal conversion program.
3. Decimal to hexadecimal conversion program.
4. The final program that conclude all the numbering conversion system from decimal to 2 numbering system until decimal to 9 numbering system, plus numbering system 16 conversion.
Few facts that you need to know
1. You know that decimal to octal conversion program and decimal to hexadecimal conversion program is a slight modification of decimal to binary conversion program.
2. The array is already first in first in.
3. Only decimal to hexadecimal that need a little bit adding a code; converting from 10 to 15 digits as A to F characters, we called this addtional code.
4.
In this tutorial, we will use division method of conversion. There are more than one method of how to convert decimal to other numbering system.
1. Decimal to binary conversion program
So, here is the code for decimal to binary conversion.
decimal = 100
i = 0
binary[i] = Math.Remainder(decimal, 2)
TextWindow.WriteLine(binary[i])
decimal = Math.Floor(decimal / 2)
While decimal > 1
i = i + 1
binary[i] = math.Remainder(decimal, 2)
decimal = math.Floor(decimal / 2)
TextWindow.WriteLine(binary[i])
EndWhile
i = i + 1
binary[i] = 1
textwindow.WriteLine("This is item length: " + Array.GetItemCount(binary))
For i = 0 To Array.getitemcount(binary) - 1
TextWindow.WriteLine("This is binary " + i + ": "+ binary[i])
EndFor
2. Decimal to octal conversion program.
This the decimal to octal conversion program.
decimal_number = 8
i = 0
octal[i] = Math.Remainder(decimal_number, 8)
'TextWindow.WriteLine(binary[i])
decimal = Math.Floor(decimal_number / 8)
TextWindow.WriteLine("This is decimal: " + decimal)
While decimal > 7
i = i + 1
octal[i] = math.Remainder(decimal_number, 8)
decimal = math.Floor(decimal_number / 8)
'TextWindow.WriteLine(binary[i])
EndWhile
i = i + 1
TextWindow.WriteLine("This is decimal: " + decimal)
octal[i] = decimal
textwindow.WriteLine("This is item length: " + Array.GetItemCount(octal))
For i = 0 To Array.getitemcount(octal) - 1
TextWindow.WriteLine("This is the octal " + i + ": "+ octal[i])
EndFor
3. Decimal to hexadecimal conversion program.
This is decimal to hexadecimal conversion program.
decimal_to_convert = 13
i = 0
hexa[i] = Math.Remainder(decimal_to_convert, 16)
TextWindow.WriteLine(hexa[i])
decimal_to_convert = Math.Floor(decimal_to_convert / 16)
While decimal_to_convert > 15
i = i + 1
hexa[i] = math.Remainder(decimal_to_convert, 16)
decimal_to_convert = math.Floor(decimal_to_convert / 16)
TextWindow.WriteLine(hexa[i])
EndWhile
i = i + 1
hexa[i] = decimal_to_convert
For i = 0 To Array.GetItemCount(hexa)
TextWindow.WriteLine("This is the item of : " + i + " " + hexa[i])
EndFor
'This addtional program that I mention.
For i = 0 To Array.GetItemCount(hexa) - 1
TextWindow.WriteLine("inside : " + hexa[i])
If hexa[i] > 9 Then
If hexa[i] = 10 Then
hexa[i] = "A"
ElseIf hexa[i] = 11 Then
hexa[i] = "B"
ElseIf hexa[i] = 12 Then
hexa[i] = "C"
ElseIf hexa[i] = 13 Then
TextWindow.WriteLine("Hit here")
hexa[i] = "D"
ElseIf hexa[i] = 14 Then
hexa[i] = "E"
ElseIf hexa[i] = 15 Then
hexa[i] = "F"
EndIf
EndIf
EndFor
textwindow.WriteLine("This is item length: " + Array.GetItemCount(hexa))
For i = 0 To Array.getitemcount(hexa) - 1
TextWindow.WriteLine("This is the hexa " + i + ": "+ hexa[i])
EndFor
4. The final program
TextWindow.WriteLine("1. Enter the decimal number that you need to convert: ")
decimal_to_convert = TextWindow.Read()
TextWindow.WriteLine("2. Enter the base number that you need to convert (1-9),16?")
base = TextWindow.Read()
i = 0
digit[i] = Math.Remainder(decimal_to_convert, base)
decimal_to_convert = Math.Floor(decimal_to_convert / base)
While decimal_to_convert > base - 1
i = i + 1
digit[i] = math.Remainder(decimal_to_convert, base)
decimal_to_convert = math.Floor(decimal_to_convert / base)
EndWhile
i = i + 1
digit[i] = decimal_to_convert
If base = 16 Then
For i = 0 To Array.GetItemCount(digit) - 1
TextWindow.WriteLine("inside : " + digit[i])
If digit[i] > 9 Then
If digit[i] = 10 Then
digit[i] = "A"
ElseIf digit[i] = 11 Then
digit[i] = "B"
ElseIf digit[i] = 12 Then
digit[i] = "C"
ElseIf digit[i] = 13 Then
digit[i] = "D"
ElseIf digit[i] = 14 Then
digit[i] = "E"
ElseIf digit[i] = 15 Then
digit[i] = "F"
EndIf
EndIf
EndFor
EndIf
For i = 0 To Array.getitemcount(digit) - 1
TextWindow.WriteLine("This is the digit " + i + " of the converted: "+ digit[i])
EndFor
In this tutorial we will learn about how to search for occurances of a character through out the string, i.e. search for index of occurance of a character through all the string.
Hello Network Administrator or Network Technician.
In this tutorial, we will learn about activities based on IPv4, that are:
1. Determining the network address (NA)
2. Determining the host address (HA)
3. Determining the broadcast address (BA)
4. Determining the first usable address (FUA)
5. Deteriming the last usable address (LUA)
If you given the host address, then the task you might need to accomplished are:
1. Determining the network address (NA)
2. Determining the broadcast address (BA)
3. Determining the first usable address (FUA)
4. Deteriming the last usable address (LUA)
And the question is this valid:
1. Is this valid network address (VNA)?
2. Is this valid broadcast address (VBA)
3. Is this valid host address (VHA)
4. Is this valid first usable address (VFUA)
5. Is this valis last usable address (VLUA)
Standard
There are 2 views:
1. Based on the number of hosts
2. Based on the number of the network
1. Look to the largest subnet, count the number of host in that subnet.
2. Take the available network or the original block address and original prefix number or original subnet number
3. Count the number of host bit that accomodate this largest subnet.
4. Count the number of new subnetwork bit that resulted from 32 - host bit requirement.
4. Count the new prefix using number of host bit required + network prefix number
5. Count the new subnetmask using the new prefix that converted to dotted decimal number, much like IPv4 address.
6. Count the broadcast address, usable address or range address and the eft over
In this tutorial we will discuss about batch FOR /F.
What is batch FOR /F?
FOR /F
1. FOR /F if running an wrong command will generate nothing
'sadvdssadd' is not recognized as an internal or external command, operable program or batch file.
2. FOR /F is running an empty result will stop the process and not execute the do block.
For example:
3. FOR /F running a long command and consist of spaces.
For example:
FOR /F ping 192.168.1.0
Hello, network administrator below is the ping reply messages that we need to analyze and need to found out the cause:
1. Destination unreachable
2. Request timed out
3. Reply
4. Destination net unreachable
5.
Examples are:
1. Reply from 192.168.0.101: Destination host unreachable
3. Reply from 8.8.8.8: bytes=32 time=1653ms TTL=50
As you can see both are have keyword of reply, but reply with keyword bytes or time or TTL is the true reply from the destination, the other one is reply from the router.
Solutions:
Sometimes the solutions is the router need to be restarted.
CSS Font defined FWSS (Family, Weight, Style, Size and Variant ) with these specific property:
1. font-family
2. font-weight
3. font-style
4. font-size
5. font-variant
and with this non specific property:
font
CSS Font-size
The harderst
Em values:
1. Dynamic
2.
Fontsize property values:
You can specify Fontsize property values as:
1. Specified as number, or
2. Specified as keyword
Key
1. Specified as keywords
The keare
1. Absolute keyword, such:
2. Relative keywords, such:
Font-weight
Font-weight property have 2 values NB (Normal and Bold):
1. Normal, and
2. Bold
Font-style
Font-style property have 3 values NIO (Normal, Italic, Oblique)
1. Normal
2. Italic
3. Oblique
How to count how many character of a string is easy. You can use text.getlength() operation, and save it to a variable and output it to textwindow using textwindow.writeline() operation.
For instance:
s = "Thanks Small Basic"
a = text.getlength(s)
textwindow.writeline(a)
CSS outline is a property that draws a line outside or next beside or adjacent to the border line.
CSS outline is how you can change the outline's color, style, width (CSW).
So what is the benefit of using outline? Make you tag stand out.
Outline style
List of the outline styles are the same as the border styles that is there are 10 styles that you can choose.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
CSS Height and Width are two properties that can be used to resize an HTML element's size of height and width.
Width can set the width of an element, and height can set the height of an element with their values are (ALPII) Auto, length, Percentage, Inherit and Internal.
The default values
The default values of property width is auto. The default values of property height is auto.
There are also max-width, max-height, min-width, and min-height properties. What are they?
These are to state that
max-width is state that the width can't over the max-width, the min-width stated that the width can't be lower than the min-width.
max-height is stated that the height can't over the max-height, the min-width stated that the width can't be lower or less than the min
Height will make an element to have height as stated in the value of property Height. Even the contain is still less than the height.
Yes, you can build or make a tag or an element lies in the middle horizontally of the parent tag, a.k.a a banner box using auto value.
Top first and clockwise.
What is the relation between margin and border?
Margin is space outside the border, while padding is space inside the border.
You can set margin with :
1. Specific property style or
2. Non-specific property style.
Remember that CSS is consist of property and values. So types of properties of margin are:
1. Specific property: There are properties for each of side of element (top, right, bottom and left).
2. Non-specific property.
1. Specific property.
Specific propery:
margin-top
margin-right
margin-bottom
margin-left
2. Non-specific property
margin: 20px 20px 20px 20px
As the name implies this is used to do something with html's elements border.
Html element that can be is
One thing to remember, the
All side or each side.
Style
Border can have one of these 10 styles.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
But, each border can have different style. So you can have somekind of mix between the styles that mentioned above.
You can't set color and size if the border is not shown up.
How? Just put the direction in the middle of it.
Size
You can't set size and color if the border is not shown up.
Size can setted using one of this two method:
1. Using specific length using pt, px, cm, and etc.
2. Using pre-defined values: thin, medium, and thick.
As the name implies, CSS background is used for things happen to background of an element. like setting its background color, image, repeat method, position and it is can scrolled or not. For instance background-color, background-image, background-
Element that often setted the background is body or html, h1, and p.
One important thing about background to understand, there is a fact that default background image is displayed repeated x and y. So, you can change this behaviour by only repeated x or repeated y or none. There are 3 possibilities.
Thats it happy coding.
Things that we will try:
1. Setting the background image
In this tutorial we will learn about move command and some of its command problems.
The problems are:
1. The process cannot access the file because it is being used by another process.
2. The system cannot find the file specified.
3. The filename, directory name, or volume label syntax is incorrect.
4. The system cannot find the path specified.
5. The system cannot find the drive specified.
6. Access is denied.
The process cannot access the file because it is being used by another process.
All of them happens because of wrong command argument.
So, here is the explanation:
1. The process cannot access the file because it is being used by another process is means that
Means that the file or folder that you want to move is being used by another process and the value of %ERRORLEVEL% is 1.
You can solve this by using the resource monitor, click the CPU tab, and on the Associated Handles textbox type the folder or file that won't moved.
2. The system cannot find the file specified.
This is happens when you define the path is correct, but the filename is not correct.
3. The filename, directory name, or volume label syntax is incorrect.
This is happens when you define more than one drive in your first or both move command argument.
4. The system cannot find the path specified.
This means that you are using correct drive, but the path you have just entered as the move command's argument is not correct. a.k.a there is no path like that a.k.a the path like that is not existed. This is happen even if you mention the correct filename.
For instance:
Sometimes, can also be caused by "broken path" which is the path contain space. For example:
For example:
cd C:\Users\Totardo\Documents\Synfig Users\Totardo
5. The system cannot find the drive specified.
This error happen when you put drive letter that is not existed in your computer as the argument to the move command.
Echo can be
1. How to write variable name
To display date variable put carret in front of the percentage sign(%). Why? Because caret will escape the format sign.
For examples:
Echo To display date variable: ^%date^%
2. To display the contain of a variable
echo %_this_is_my_variable1%
You can output date and time with this command on a cmd window:
1. echo %date%
2. echo %time%
3. or, you can use wmic, do this: wmic os get localdatetime
That's all folks, I hope you like the information,
In this tutorial we will discuss about how to get bytes free from a drive or a.k.a how many space are available on that drive. There are many ways to do that, but in this tutorial, we only uses cmd command.
So, for instance we would like to know the available space on drive c:
Pointer is just a different type of variable. This type of variable holds not value (integer value, float value, character value) but memory address.
As you know, all our data or value of a variable is stored at certain address of the memory.
So, this type of variable (pointer, I mean) holds it (address of the memory).
There are 3 types of activity that you can do oftenly with pointer, for instances:
1. Creating pointer variable.
2. Assigning a memory address to a pointer variable.
3. Accessing value
It just how to declare it. It doesn't mean
Pointer also can have arithmatic operation
To read pointer arithmatic operation you can read in here.
String can be accessed with two methods:
1. Using variable, if you want to access all elements, or.
2. Using variable name and index, if you want to access specific elements of that string.
In this tutorial we will discuss about Array and DAAM (Declare, Assign, Access and Modify) operation.
Array is fixed size and same type elements that collected together by the programmer. For instance, you can collected together few integer values, you can collected together few characters values or you can collected together some float values, etc. into a variable.
So, first we need to know how to declare an array?
Declare - How to declare an array?
First you need to think about the type of the data of each of element that you like and how many element that will be prepared for you.
The syntax is this:
data-type array's_name [array_size]
For example:
int height[5] = [12, 13, 40, 15, 56];
int float[3] = [13
Assign - How to assign element's value?
There are two ways of how to assign element's value are (you put curly braces when assigning value to each element using both methods):
1. Explicit
For example:
int height[5]={177,180,160,170,172};
2. Implicit
For example:
int height[]={177,180,160,170,172}
Accessing - How to access element's value?
You need to know the element index which you like to access and put the number (the element index) inside the square brackets. For example:
cout << height[1], or
cout << height[2].
You can also access the value of each array's element by using the pointer for instance:
int *p = height;
cout << "The value of height[" << i << "]: " << *p;
Modify - How to modify or change the element's value?
You can change any initiated elements of array using below commands:
height[1] = 12;
In this lesson we learn about how to compare what inside a folder to what inside another folder, side by side.
PRE-REQUISITE
1. You need to know how to use setlocal enabledelayedexpansion
2. You need to know how to use FOR /F basically
3. You need to know how to use FOR /F with
4.
Code are:
@echo off SETLOCAL ENABLEDELAYEDEXPANSION REM This program will compare what inside a folder to
what inside another folder, side by side. REM We need to measure how many line in the 1st file SET /a length_file_1 = 0 SET /a length_file_2 = 0 FOR /F "tokens=* delims=" %%i IN ('"dir /b %1"') DO SET
/a length_file_1 = length_file_1 + 1
FOR /F "tokens=* delims=" %%i IN ('"dir /b %2"') DO SET
/a length_file_2 = length_file_2 + 1
echo File length at %1 is: %length_file_1% files or
folders.
echo File length at %2 is: %length_file_2% files or
folders.
REM Next, we need to compare which one is bigger
SET /a iterator_length = 0
IF %length_file_1% GEQ %length_file_2% SET /a
iterator_length = %length_file_1%
IF %length_file_2% GEQ %length_file_1% SET /a
iterator_length = %length_file_2%
REM Next echo the iterator length to the screen
echo Iterator length: %iterator_length%
REM extract all the data into two arrays
REM ====================================
SET /a indeks = 0
FOR /F "tokens=* delims= eol=;" %%i IN ('dir /b "%1"') DO
SET /a indeks = indeks + 1& SET a[!indeks!]=%%i
SET /a indeks = 0
FOR /F "tokens=* delims= eol=;" %%i IN ('dir /b "%2"') DO
set /a indeks = indeks + 1& SET b[!indeks!]=%%i
REM Print out using for /L
REM ======================
IF %length_file_1% GEQ %length_file_2% echo No, This
colomn is for %1 %TAB%,%TAB% This colomn is for %2&FOR /L
%%i IN (1,1,%length_file_1%) DO echo %%i, !a[%%i]! %TAB
%,%TAB% !b[%%i]!
IF %length_file_2% GEQ %length_file_1% echo No, This is
colomn is for %2 %TAB%,%TAB% This colomn is for %1&FOR /L
%%i IN (1,1,%length_file_2%) DO echo %%i, !a[%%i]! %TAB
%,%TAB% !b[%%i]!
In this tutorial I will show you how to parse an output of command: Dir * \b and set an array element each to the each line output of the command.
In this tutorial we will
So, lets continue
PRE REQUISITE
1. You need to know about setlocal EnableDelayedExpansion
2. You need to know about how to use FOR /F and FOR /L basically. You can read it at my tutorial.
@echo off REM This is a program for setting each array index value with for loop parameter value setlocal EnableDelayedExpansion REM Setting an array value with each for loop parameter value FOR /L %%i IN (1,1,10) DO set a[%%i]=%%i REM Outputting an array value with each for loop parameter value FOR /L %%i IN (1,1,10) DO echo !a[%%i]!
You can also add the FOR /F loop parameter value to each array index:
In this tutorial I will show you make a how to copy all files on a folder to another destination folder that you like.
Lets get into the code
In this tutorial we will use command: copy but we will use program argument 1 as the source file
REM This program will copied all files containded on one
directory to another folder as you like. REM This program created by Totzfreelance 2020 REM This program use program argument number 1 or a.k.a %1 as source folder and use program argument number 2 or a.k.a %2 as destination folder REM Example usage is: copy_to_all_files.bat C:\ C:\Users\ FOR /F "tokens=* delims=" %%i IN ('"dir /b * %1"') DO
copy %%i %2%%i.txt
This blog is how to echo certain line of a text file and you can also edit the code as you like.
You know, you can print all lines of a text file using FOR /F variant loop.
You can also print certain line of a text file using FOR /F loop variant but with few workaround; We will use IF to block or to not display echo and use setlocal EnableDelayedExpansion to get the number of iteration.
So in this tutorial we will echo or print out certain specific line out of any text file.
PRE-REQUISITE:
You need to know how to use setlocal EnableDelayedExpansion and variable: !somevariable!
@echo off REM This a program to read a specific line of a text file REM Created by Totzfreelance REM %1 is the filename that you want to read REM %2 is for the line number that you want to read from
the file a.k.a from the program argument number 1. setlocal EnableDelayedExpansion SET /a a = 0 FOR /F "tokens=* delims=" %%i IN ('type %1') DO set /a a
= a + 1&IF !a!==%2 echo %%i