Showing posts with label My-note=programming. Show all posts
Showing posts with label My-note=programming. Show all posts

Saturday 28 December 2013

OOP ala gua

tumbuhan punya daun, batang, bunga, buah

tinggi batang awalnya = 0
warna daun awal = .....

tumbuhan bisa berkembang ditandai dengan perpanjangan batang.
tumbuhan bisa layu, ditandai dengan warna dauh yang kuning.
method adalah
tumbuh()
layu()
segar()

1. Membuat kelas
Contoh: Kelas tumbuhan

2. Membuat objek
Contoh: mawar
bunga.tinggi = 0
bunga.

3. memasukkan/menggolongkan objek ke suatu kelas

Dahulu kita hanya mengenal obyek: benda, manusia, tumbuh-tumbuhan dan hewan, tapi sekarang sejak berdirinya dunia komputer, kita mengenal obyek: file, text, etc :D

My note: Batch programming

Echo command
Echo = display it to command line screen 
Used to display something on the command-line screen.

Gini, jika echo on (default), semua command akan di echo (ditampilkan di layar).
Jika echo off, semua command tidak akan di echo, tapi, command echo off nya tetap ditampilkan. Apa solusi? tambahkan @ di depan command echo off itu.
 

Contoh:
Echo Hello World!

Set command
Set command without refinement (polos) = used to compose a variable

Set command with /a ->used to enter


Set with /P= used to display and input a value to a variable.
 prompt

Contoh:
set /P enter your password

Pause
Press any key to enter..

Goto
:label

Exit

Sunday 22 December 2013

Microsoft Excel Basic Coding

Yang berhubungan dengan Cell

How to refer to one cell in a particular sheet?
Style1: Using range property
Use: Range property + A1 Notation

Example:

Sub onecell()
    Sheet1.Range("A1").Select
End Sub

Style 2: Using index number
Use: Row Index number, Column index number, cells property
Example:
Sub onecell()
    Sheet1.cells(1,1).Select
End Sub

Note: Also good for used with looping statement.

How to refer to one cell that relative to another active cell? (Relativity)
Use: offset property
Example:
This can be both do to style 1 and style 2

Sub onecell()
    Sheet1.cells(1,1).offset(1,2).Value = 10
end sub


How to refer to cells (more than one cell)
Style1: Using A1 Notation
Use: Range property + A1 Notation
Example:
Sub manycells1()
    Sheet1.Range("A1:A3").Select
End Sub

Style2: Using Range Object
Use: dim, set, object variable

Example:
sub manycells2()
    dim a as range
    set a = sheet1.range("A1:A3")
    a.select
end sub

Style3: Using shortcut notation
As the title implies, this is the shorcut of using Range word. That is, you don't have to type word Range or use Quotation marks anymore for shortcuts.

Use: [A1:A2] or [MyRange] if you have define those cells in name manager.

Example:
Sub manycells()
    Sheet1.[MyRange].Select
End sub

Note: You don't have to type word "Range" or use Quotation marks after Sheet1.

How to refer to all cell in a particular sheet
Use: cells
Example:
sub allcell()
    sheet1.cells.activate
end sub


Yang berhubungan dengan Sheet

How to refer a one sheet?
Style 1:
Use Worksheets name
Example:
Sub onesheet()
    Worksheets("sheet2").Select
End Sub

Style2: 
Use Worksheets index number
Example:
Sub onesheet()
    Worksheets(2).Select
End Sub

How to refer to more than one sheets?
Use: worksheets property and array function
Example:
Sub several_sheets()
    worksheets(Array("Sheet1","Sheet2")).Select
end sub

How to refer to all sheet in a workbook?
Use: Worksheets property without specifications.
Example:
Sub all_sheet()
    Worksheets.Select
End Sub

Yang berhubungan dengan Workbook

How to create a new workbook
Use: workbooks.add
Example:
Sub AddOne()
    Workbooks.add
End sub

How to activate a workbook
Use: workbooks properties and book name(for i.e. : "book1")
Example:
Sub ActivateOne()
    Workbooks("book1").activate
End sub

How to open a workbook
Use: Open method and, path to the file
Example:
Sub OpenUp()
    Workbooks.Open ("C:\Mybook")
End Sub
How to save a workbook
Use: saves or save and path to the file

Example:
Sub Save()
    Workbooks("Mybook").SaveAs ("E:\Mybook")
End Sub

Now you have enough tool to do these tasks:
1. Copy and paste from sheet1 to sheet2
Untuk pemilihan sel saya lebih prefer menggunakan keyword range daripada cells (lebih praktis) meskipun untuk seleksi satu sel saja saya tetap menggunakan keyword range.

Sub copy_paste()
    Sheet1.Range("A1:A2").Copy
    Sheet2.Range("A1:A2").PasteSpecial
End Sub

Well, you can implement those with macro recording though.

2. Adding a comment on a cell or cells
Sub

Sunday 1 December 2013

Cookbook of Assembly

1. Kita akan modifikasi register berikut ini: AX, DS, CS, IP  menggunakan perintah register, assemble, dump, enter, trace command.

register: to display the content of our CPU register
assemble: to entering code to our code segment
dump: to display the content of our data segment
enter: to fill/change the content of our data segment
trace: to execute a code one at a time.




2. Semua angka yang dimasukkan kedalam debugger adalah hexadecimal.

3. Segment register = DS, ES, SS, CS

DS= data segment
ES = extra segment
SS =
CS = Code segment (place of code)

Flags: NV, VP, EI, PL, NZ, NA, PO, NC


Langkah 1: melihat isi register untuk pertama kali
How?
-r
What you see?
AX, BX, CX, DX, ......
AX= Acummulator register (Arithmetic and logic)
DX = Data register (DH + DL)

Int 21: print character to screen
Int 20: terminate program

-h
contoh: 
-n name

Langkah 2: mengisi register AX dengan nilai 1234
How?
- r ax
:1234

Langkah 3: Melihat (dump) isi register DS (untuk pertama kali)
How?
-d ds:0000
ds:0000
0B3C:0000

What you see?
Isi dari memory dari 0B3C:0000 sampai 0B3C:0070 dan printable ASCII character-nya
. --> unprintable ASCII character

Langkah 4: Memasukkan(enter)/mengubah data di data segment
How?
-e ds:0000


Langkah 5: Melihat kembali hasil perubahan yang tlah dilakukan
How?
-d ds:0000

Langkah 6: Put some code to the machine
How?
-a cs
Watch IP address (next instruction to be fetched)
so
-a cs:100
mov [0], ax

Langkah 7: trace
-t
what?
IP pointer from 0100 to 0103 is change


Langkah 8: Periksa isi konten register ds
-d ds:0000

What you see?
isi dari register ds:0000 berubah menjadi Langkah 4

Langkah 9: Assemble another code
- a cs:0000
mov ax, [0]

Langkah 10: Ubah register IP (Instruction Pointer)
-r IP



1. Ketik a
2. Setelah tanda - muncul, ketik baris berikut ini satu baris per satu baris:
mov ax,B800
mov ds,ax
mov byte[0F9E],24
int 20
3. Ketik return/enter dua kali, untuk keluar dari editor
4. Ketik g untuk menjalankan program

Keterangan: