Kamis, 02 April 2020

SMALL BASIC: Programming question session 2

1. If you have an array like below, what is the length of the array, notice the index 0 of the array is empty or "", i.e. What is the output of textwindow window?

myarr[0] = ""
myarr[1] = "A"
myarr[2] = "B"
TextWindow.WriteLine(Array.GetItemCount(myarr))

A). 1 B). 2 C). 3

2. Still with code from number  1


3. Logic question: Mr. Bono told to record all the room number that are not empty and handed that record to Mr. Bing, because Mr. Bing wants to knock every door's room, meet and invite every room user to have a tea while talk with him/her about the rise of the rent.

But,

4). Look for the code below, I want to add fgd array's element to nbr array's element. Do you think the nbr array elements grows or appended with fgd elements forever?

fgd[0] = "Added"
fgd[1] = "Added"
nbr[0] = 0
nbr[1] = 1

start:

nbr_l = array.GetItemCount(nbr)
TextWindow.WriteLine(nbr_l)
TextWindow.Pause()
For i= 0 To 1
  nbr[i+nbr_l] = fgd[i]
EndFor
TextWindow.writeline(nbr)
Program.delay(1000)
Goto start


5). Multi dimension array question. Look at for the code below, do you think the code will generated y as a multi dimension array? or not?

x[0] = 10
x[1] = 11

For i = 0 To 1
  y[i] = x
EndFor


TextWindow.WriteLine(y)
 

6). Still based on question 5, how many lines or rows, array y have?

SMALL BASIC: Interrelation of arrays

Hello, SMALL BASIC programmer, welcome.

In this tutorial we will learned about interrelation of arrays. There are two, three or even more arrays that are interelated during the programming session.

What interrelation of arrays. Interrelation of arrays, I mean what

Use this the value of each of the element's of this array (Array A) to get


1. Get the index of this value
2. Get the value of this index

1. Save as the value of this index
2. Save as the index of this value

So for example, get the index of this value and save it as the value

Get the value of the these indexes and use it as index of to access another array and save it as the value of this index.

SMALL BASIC: Adding or appending elements to array

Hello, SMALL BASIC programmer, welcome.

In this tutorial we will learn how to adding or appending elements to an array. These are few tips or few methods:

1. Adding or appending elements one by one
2. Adding or appending elements one array by one array whole

So, lets discuss this one by one:

1. Adding or appending elements one by one

object_1[0] = "A"
object_1[1] = "B"
object_2[0] = 1
object_2[1] = 2

'Appending one element after one element to an array
'1st. Find the length adder and the length of addee, but
'except the object_1 don't substract it with 1
object_2_l = Array.GetItemCount(object_2) - 1
object_1_l = Array.GetItemCount(object_1)

For i = 0 To object_2_l
  object_1[object_1_l+i] = object_2[i]
EndFor


'2. Get the length of the new object
object_1_l = Array.GetItemCount(object_1)
For i = 0 To object_1_l - 1
  TextWindow.WriteLine(object_1[i])
EndFor
  



Rabu, 01 April 2020

SMALL BASIC: Programming questions session 1

Hello, SMALL BASIC programmer, welcome.

In this page we will learned programming question session 1 (amid corona virus outbreak).

So, what is the answers of the questions below:

1. Look at program below, what is the value of i, each time i is printed to the textwindow window?

Up:
TextWindow.WriteLine(i)
For i = 0 To 10
  Goto up
  Program.Delay(1000)
EndFor

2. Still using above program, but with slight modification. How many time the program will runs or a.k.a the program printed "Hello World!" to the textwindow window?

Up:
TextWindow.WriteLine("Hello World!")
For i = 0 To 10
  Goto up
  Program.Delay(1000)
EndFor

3. Still using program number 1, but with slight modification. Is it i incremented each time i is printed out to the textwindow window?

Up:
i = i + 1
TextWindow.WriteLine(i)
For i = 0 To 10
  Goto up
  Program.Delay(1000)
EndFor

4. Still using program number 1, but with slight modification. Is it "Hello World" string printed out to the screen?

Up:
i = i + 1
TextWindow.WriteLine(i)
For i = 0 To 10
  Goto up
  TextWindow.WriteLine("Hello World")
EndFor

Ok, thats it. I hope you enjoy the questions.

SMALL BASIC: Folder-subfolder iteration

Hello, SMALL BASIC programmer, welcome.

In this tutorial, we will learn about how to get all folders and all sub folders started from our first folder or first door.

This tutorial implements tree diagram traversing algorithm.

There are two types of how to draw a tree diagram:
1. Using vertex,vertex label, link, and link label.
2. Using hierarchy

You can train a lot with tree diagram with folder-subfolder iteration. Yeah, you can learn a lot with folder-subfolder.

You can also implement this to full mesh topology, where full mesh topology is a type of tree diagram topology each of the descendat connects to other descendent.


So, okay, now how to solve the tree diagram traversing algorithm?
It essentially, opening first door and write the next door, recursively; loop back from the beginning again.



SMALL BASIC: Removing unwanted element

Hi, SMALL BASIC programmer, welcome.

In this tutorial, we will learned about removing unwanted element from an array, in this case from a single line multi colomn (SLMC) array not multi line multi colomn (MLMC). So, watch it.

For example, we want to remove element that have value FAILED from an SLMC array.

There are couples method that you can do to this, but I prefer this. If you do this differently, you will get different experience.

x[0] = "SUCCESS"
x[1] = "FAILED"
x[2] = "SUCCESS"
x[3] = "SUCCESS"

k = 0
m = 0
For i = 0 To 3
  If x[i] = "FAILED" Then
    x_l = Array.GetItemCount(x) - 1
    'Move the front and the back
    For j = i + 1 to x_l
      y[k] = x[j]
      k = k + 1
    EndFor
    For l = i - 1 To 0
      z[m] = x[l]
      m = m + 1
    EndFor
    'Merge y and z, merge y to the back of z
    '1st. Search the length of z
    z_l = Array.GetItemCount(z) - 1
    '2nd. And then transfer one by one
    For transfer_index = 0 To z_l
      y[Array.GetItemCount(y)] = z[transfer_index]
    EndFor
  EndIf
EndFor

TextWindow.WriteLine(y)
 
   
   

SMALL BASIC: Checking elements are same value or not

Hi, Small Basic programmer, welcome.

In this tutorial we will learned about a program that check whether values of colomn of the same row of an array are same or not same using SMALL Basic.

This is useful sometimes when you program and few situations.

So here is the program:
y[0] = "Failed"
y[1] = "Success"
y[2] = "Failed"

y_l = Array.GetItemCount(y) - 1
For i = 0 To y_l
  If y[i] = "Success" Then
    TextWindow.WriteLine("Not all failed")
    Goto quitloop
  Else
    If i = y_l then
      TextWindow.WriteLine("All failed")
      EndIf
      EndIf
EndFor
  quitloop: