• Tidak ada hasil yang ditemukan

Labsheet Pemrograman Lanjut Elektro

N/A
N/A
Protected

Academic year: 2017

Membagikan "Labsheet Pemrograman Lanjut Elektro"

Copied!
38
0
0

Teks penuh

(1)

S e m e s t e r 2 U n d e rsta n d ID E D e lp h i and P ro g ra m A lg o rith m

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 1 o f 1 0

1 . C o m p e t e n c y

A f t e r p r a c tic in g , s tu d e n ts w ill h a v e c o m p e te n c ie s : k n o w in g , u n d e r s ta n d in g a n d a p p ly in g I D E ( In te g r a te d D e v e lo p m e n t E n v ir o n m e n t) D e lp h i in c o m p u te r p r o g r a m m in g .

2 . S u b C o m p e t e n c i e s

A f t e r p r a c tic in g , s tu d e n ts w ill h a v e s u b c o m p e te n c ie s : a. K n o w in g p a r ts o f ID E D e lp h i.

b. U n d e r s ta n d f u n c tio n a n d p r o c e d u r e o f e a c h p a r t o f ID E D e lp h i. c. A p p ly in g ID E D e lp h i to m a k e a s im p le p r o g r a m .

3 . I n t r o d u c t i o n

3 .1 . K n o w i n g I D E D e l p h i

ID E D e lp h i c o n s is ts o f 6 m a in p a rts , w h ic h a re : M e n u , S p e e d B a r, C o m p o n e n t P a le tte , F o rm D e s ig n e r, C o d e E d ito r a n d O b je c t In s p e c to r.

S p e e d B a r M e n u C o m p o n e n t P a lette

O b je c t In s p e c to r C o d e E d ito r F o rm D e s ig n e r

(2)

S e m e s t e r 2 U n d e rsta n d ID E D e lp h i and P ro g ra m A lg o rith m

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 2 o f 1 0

a. M a in M e n u

D e lp h i M a in M e n u h a v e s im ila r f u n c tio n m e m ilik i k e g u n a a n s e p e r ti m e n u p a d a a p lik a s i W in d o w s la in n y a . F ro m th is m e n u , y o u c a n o p e n o r s a v e a p r o g r a m , r u n n in g a n d s e a r c h in g p r o g r a m , e tc . S h o rtly , e v e r y th in g th a t c o n n e c te d w ith I D E D e lp h i c a n b e c a lle d v ia m a in m e n u .

F ile E d it S e a r c h V ie w P r o je c t R u n C o m p o n e n t D a t a b a s e T o o ls W in d o w H e lp

b . S p e e d B a r

S p e e d B a r o r t o o lb a r c o n ta in s e t o f b u tto n th a t h a v e s a m e fu n c tio n w ith m o s tly ite m m e n u .

c. C o m p o n e n t P a le tt e

C o m p o n e n t P a le tt e c o n ta in s s e t o f ic o n th a t r e p r e s e n ts c o m p o n e n t s o f V C L

(Visual Component Library).

V C L is c o m p o n e n t t h a t c a n b e u s e d to b u ild a n a p p lic a tio n .

S ta n d a r d A d d it io n a l W i n 3 2 ] S y s te m D a ta A c c e s s D a ta C o n tro ls ] d b E x o r e s s ] D a ta S n a o B D E ^ I *

d. F o rm D e s ig n e r

F o rm D e s ig n e r is a p la c e to d e s ig n w in d o w s a p p lic a tio n . T h e D e s ig n is p la c e m e n t o f c o m p o n e n t s fr o m C o m p o n e n t P a le tte .

C r e a t e d b y : P r o h i b i t e d t o r e p r o d u c e i n p a r t o r w h o l e d o c u m e n t w i t h o u t R e v i e w e d b y : S a m s u l H a d i p e r m i s s i o n o f t h e F a c u l t y o f E n g i n e e r i n g , Y o g y a k a r t a S t a t e

(3)

S e m e s t e r 2 U n d e rsta n d ID E D e lp h i and P ro g ra m A lg o rith m

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 3 o f 1 0

2

k F o r m i

HD®

e. C o d e E d ito r

C o d e E d ito r is p la c e to w r ite p r o g r a m in P a s c a l L a n g u a g e . C o d e e d ito r h a s a C o d e In s p e c to r, s o th a t w e d o n ’t h a v e to w r ite w h o le in s tr u c tio n . D e lp h i h a s w r ite a b a s ic s tr u c tu r e o f a p r o g r a m . L o o k a t th e p ic tu r e b e lo w :

§3 U n it 1 . pas

► j T F o rm l

+ _ l V a r ia b le s /C o n s ta n ts + __ | U s e s

U n it l ' T

unit Unitl; A

interface

uses

Windows, Messages, SysUtils, Dialogs;

Variants,

type

TForml = class(TForm)

private

{ P r i v a t e d e c l a r a t i o n s } public

{ P u b l i c d e c l a r a t i o n s }

end;

-|j«i A

1: 1 M o d ifie d In s e rt

(4)

S e m e s t e r 2 U n d e rsta n d ID E D e lp h i and P ro g ra m A lg o rith m

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 4 o f 1 0

f. O b je c t In s p e c to r

T h e O b je c t In s p e c to r is th e c o n n e c t io n b e tw e e n y o u r a p p lic a tio n 's v is u a l a p p e a r a n c e a n d th e c o d e th a t m a k e s y o u r a p p lic a tio n ru n .

T h e O b je c t In s p e c to r e n a b le s y o u to :

- s e t d e s ig n - tim e p r o p e r tie s f o r c o m p o n e n t s y o u h a v e p la c e d o n a fo r m (o r f o r th e fo r m its e lf).

- C r e a te a n d h e lp y o u n a v ig a te th r o u g h e v e n t h a n d le rs . - F ilt e r v is ib le p r o p e r tie s a n d e v e n ts .

C

O b j e c t I n s p e c t o r

Fornnl T F o rnn l

P r o p e r t i e s ' ^ ^ n ts |

A c t io n A

A c tiv e C o n tr o l

A lig n a lN o n e A lp h a B le n d F a ls e A lp h a B le n d V a k 2 5 5

E l A n c h o r s [ a k L e f t, a k T o p ] A u to S c ro ll T ru e

A u to S iz e F a ls e B iD iM o d e b d L e ft T o F iig h t E B o r d e r lc o n s [b iS y s te m M e n u ,

B o rd e rS tyie b s S iz e a b le B o r d e r W id th 0 C a p tio n IBWTmTI C lie n tH e ig h t 2 1 7 C lie n tW id th 5 1 6

C o lo r O c l B t n F a c e

E l C o n s tra in ts (T S iz e C o n s tra in v 1

A ll s h o w n

3

O b j e c t I n s p e c t o r

m

l | Fornnl T F o rnn l T | |

1 P ro p e r(je s E v e n t P j ' ' ' ^ )

| A c t io n A

A c tiv e C o n tr o l M e n u O b je c tM e n u lt e O n A c tiv a te O n C a n F le s iz e O n C lic k O n C lo s e O n C lo s e Q u e ry O n C o n s tr a in e d O n C o n te x tP o p i O n C r e a te O n D b lC lic k O n D e a c tiv a te O n D e s tro y O n D o c k D r o p O n D o c k O v e r

IaINt o w ii

T h e O b je c t In s p e c to r h a s tw o p a g e s : - P r o p e r tie s p a g e

- E v e n t s p a g e

O b je c t In s p e c to r ta b s p r o v id e a m e a n s to s w itc h b e tw e e n th e P r o p e r ty p a g e a n d th e E v e n t s p a g e o f th e O b je c t In s p e c to r. T o c h a n g e p a g e s , c lic k th e P r o p e r tie s o r E v e n t s ta b .

C r e a t e d b y : P r o h i b i t e d t o r e p r o d u c e i n p a r t o r w h o l e d o c u m e n t w i t h o u t R e v i e w e d b y : S a m s u l H a d i p e r m i s s i o n o f t h e F a c u l t y o f E n g i n e e r i n g , Y o g y a k a r t a S t a t e

(5)

S e m e s t e r 2 U n d e rsta n d ID E D e lp h i and P ro g ra m A lg o rith m

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 5 o f 1 0

Y o u c a n d is p la y a n d f ilt e r p r o p e r tie s a n d e v e n ts b y c a te g o r y . B y filte r in g th e p r o p e r tie s , y o u c a n r e d u c e th e n u m b e r o f p r o p e r tie s v is ib le in th e O b je c t In s p e c to r a n d f o c u s o n th o s e w h ic h a r e p r im a r ily o f in te r e s t a t th e tim e . Y o u c a n a ls o m o r e e a s ily lo c a te r e la te d p r o p e r tie s b y v ie w in g th e m b y c a te g o r y . F o r e x a m p le , w h e n lo c a liz in g y o u r a p p lic a tio n f o r o th e r c o u n tr ie s , y o u c a n d is p la y o n ly p r o p e r tie s t h a t n e e d to b e lo c a liz e d b y u n c h e c k in g a ll c a te g o r ie s e x c e p t L o c a liz a b le . S e e P r o p e r ty a n d e v e n t c a te g o r ie s in th e O b je c t In s p e c to r.

T h e O b je c t In s p e c to r a ls o in c lu d e s e x p a n d e d in lin e c o m p o n e n t r e fe r e n c e s th a t d is p la y th e p r o p e r tie s a n d e v e n ts o f a r e fe r e n c e d c o m p o n e n t ( o r a s u b c o m p o n e n t) w ith o u t h a v in g to a c tu a lly s e le c t th a t c o m p o n e n t.

Y o u c a n c o n tr o l th e c o lo r s in w h ic h ite m s a p p e a r in th e O b je c t In s p e c to r a n d c h a n g e o p tio n s th a t a llo w y o u to d is p la y a n in s ta n c e list, a s ta tu s b a r, a n d s h o w r e a d - o n ly p r o p e r tie s . T o c h a n g e th e s e s e ttin g s f o r th e O b je c t In s p e c to r, c h o o s e T o o ls |E n v ir o n m e n t O p tio n s , a n d c lic k th e O b je c t In s p e c to r ta b o r r ig h t- c lic k th e O b je c t In s p e c to r a n d c h o o s e P ro p e rtie s .

4 . T o o l s a n d M a t e r i a l s

• P e r s o n a l C o m p u te r

• W in d o w s X P O p e r a tin g S y s te m

• B o r la n d D e lp h i 7

5 . W o r k S a f e t y

a. B e fo r e p r a c tic in g , s tu d e n ts s h o u ld u n d e r s ta n d th e g o a l a n d c o m p e te n c y o f th is p r a c tic e .

b. R e a d a n d u n d e r s ta n d a ll p r o c e d u r e s o f t h is p r a c tic e c a r e fu lly .

c. A lw a y s k e e p d a ta fro m lo s in g c a u s e s b y e x tin g u is h e d e le c tr ic ity .

6 . P r o c e d u r e s

6 .1 . C r e a t i n g S i m p l e P r o g r a m

1. R u n B o r la n d D e lp h i 7 o n y o u r c o m p u te r . C lic k m e n u s ta r t - A ll P r o g r a m s - B o r la n d D e lp h i 7 - D e lp h i 7.

(6)

S e m e s t e r 2 U n d e rsta n d ID E D e lp h i and P ro g ra m A lg o rith m

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 6 o f 1 0

2. ID E D e lp h i w ill lo o k lik e th is :

_ r * * * b f t t e a r » rrm t

• - • Q a l a j. .

C i . # F! ■ ► - I I

1 H r C M t r a t Tb» ? J t

-J_ ^ ~ i | * d a l tda±T*4! V * % S ! * » l i « l r nc t l * » C a r * e f c 1 PC? 1 «1 » • » < « ■ 1 ■! ■ » { » « : > W w * , ^ ^ I f f « i A J » M j ) ■ • « « - • * s i ?

* i a r - « * * L u * * R a j 1

n

m

W aM « * ■ 4 « J C w t n

t » a * * : « * ! » * * * * • D f M r r n

' » • » f m l 1 U U —

M M M t *~

r*> - d i l ^ a c a II •

N * a «

C r e a t e d b y : P r o h i b i t e d t o r e p r o d u c e i n p a r t o r w h o l e d o c u m e n t w i t h o u t R e v i e w e d b y : S a m s u l H a d i p e r m i s s i o n o f t h e F a c u l t y o f E n g i n e e r i n g , Y o g y a k a r t a S t a t e

(7)

S e m e s t e r 2 U n d e rsta n d ID E D e lp h i and P ro g ra m A lg o rith m

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 7 o f 1 0

3. in th e a c tiv e F o rm , c h o o s e c o m p o n e n t B u tto n 1 o n T a b S ta n d a r d a n d p la c e it o n fo r m ju s t lik e p ic tu r e b e lo w :

r »m k j'

k U* k f i » r* mr t *i r » * * « *- *» « « • « •« * . J # ;

. J ' f d & Li J . JL. # ’• * «* ■< M M * * * : V f r S l i M t n w M l f M I Hw- D * f t «a t t Jt I t C >—4 t m m t t m i i l i # r a ► • II I V & H * i A “ «I " • *■; * " i?

• M

*« f M

Ita

( + •

I C tU l 10.4*1 J + J I

! 1 J » « ' »»* * • • • §■ f t * » * ( n »1

V *

UnTMM Hw'

:» >

Allto m

B a a

■ >B u tto n 1

4. S e t e a c h c o m p o n e n t’s p r o p e r tie s b y s e le c tin g c o m p o n e n t firs t, th e n c h o o s e p r o p e r tie s o n O b je c t In s p e c to r, w ith th e v a lu e b e lo w .

K o m p o n e n P r o p e r tie s V a lu e

F o rm 1 C a p tio n P r a k tik M e m b u a t P r o g r a m S e d e r h a n a

B u tto n 1 C a p tio n K lik S a y a !

5. T h e n th e d e s ig n w ill lo o k lik e th is :

(8)

S e m e s t e r 2 U n d e rsta n d ID E D e lp h i and P ro g ra m A lg o rith m

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 8 o f 1 0

6. F ill p r o g r a m c o d e o f B u tto n 1 in tw o w a y s : a ) d o u b le c lic k o n B u tto n 1 , o r b ) s e le c t B u tto n 1 , s e le c t E v e n t s o n O b je c t In s p e c to r, th e n d o u b le c lic k ite m O n C lic k . W r it e th e s e c o d e :

p r o c e d u r e T F o rm 1 .B u tto n 1 C lic k (S e n d e r: T O b je c t);

b e g in

A p p lica tio n .M e s s a g e B o x ('H a lo , Saya baru saja d ik lik ', 'In fo rm a s i', M B_O K o r

M B_IC O N E X C LA M A TIO N );

e n d ;

7. P r o je c t is r e a d y to ru n in th r e e w a y s : a ) C lic k t o o lb a r R u n | R u n , o r c ) p u s h b u tto n F 9 o n k e y b o a r d .

o r b ) v ia m e n u

8. A f t e r p r o g r a m ru n n in g , c lic k o n b u tto n K lik S a y a !’ , th e n a m e s s a g e b o x w ill s h o w e d :

9. S a v e y o u r p r o je c t b y s e le c tin g m e n u F ile | S a v e A ll. D e lp h i w ill s h o w a d ia lo g b o x a n d a s k in g y o u to in s e r t th e n a m e o f u n it in y o u r fo r m . W r ite U L a tih a n 1 .p a s a n d c lic k O K . D e lp h i w ill a g a in s h o w d ia lo g b o x a n d a s k in g

y o u to in s e r t th e n a m e o f y o u r p r o je c t. F ill it w ith

PLatihanl.dpr

a n d c lic k O K .

C r e a t e d b y : P r o h i b i t e d t o r e p r o d u c e i n p a r t o r w h o l e d o c u m e n t w i t h o u t R e v i e w e d b y : S a m s u l H a d i p e r m i s s i o n o f t h e F a c u l t y o f E n g i n e e r i n g , Y o g y a k a r t a S t a t e

(9)

S e m e s t e r 2 U n d e rsta n d ID E D e lp h i and P ro g ra m A lg o rith m

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 9 o f 1 0

(10)

S e m e s t e r 2 U n d e rsta n d ID E D e lp h i and P ro g ra m A lg o rith m

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 1 0 o f 1 0

10 . A lw a y s tr y to s a v e u n it file b e g in w ith le tte r u

________ .pas

a n d s a v e

p r o je c t file b e g in w ith le tte r p

________ .dpr

. it is u s e fu l to d is tin g u is h

b e tw e e n u n it file w ith p r o je c t file .

11 . S a v e d p r o je c t w ill c r e a tin g a lo t o f file s , b u t 3 m a in file s a re :

• PLatihanl.dpr

, c o n ta in m a in p r o g r a m o f y o u r a p p lic a tio n .

• ULatihan.pas

, u n it th a t w ill h a n d le e v e n ts o n fo r m .

• ULatihan.dfm

, lis t o f c o m p o n e n t s a n d t h e ir p r o p e r tie s in th e fo r m ( s ) .

7 . D i s c u s s i o n

a. C r e a te a p r o g r a m w ith 2 b u tto n s . C h a n g e p r o p e r ty C a p tio n o f th o s e b u tto n s b e c o m e ‘ B ir u ’ d a n ‘ M e r a h ’ . T h e r e q u e s t a re , ‘ B ir u ’ , th e n fo r m c o lo r w ill c h a n g e in to b lu e a n d if w e c lic k ‘M e r a h ’ b u tto n , th e n fo r m c o lo r w ill c h a n g e in to re d .

R u n n in g p r o g r a m w ill lo o k lik e th is p ic tu re :

b. P u t th r e e T b u tto n c o m p o n e n t s a n d a T e d it c o m p o n e n t o n a fo r m . W h e n B u tto n 1 p r e s s e d , t e x t o n E d it1 w ill c h a n g e in to ‘ P e m r o g r a m a n ’ . W h e n B u tto n 2 p r e s s e d , te x t o n E d it1 w ill c h a n g e in to ‘ K o m p u te r ’ . L a s t, w h e n B u tto n 3 p r e s s e d , te x t o n E d it1 w ill b e e m p ty .

R u n n in g p r o g r a m w ill lo o k lik e th is p ic tu re :

M e r u b a h I s i T e k s

[I B u t t o n i ; B u tt o n 2 B u tt o n 3

E d irl

C r e a t e d b y : P r o h i b i t e d t o r e p r o d u c e i n p a r t o r w h o l e d o c u m e n t w i t h o u t R e v i e w e d b y : S a m s u l H a d i p e r m i s s i o n o f t h e F a c u l t y o f E n g i n e e r i n g , Y o g y a k a r t a S t a t e

(11)

$

S e m e s t e r 2 D a ta T y p e in P ro g ra m m in g

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 1 o f 1 5

1 . C o m p e t e n c y

A f t e r p r a c tic in g , s tu d e n ts w ill h a v e c o m p e te n c ie s : k n o w , u n d e r s ta n d a n d a p p ly in g D a ta T y p e a n d a p p lic a tio n in P r o g r a m m in g .

2 . S u b C o m p e t e n c i e s

A f t e r p r a c tic in g , s tu d e n ts w ill h a v e s u b c o m p e te n c ie s : a. K n o w in g p a r ts o f d a ta ty p e .

b . U n d e r s ta n d f u n c tio n a n d p r o c e d u r e o f d a ta ty p e . c. A p p ly in g d a ta ty p e in p r o g r a m m in g .

3 . I n t r o d u c t i o n 3 .1 . V a r i a b l e

W e o fte n u s e v a r ia b le s in c o m p u te r p r o g r a m m in g . V a r ia b le s a r e s im p ly a p la c e to k e e p d a ta .

S y n t a x o f v a r ia b le d e c la r a tio n o n D e lp h i is:

v a r

nama_ var

iabel: tipe_ variabel;

e x a m p le :

v a r

i: in te g e r;

T o d e c la r e s e v e r a l v a r ia b le s w ith d iffe r e n t d a ta ty p e , w e o n ly h a v e to w r ite k e y w o r d v a r o n c e , lik e th is :

v a r

i: in te g e r; j: re a l;

k: c h a r;

H e r e a n o th e r s a m p le o f s e v e r a l v a r ia b le s w ith s a m e d a ta ty p e s :

v a r

i, j , k: in te g e r; a , b, c: c h a r;

(12)

S e m e s t e r 2 D a ta T y p e in P ro g ra m m in g

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 2 o f 1 5

V a r ia b le n a m e o n D e lp h i m u s t f o llo w th e s e ru le s :

• N a m e o f v a r ia b le m a x im u m c o n s is t o f 6 3 c h a r a c te r s . If v a r ia b le h a s m o r e th a n 6 3 c h a r a c te r s , c o m p ile r w ill a b a n d o n th e r e m a in d e r c h a r a c te r .

• N a m e o f v a r ia b le c a n o n ly c o n ta in c h a r a c te r s , n u m b e r s , u n d e r s c o r e s , a n d m u s t n o t b e g in w ith n u m b e r.

• K e y w o r d o f D e lp h i c a n n o t b e a v a r ia b le n a m e , f o r e x a m p le i f, e l s e, f o r, e tc .

3 .2 . D a t a T y p e

A ty p e is e s s e n tia lly a n a m e f o r a k in d o f d a ta . W h e n y o u d e c la r e a v a r ia b le y o u m u s t s p e c ify its ty p e , w h ic h d e te r m in e s th e s e t o f v a lu e s th e v a r ia b le c a n h o ld a n d th e o p e r a tio n s t h a t c a n b e p e r fo r m e d o n it. E v e r y e x p r e s s io n r e tu r n s d a ta o f a p a r tic u la r ty p e , a s d o e s e v e r y fu n c tio n . M o s t f u n c tio n s a n d p r o c e d u r e s r e q u ir e p a r a m e te r s o f s p e c ific ty p e s . In D e lp h i, it c o n s is ts of:

• In te g e r d a ta ty p e s .

• R e a l d a ta ty p e s .

• B o o le a n d a ta ty p e s .

• C h a r a c t e r d a ta ty p e s .

• S tr in g d a ta ty p e s .

a. In te g e r ty p e s

A n in te g e r ty p e r e p r e s e n ts a s u b s e t o f th e w h o le n u m b e rs . T h e g e n e r ic in te g e r ty p e s a r e In te g e r a n d C a rd in a l; u s e th e s e w h e n e v e r p o s s ib le , s in c e th e y r e s u lt in th e b e s t p e r fo r m a n c e f o r th e u n d e r ly in g C P U a n d o p e r a tin g s y s te m . T h e ta b le b e lo w g iv e s t h e ir r a n g e s a n d s to r a g e f o r m a t s f o r th e c u r r e n t 3 2 - b it D e lp h i c o m p ile r .

F u n d a m e n ta l in te g e r ty p e s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

T y p e B it R a n g e F o r m a t

S h o r tin t 8 b it - 1 2 8 .. 1 2 7

S m a llin t 1 6 b it - 3 2 7 6 8 .. 3 2 7 6 7

L o n g in t 3 2 b it - 2 1 4 7 4 8 3 6 4 8 .. 2 1 4 7 4 8 3 6 4 7

B y te 8 b it 0 .. 2 5 5

W o r d 1 6 b it 0 .. 6 5 5 3 5

C r e a t e d b y : P r o h i b i t e d t o r e p r o d u c e i n p a r t o r w h o l e d o c u m e n t w i t h o u t R e v i e w e d b y : S a m s u l H a d i p e r m i s s i o n o f t h e F a c u l t y o f E n g i n e e r i n g , Y o g y a k a r t a S t a t e

(13)

$

S e m e s t e r 2 D a ta T y p e in P ro g ra m m in g

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 3 o f 1 5

G e n e r ic in te g e r ty p e s f o r 3 2 - b it im p le m e n ta

T y p e B it R a n g e F o r m a t

In te g e r ( D e lp h i 1) 1 6 b it - 3 2 7 6 8 .. 3 2 7 6 7 C a r d in a l ( D e lp h i 1) 1 6 b it 0 .. 6 5 5 3 5

In te g e r ( D e lp h i 2 s /d 7 ) 3 2 b it - 2 1 4 7 4 8 3 6 4 8 .. 2 1 4 7 4 8 3 6 4 7 C a r d in a l ( D e lp h i 2 s /d 7 ) 3 2 b it 0 .. 2 1 4 7 4 8 3 6 4 7

io n s o f D e lp h i

b. R e a l ty p e s

A re a l t y p e d e fin e s a s e t o f n u m b e r s th a t c a n b e r e p r e s e n te d w ith flo a t in g - p o in t n o ta tio n . T h e ta b le b e lo w g iv e s th e ra n g e s a n d s to r a g e

o r m a t s f o r th e f u n d a m e n ta l re a l ty p e s .

T y p e S iz e in B it R a n g e F o r m a t S ig n ific a n t

D ig it

R e a l 6 b it 2 .9 * 1 0 -39 .. 1 .7 * 1 0 38 1 1 -1 2

S in g le 4 b it 1 .5 * 1 0 -45 .. 3 . 4 * 1 0 38 7 -8

D o u b le 8 b it 5 .0 * 1 0 -324 .. 1 .7 * 1 0 308 1 5 -1 6

E x te n d e d 1 0 b it

3 4*1 q

-4932

^ 1*1

q

4932

1 9 -2 0

C o m p 8 b it 63 63 1 9 -2 0

C u r r e n c y 8 b it - 9 2 2 3 3 7 2 0 3 6 8 5 4 7 7 .5 8 0 8 .. 9 2 2 3 3 7 2 0 3 6 8 5 4 7 7 .5 8 0 7

1 9 -2 0

c. B o o le a n ty p e s

T h e f o u r p r e d e fin e d B o o le a n ty p e s a r e B o o le a n , B y te B o o l, W o r d B o o l, a n d L o n g B o o l. B o o le a n is th e p r e fe r r e d ty p e . T h e o th e r s e x is t to p r o v id e c o m p a tib ility w ith o t h e r la n g u a g e s a n d o p e r a tin g s y s te m lib ra rie s .

A B o o le a n v a r ia b le o c c u p ie s o n e b y te o f m e m o ry , a B y te B o o l v a r ia b le a ls o o c c u p ie s o n e b y te , a W o r d B o o l v a r ia b le o c c u p ie s tw o b y te s (o n e w o rd ), a n d a L o n g B o o l v a r ia b le o c c u p ie s f o u r b y te s (tw o w o r d s ) .

B o o le a n v a lu e s a r e d e n o te d b y th e p r e d e fin e d c o n s ta n ts T r u e a n d F a ls e . T h e fo llo w in g r e la tio n s h ip s h o ld .

D a ta T y p e M e m o r i n e e d e d

B o o le a n 1 b y te

B y te B o o l 1 b y te

W o r d B o o l 2 b y te (1 w o r d )

L o n g B o o l 4 b y te (2 w o r d )

(14)

S e m e s t e r 2 D a ta T y p e in P ro g ra m m in g

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 4 o f 1 5

d. C h a r a c te r ty p e s

T h e f u n d a m e n ta l c h a r a c te r t y p e s a r e A n s iC h a r a n d W id e C h a r . A n s iC h a r v a lu e s a r e b y te - s iz e d (8 - b it) c h a r a c te r s o r d e r e d a c c o r d in g to th e lo c a le c h a r a c te r s e t w h ic h is p o s s ib ly m u ltib y te . A n s iC h a r w a s o r ig in a lly m o d e le d a f t e r th e A N S I c h a r a c te r s e t ( th u s its n a m e ) b u t h a s n o w b e e n b r o a d e n e d to r e fe r to th e c u r r e n t lo c a le c h a r a c te r s e t.

W id e C h a r c h a r a c te r s u s e m o r e th a n o n e b y te to r e p r e s e n t e v e r y c h a r a c te r . In th e c u r r e n t im p le m e n ta tio n s , W id e C h a r is w o r d - s iz e d ( 1 6 - b it) c h a r a c te r s o r d e r e d a c c o r d in g to th e U n ic o d e c h a r a c te r s e t (n o te t h a t it c o u ld b e lo n g e r in f u t u r e im p le m e n ta tio n s ) . T h e fir s t 2 5 6 U n ic o d e c h a r a c te r s c o r r e s p o n d to th e A N S I c h a r a c te r s .

N o te

O n L in u x , w c h a r _ t w id e c h a r is 3 2 b its p e r c h a r a c te r . T h e 1 6 - b it U n ic o d e s ta n d a r d t h a t D e lp h i W id e C h a r s s u p p o r t is a s u b s e t o f th e 3 2 - b it U C S s ta n d a r d s u p p o r te d b y L in u x a n d th e G N U lib ra rie s . D e lp h i W id e C h a r d a ta m u s t b e w id e n e d to 3 2 b its p e r c h a r a c te r b e fo r e it c a n b e p a s s e d to a n O S fu n c tio n a s w c h a r _ t.

T h e g e n e r ic c h a r a c te r t y p e is C h a r, w h ic h is e q u iv a le n t to A n s iC h a r . B e c a u s e th e im p le m e n ta tio n o f C h a r is s u b je c t to c h a n g e , it's a g o o d id e a to u s e th e s ta n d a r d fu n c tio n S iz e O f r a th e r th a n a h a r d - c o d e d c o n s ta n t w h e n w r itin g p r o g r a m s t h a t m a y n e e d to h a n d le c h a r a c te r s o f d iffe r e n t s iz e s .

A s tr in g c o n s ta n t o f le n g th 1, s u c h a s 'A ', c a n d e n o te a c h a r a c te r v a lu e . T h e p r e d e fin e d f u n c tio n C h r r e tu r n s th e c h a r a c te r v a lu e f o r a n y in te g e r in th e r a n g e o f A n s iC h a r o r W id e C h a r ; f o r e x a m p le , C h r ( 6 5 ) r e tu r n s th e le tte r A .

C h a r a c te r v a lu e s , lik e in te g e r s , w r a p a r o u n d w h e n d e c r e m e n te d o r in c r e m e n te d p a s t th e b e g in n in g o r e n d o f t h e ir r a n g e ( u n le s s r a n g e - c h e c k in g is e n a b le d ) . F o r e x a m p le , a ft e r e x e c u tio n o f th e c o d e

v a r

L e tte r: C h a r; I: In te g e r; b e g in

C r e a t e d b y : P r o h i b i t e d t o r e p r o d u c e i n p a r t o r w h o l e d o c u m e n t w i t h o u t R e v i e w e d b y : S a m s u l H a d i p e r m i s s i o n o f t h e F a c u l t y o f E n g i n e e r i n g , Y o g y a k a r t a S t a t e

(15)

S e m e s t e r 2 D a ta T y p e in P ro g ra m m in g

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 5 o f 1 5

L e tte r := H ig h ( L e tte r ) ; f o r I := 1 to 6 6 d o

In c ( L e tte r) ;

e n d;

L e tte r h a s th e v a lu e A (A S C II 6 5 ).

e. S tr in g ty p e s

A s tr in g r e p r e s e n ts a s e q u e n c e o f c h a r a c te r s . D e lp h i s u p p o r ts th e f o llo w in g p r e d e fin e d s tr in g ty p e s .

S tr in g ty p e s

T y p e M a x im u m le n g th M e m o r y r e q u ir e d U s e d f o r

S h o r tS tr in g 2 5 5 c h a r a c te r s 2 to 2 5 6 b y te s b a c k w a r d c o m p a tib ility

A n s iS tr in g ~ 2 A31 c h a r a c te r s 4 b y te s to 2 G B 8 - b it ( A N S I) c h a r a c te r s , D B C S A N S I, M B C S A N S I, e tc .

W id e S tr in g ~ 2 A 3 0 c h a r a c te r s 4 b y te s to 2 G B U n ic o d e c h a r a c te r s ; m u lt i- u s e r s e r v e r s a n d m u lt i- la n g u a g e a p p lic a tio n s

A n s iS tr in g , s o m e tim e s c a lle d th e lo n g s tr in g , is th e p r e fe r r e d ty p e f o r m o s t p u r p o s e s .

S tr in g ty p e s c a n b e m ix e d in a s s ig n m e n ts a n d e x p r e s s io n s ; th e c o m p ile r a u t o m a tic a lly p e r fo r m s r e q u ir e d c o n v e r s io n s . B u t s tr in g s p a s s e d b y r e fe r e n c e to a f u n c tio n o r p r o c e d u r e (a s v a r a n d o u t p a r a m e te r s ) m u s t b e o f th e a p p r o p r ia te ty p e . S tr in g s c a n b e e x p lic itly c a s t to a d iffe r e n t s trin g t y p e (s e e T y p e c a s ts ) .

T h e r e s e r v e d w o r d s tr in g f u n c tio n s lik e a g e n e r ic ty p e id e n tifie r . F o r e x a m p le ,

v a r S : s tr in g ;

c r e a te s a v a r ia b le S th a t h o ld s a s tr in g . In th e d e fa u lt { $ H + } s ta te , th e c o m p ile r in te r p r e ts s tr in g ( w h e n it a p p e a r s w ith o u t a b r a c k e te d n u m b e r a f t e r it) a s A n s iS tr in g . U s e th e { $ H - } d ir e c tiv e to tu r n s tr in g in to S h o r tS tr in g .

T h e s ta n d a r d f u n c tio n L e n g th r e tu r n s th e n u m b e r o f c h a r a c te r s in a s trin g . T h e S e tL e n g th p r o c e d u r e a d ju s ts th e le n g th o f a s tr in g . C o m p a r is o n o f s tr in g s is d e fin e d b y th e o r d e r in g o f th e c h a r a c te r s in c o r r e s p o n d in g p o s itio n s . B e tw e e n s tr in g s o f u n e q u a l le n g th , e a c h c h a r a c te r in th e lo n g e r s tr in g w it h o u t a c o r r e s p o n d in g c h a r a c te r in th e s h o r te r s tr in g t a k e s o n a

(16)

$

S e m e s t e r 2 D a ta T y p e in P ro g ra m m in g

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 6 o f 1 5

g r e a te r - th a n v a lu e . F o r e x a m p le , " A B " is g r e a te r th a n "A "; t h a t is, 'A B ' > 'A ' r e tu r n s T ru e . Z e r o - le n g th s tr in g s h o ld th e lo w e s t v a lu e s .

Y o u c a n in d e x a s tr in g v a r ia b le ju s t a s y o u w o u ld a n a r ra y . If S is a s trin g v a r ia b le a n d i a n in te g e r e x p r e s s io n , S [i] r e p r e s e n ts th e ith c h a r a c te r - - o r , s tr ic tly s p e a k in g , th e ith b y te - - in S. F o r a S h o r tS tr in g o r A n s iS tr in g , S [i] is o f ty p e A n s iC h a r ; f o r a W id e S tr in g , S [i] is o f ty p e W id e C h a r . F o r s in g le - b y t e ( W e s te r n ) lo c a le s , M y S tr in g [2 ] := 'A '; a s s ig n s th e v a lu e A to th e s e c o n d c h a r a c te r o f M y S trin g . T h e f o llo w in g c o d e u s e s th e s ta n d a r d A n s iU p p e r C a s e fu n c tio n to c o n v e r t M y S tr in g to u p p e r c a s e .

v a r I: In te g e r;

b e g i n

I := L e n g th ( M y S tr in g ) ; w h ile I > 0 d o

b e g i n

M y S tr in g [I] := A n s iU p p e r C a s e ( M y S tr in g [I]) ; I := I - 1;

e n d;

e n d;

B e c a r e fu l in d e x in g s tr in g s in th is w a y , s in c e o v e r w r itin g th e e n d o f a s tr in g c a n c a u s e a c c e s s v io la tio n s . A ls o , a v o id p a s s in g lo n g - s tr in g in d e x e s a s v a r p a r a m e te r s , b e c a u s e th is r e s u lts in in e ffic ie n t c o d e .

Y o u c a n a s s ig n th e v a lu e o f a s tr in g c o n s t a n t - - o r a n y o t h e r e x p r e s s io n th a t r e tu r n s a s tr in g - - t o a v a r ia b le . T h e le n g th o f th e s tr in g c h a n g e s d y n a m ic a lly w h e n th e a s s ig n m e n t is m a d e . E x a m p le s :

M y S tr in g := 'H e llo w o r ld !'; M y S tr in g := 'H e llo ' + 'w o rld '; M y S tr in g := M y S tr in g + '!';

M y S tr in g := ' '; { s p a c e } M y S tr in g := ''; { e m p ty s tr in g }

3 . 3 . C o n s t a n t s

S e v e r a l d iffe r e n t la n g u a g e c o n s tr u c t io n s a r e r e fe r r e d to a s " c o n s ta n ts " . T h e r e a r e n u m e r ic c o n s ta n ts ( a ls o c a lle d n u m e r a ls ) lik e 17 , a n d s tr in g c o n s ta n ts ( a ls o c a lle d c h a r a c te r s tr in g s o r s tr in g lite r a ls ) lik e 'H e llo w o r ld !'. E v e r y

C r e a t e d b y : P r o h i b i t e d t o r e p r o d u c e i n p a r t o r w h o l e d o c u m e n t w i t h o u t R e v i e w e d b y : S a m s u l H a d i p e r m i s s i o n o f t h e F a c u l t y o f E n g i n e e r i n g , Y o g y a k a r t a S t a t e

(17)

S e m e s t e r 2 D a ta T y p e in P ro g ra m m in g

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 7 o f 1 5

e n u m e r a te d ty p e d e fin e s c o n s ta n ts th a t r e p r e s e n t th e v a lu e s o f t h a t ty p e . T h e r e a r e p r e d e fin e d c o n s ta n ts lik e T r u e , F a ls e , a n d n il. F in a lly , t h e r e a re c o n s ta n ts th a t, lik e v a r ia b le s , a r e c r e a te d in d iv id u a lly b y d e c la r a tio n .

D e c la r e d c o n s ta n ts a r e e ith e r tr u e c o n s ta n ts o r ty p e d c o n s ta n ts . T h e s e tw o k in d s o f c o n s ta n t a r e s u p e r fic ia lly s im ila r , b u t th e y a r e g o v e r n e d b y d iffe r e n t ru le s a n d u s e d f o r d iffe r e n t p u rp o s e s .

P e n d e k la r a s ia n k o n s ta n ta d ila k u k a n d e n g a n s in ta k s b e rik u t:

c o n s t

nameof_kon

stanta = valueof_konstantam

,

e x a m p le :

c o n s t

M a ksim u m = 10;

L o g N a tu ra l = 2 .7 1 8 2 8 1 8 2 8 ; Bahasa = 'O b je c t Pascal';

W e c o u ld d e te r m in e th e ty p e o f c o n s ta n t. It c a lle d ty p e d c o n s ta n ta . e x a m p le :

c o n s t

M a ksim u m : in te g e r = 10;

L o g N a tu ra l : d o u b le = 2 .7 1 8 2 8 1 8 2 8 ; Bahasa : S h o rtS trin g = 'O b je c t Pascal';

4 . T o o l s a n d M a t e r i a l s

• P e r s o n a l C o m p u te r

• W in d o w s X P O p e r a tin g S y s te m

• B o r la n d D e lp h i 7

5 . W o r k S a f e t y

a. B e fo r e p r a c tic in g , s tu d e n ts s h o u ld u n d e r s ta n d th e g o a l a n d c o m p e te n c y o f th is p r a c tic e .

b. R e a d a n d u n d e r s ta n d a ll p r o c e d u r e s o f th is p r a c tic e c a r e fu lly .

c. A lw a y s k e e p d a ta fro m lo s in g c a u s e s b y e x tin g u is h e d e le c tr ic ity .

6 . P r o c e d u r e s

(18)

$

S e m e s t e r 2 D a ta T y p e in P ro g ra m m in g

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 8 o f 1 5

6 .1 . P r a k t i k P e n g g u n a a n T i p e B i l a n g a n B u l a t

1. R u n B o r la n d D e lp h i 7 o n y o u r c o m p u te r .

2. In a c tiv e fo r m , s e le c t c o m p o n e n t s a n d p la c e o n fo r m lik e p ic tu r e b e lo w :

**

U*

tart r»—< *ir 'w ***?■ w«m *J r

• Ol a j . x # M t M M t ' M v l l M k w M U M I M « n D M w W 1 4 «

# p ■ ► - a a 4 J ?

Label

L a b e L

Label

L a b e l4 <

• I MM fmm

l l t a k a U b f i o f f l t » « M > i * » ) | M I t t U i U H * T _ i * o «

D l v J n m ^/ » 4 i » u

l . t eVi t t 1 Cv » . l w»1

w Lf cMfA' U» r * >

- c |l •«*. -—m»- • • Jt V—

3. S e t th e p r o p e r tie s o f e a c h c o m p o n e n t s a s fo llo w :

C o m p o n e n t P r o p e r tie s V a lu e

F o r m l C a p tio n T ip e B ila n g a n B u la t

L a b e ll C a p tio n x =

F o n t - S iz e 12

F o n t - S ty le - f s B o ld T r u e

L a b e l2 C a p tio n y =

F o n t - S iz e 12

F o n t - S ty le - f s B o ld T r u e

L a b e l3 C a p tio n x + y =

F o n t - S iz e 12

F o n t - S ty le - f s B o ld T r u e

L a b e ll C a p tio n x * y =

F o n t - S iz e 12

F o n t - S ty le - f s B o ld T r u e

C r e a t e d b y : P r o h i b i t e d t o r e p r o d u c e i n p a r t o r w h o l e d o c u m e n t w i t h o u t R e v i e w e d b y : S a m s u l H a d i p e r m i s s i o n o f t h e F a c u l t y o f E n g i n e e r i n g , Y o g y a k a r t a S t a t e

(19)

$

S e m e s t e r 2 D a ta T y p e in P ro g ra m m in g

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 9 o f 1 5

E d it1 T e x t

<empty>

E d it2 T e x t

<empty>

E d it3 T e x t

<empty>

E d it4 T e x t

<empty>

B u tto n 1 C a p tio n H itu n g

4. T h e r e s u lt is lik e p ic tu r e b e lo w :

x =:

H itu n g

x + y = : : x * y = [

5. D o u b le C lic k o n B u tto n 1 , th e n w r ite c o d e p r o g r a m a s fo llo w :

p r o c e d u r e T F o rm 1 .B u tto n 1 C lic k (S e n d e r: T O b je c t);

v a r

x , y , z: in te g e r;

b e g in

x := S trT o In t(E d it1 .T e x t); y := S trT o In t(E d it2 .T e x t); z := x + y ;

E d it3 .T e x t := In tT o S tr( z );

z := x * y ;

E d it4 .T e x t := In tT o S tr( z );

e n d ;

6. R u n p r o je c t b y c lic k in g t o o lb a r .

iJ

o r p r e s s F 9 o n y o u r k e y b o a r d .
(20)

$

S e m e s t e r 2 D a ta T y p e in P ro g ra m m in g

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 1 0 o f 1 5

7. A f t e r p r o g r a m ru n n in g , e n tr y th e n u m b e r 3 a n d 4 s e q u e n tia lly o n E d it1 a n d E d it2 , th e n c lic k b u tto n H itu n g . W e c a n s e e t h a t o n E d it3 w ill s h o w r e s u lt 3 + 4 = 7 a n d o n E d it4 w ill s h o w r e s u lt 3 * 4 = 1 2 lik e p ic tu r e b e lo w :

7 4 1 i | > c H i l d n g d n H u l d l

m

i m p e l X = |3

y =

I4

| l' i l i t L i n q '|

x ■ y = k x *

y

| i z

8. T r y to e n tr y a n o t h e r n u m b e r o n E d it1 d a n E d it2 ju s t lik e s te p 7.

9. S a v e y o u r p r o je c t a s T ip e D a t a 1 .

6 .2 . A p p l y i n g R e a l T y p e o n P r o g r a m m i n g

1. R u n B o r la n d D e lp h i 7 o n y o u r c o m p u te r .

2. n a c tiv e fo r m , s e le c t c o m p o n e n t s a n d p la c e o n fo r m lik e p ic tu r e b e lo w : ----► M l ■ M l * m ( B U 3 ^ *•

m . 4 * ' • * » • i l l l t M * « W O . ; I ■ ■ t e U M Kwu C « £ m M i £ > : n a -M I m » i Z m m O m ! 2«fcJ

_ # C ■ ► * » i . w * t A f y « j JSJ * • I f i t f •»“ * * " £

L a b e

Labe

Labe

Labe

C r e a t e d b y : P r o h i b i t e d t o r e p r o d u c e i n p a r t o r w h o l e d o c u m e n t w i t h o u t R e v i e w e d b y : S a m s u l H a d i p e r m i s s i o n o f t h e F a c u l t y o f E n g i n e e r i n g , Y o g y a k a r t a S t a t e

(21)

$

S e m e s t e r 2 D a ta T y p e in P ro g ra m m in g

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 1 1 o f 1 5

3. S e t th e p r o p e r tie s o f e a c h c o m p o n e n t s a s fo llo w :

C o m p o n e n t P r o p e r tie s V a lu e

F o rm 1 C a p tio n T ip e B ila n g a n R e a l

L a b e l1 C a p tio n M e n c a r i L u a s d a n K e lilin g

L in g k a r a n

F o n t - S iz e 12

F o n t - S ty le - f s B o ld T r u e

L a b e l2 C a p tio n M a s u k k a n n ila i ja r i- ja r i

L a b e l3 C a p tio n L u a s lin g k a r a n =

L a b e l4 C a p tio n K e lilin g lin g k a r a n =

E d it1 T e x t

<empty>

E d it2 T e x t

<empty>

E d it3 T e x t

<empty>

B u tto n 1 C a p tio n H itu n g

4. T h e r e s u lt is lik e p ic tu r e b e lo w :

M e n c a r i L u a s d a n K e lilin g L in g k a r a n M a s u k k a n n ilai jari-jari- • P

H itun g

L u a s lin g k a ra n = K eliling lin g k a ra n

-5. D o u b le C lic k o n B u tto n 1 , th e n w r ite c o d e p r o g r a m a s fo llo w :

p r o c e d u r e T F o rm 1 .B u tto n 1 C lic k (S e n d e r: T O b je c t);

v a r

ja ri_ ja ri: re a l; lu a s _ lin g k a ra n : re a l; k e lilin g jin g k a r a n : re a l;

c o n s t

phi = 3 .1 4 ;

b e g in

(22)

$

S e m e s t e r 2 D a ta T y p e in P ro g ra m m in g

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 1 2 o f 1 5

ja ri_ ja ri := S trT o F lo a t(E d it1 .T e x t); lu a s _ lin g k a ra n := 2 * phi * ja ri_ ja ri; E d it2 .T e x t := F lo a tT o S tr(lu a s _ lin g k a ra n );

k e lilin g _ lin g k a ra n := phi * ja ri_ ja ri * ja ri_ ja ri; E d it3 .T e x t := F lo a tT o S tr(k e lilin g _ lin g k a ra n );

e n d ;

6. R u n p r o je c t b y c lic k in g t o o lb a r o r p r e s s F 9 o n y o u r k e y b o a r d .

7. A f t e r p r o g r a m ru n n in g , e n tr y th e n u m b e r 5 o n E d it1 , c lic k b u tto n H itu n g , th e n E d it2 w ill s h o w c ir c le v a s t a s 3 1 ,4 a n d E d it3 w ill s h o w c ir c le a r o u n d e q u a l to 7 8 ,5 lik e s h o w n b e lo w :

7 ' T i p e B i l a n g a n R e a l K U j I

M e n c a r i L u a s d a n K e lilin g L in g k a r a n M a s u k k a n r i a i jari-jari

F ~

1 ! H itu n g ! 1

L u a s lin g k a ra n = 13 1 .4 K eliling lin g k a ra n = |7 8 .5

8. T r y to e n tr y a n o t h e r n u m b e r o n E d it1 d a n E d it2 ju s t lik e s te p 7.

9. S a v e y o u r p r o je c t a s T ip e D a ta 2 .

6 . 3 . A p p l y i n g B o o l e a n T y p e o n P r o g r a m m i n g

1. R u n B o r la n d D e lp h i 7 o n y o u r c o m p u te r .

2. In a c tiv e fo r m , s e le c t c o m p o n e n t s a n d p la c e o n fo r m lik e p ic tu r e b e lo w :

C r e a t e d b y : P r o h i b i t e d t o r e p r o d u c e i n p a r t o r w h o l e d o c u m e n t w i t h o u t R e v i e w e d b y : S a m s u l H a d i p e r m i s s i o n o f t h e F a c u l t y o f E n g i n e e r i n g , Y o g y a k a r t a S t a t e

(23)

S e m e s t e r 2 D a ta T y p e in P ro g ra m m in g

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 1 3 o f 1 5

t * n | » ' . n x

* *

’.S

P»«Ht «O' 'M tn n 'K * in n

-1+1’

*

& •

(4 It

i , J , + IW ta m 0«toLv*Q*l M om r DOfc 1

«1

»l««n 1

mm*lmw-

>*11

J r b ^ - i ! / ! ' « * ■*! Si‘ a « * j “ “= U

* wMm D«*eLi*e t»#-1--*

7 f* fo < «

u f i * *

3 » _ _ _ _ _ _ _ _- r Edit1

3 1 * » '

■ 691 —

— ---► B utton1

(||M W HIW • — a •M

'*»• !»• OV.M 1 * • ic m <» r -#v/«

|p *r% K L ,I_____ r tndtei ««a# rw - * * * *■*

M M * «_•

3. S e t th e p r o p e r tie s o f e a c h c o m p o n e n t s a s fo llo w :

K o m p o n e n P r o p e r tie s V a lu e

F o rm 1 C a p tio n T ip e D a ta B o o le a n

E d it1 T e x t

<empty>

B u tto n 1 C a p tio n T r u e v s F a ls e

4. T h e r e s u lt is lik e p ic tu r e b e lo w :

/ T i p e D a t a B o o l e a n X |

(24)

$

S e m e s t e r 2 D a ta T y p e in P ro g ra m m in g

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 1 4 o f 1 5

5. D o u b le C lic k o n B u tto n 1 , th e n w r ite c o d e p r o g r a m a s fo llo w :

p r o c e d u r e T F o rm 1 .B u tto n 1 C lic k (S e n d e r: T O b je c t);

b e g in

i f (g a n tia n = False) t h e n b e g i n

g a n tia n := T ru e ;

E d it1 .T e x t := 'N ila i B oolean = T ru e ';

e n d e l s e b e g i n

g a n tia n := False;

E d it1 .T e x t := 'N ila i B oolean = False';

e n d ; e n d ;

6. A d d v a r ia b le

ga nt

ian

o n g lo b a l v a r ia b e l d e c la r a tio n a s fo llo w :

v a r

F o r m l: T F o r m l; _ J W rite th is co d e g a n tia n : b o o le a n ;

i m p l e m e n t a t i o n

{ $ R * . d f m }

7. R u n p r o je c t b y c lic k in g t o o lb a r o r p r e s s F 9 o n y o u r k e y b o a r d .

8. A f t e r p r o g r a m ru n n in g , p r e s s th e b u tto n o n c e , th e n e d it1 w ill s h o w m e s s a g e ‘ N ila i B o o le a n = T r u e ’ , p r e s s a g a in th e b u tto n , e d it1 w ill s h o w m e s s a g e ‘ N ila i B o o le a n = F a ls e ’ , e tc . th is w ill h a p p e n e v e r y tim e y o u p r e s s th e b u tto n .

C r e a t e d b y : P r o h i b i t e d t o r e p r o d u c e i n p a r t o r w h o l e d o c u m e n t w i t h o u t R e v i e w e d b y : S a m s u l H a d i p e r m i s s i o n o f t h e F a c u l t y o f E n g i n e e r i n g , Y o g y a k a r t a S t a t e

(25)

S e m e s t e r 2 D a ta T y p e in P ro g ra m m in g

C l a s s i c a l h o u r s 4 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 1 5 o f 1 5

9. S a v e y o u r p r o je c t a s T ip e D a ta 3 .

7 . D i s c u s s i o n

a. C r e a te a p r o g r a m to c o u n t r e s is t a n c e o f tw o r e s is t o r in s ta lle d b o th s e r ia l a n d p a r a lle l w ith c o n fig u r a tio n ju s t lik e p ic tu r e b e lo w :

/ ' M e n g h i t u n g N i l a i R e s i s t o r S e i i d a n P a r a l e l | V ] f n ] ( x ]

R e s is to r 1 = 1 0 0 0 0 o h m R e s is to r 2 = 1 0 0 0 0 o h m

i H itu n g !

R I s e ri R 2 = 2 0 0 0 0 o h m R I p a r a le l R 2 = |sooo o h m

b. C r e a te a p r o g r a m to p e r fo r m t e m p e r a t u r c o n v e r s io n fro m C e lc iu s to F a r e n h e it w ith f o r m u la F = (9 /5 x C ) + 3 2 , a n d fr o m F a h r e n h e it to C e lc iu s w ith f o r m u la C = 5 /9 x (F - 3 2 ) !

(26)

$

S e m e s t e r 2 Bra n c h in g /C o n d itio n a l S tru c tu re in P ro g ra m m in g

C l a s s i c a l h o u r s 8 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 1 o f 1 3

1 . C o m p e t e n c y

A f t e r p r a c tic in g , s tu d e n ts w ill h a v e c o m p e te n c ie s : k n o w , u n d e r s ta n d a n d a p p ly in g b r a n c h s tr u c tu r e in P r o g r a m m in g .

2 . S u b C o m p e t e n c i e s

A f t e r p r a c tic in g , s tu d e n ts w ill h a v e s u b c o m p e te n c ie s : a. K n o w in g c o n c e p t o f b r a n c h s tr u c tu r e .

b. U n d e r s ta n d f u n c tio n a n d p r o c e d u r e o f b r a n c h s tr u c tu r e . c. C r e a tin g c o m p u te r p r o g r a m w ith b r a n c h s tru c tu re .

3 . I n t r o d u c t i o n

C o n d itio n a l o r b r a n c h s tr u c tu r e u s e d to tu r n th e flo w o f a p r o c e s s . It is v e r y u s e fu l, e s p e s c ia lly f o r c o m p le x p r o g r a m . B a s ic a lly , th e r e a r e 3 c o m m a n d s in c o n d itio n a l s tr u c tu r e , t h e y a re :

a. IF - T H E N

b. IF - T H E N - E L S E c. C A S E - O F

3 . 1 . I F - T H E N

“ I F c o m m a n d ” u s e d to s e le c t a s in g le c o n d itio n . If th e c o n d itio n tru e , th e n th e

s t a t e m e n t in its b lo c k w ill b e p r o c e s s e d . If n o t, p r o g r a m w ill p r o c e s s n o th in g . T h e s y n ta x o f a n “ I F . . . T H E N ” s t a t e m e n t is

if

expression

then

statement

W h e r e e x p r e s s io n r e tu r n s a B o o le a n v a lu e . If e x p r e s s io n is tru e , th e n s t a t e m e n t is e x e c u te d ; o th e r w is e it is n o t. F o r e x a m p le ,

if

J <> 0

then

Result := I/J;

F l o w c h a r t o f IF - T H E N is:

C r e a t e d b y : P r o h i b i t e d t o r e p r o d u c e i n p a r t o r w h o l e d o c u m e n t w i t h o u t R e v i e w e d b y : S a m s u l H a d i p e r m i s s i o n o f t h e F a c u l t y o f E n g i n e e r i n g , Y o g y a k a r t a S t a t e

(27)

$

S e m e s t e r 2 Bra n c h in g /C o n d itio n a l S tru c tu re in P ro g ra m m in g

C l a s s i c a l h o u r s 8 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 2 o f 1 3

3 . 2 . P e r i n t a h I F - T H E N - E L S E

T h e s y n ta x o f a n if...th e n ...e ls e s ta t e m e n t is

If

expression

then

statementl

else

statement2

W h e r e e x p r e s s io n r e tu r n s a B o o le a n v a lu e . If e x p r e s s io n is tru e , th e n s t a t e m e n t l is e x e c u te d ; o th e r w is e s t a t e m e n t2 is e x e c u te d . F o r e x a m p le ,

if

J = 0

then

Exit

else

Result: = I/J;

T h e th e n a n d e ls e c la u s e s c o n ta in o n e s ta t e m e n t e a c h , b u t it c a n b e a s tr u c tu r e d s ta te m e n t. F o r e x a m p le ,

if J <> 0 then

begin

Result := I/J;

Count := Count + 1;

end

else if Count = Last then

Done := True

else

Exit;

N o tic e th a t th e r e is n e v e r a s e m ic o lo n b e tw e e n th e th e n c la u s e a n d th e w o r d e ls e . Y o u c a n p la c e a s e m ic o lo n a f t e r a n e n tir e if s ta t e m e n t to s e p a r a te it fro m th e n e x t s ta t e m e n t in its b lo c k , b u t th e th e n a n d e ls e c la u s e s r e q u ir e n o th in g m o r e th a n a s p a c e o r c a r r ia g e re tu r n b e tw e e n th e m . P la c in g a s e m ic o lo n im m e d ia te ly b e fo r e e ls e (in a n if s ta te m e n t) is a c o m m o n p r o g r a m m in g e r ro r.

F l o w c h a r t o f IF - T H E N - E L S E c o m m a n d is:

(28)

$

S e m e s t e r 2 Bra n c h in g /C o n d itio n a l S tru c tu re in P ro g ra m m in g

C l a s s i c a l h o u r s 8 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 3 o f 1 3

a n o th e r s y n ta x o f IF - T H E N - E L S E c o m m a n d is:

i f

(kondisi percabangan)

t h e n b e g in

... ;

{a k s i-1 }

e n d

e ls e b e g in

... ;

{a k s i-2 }

e n d ;

3 . 3 . C A S E - O F C o m m a n d

C A S E - O F c o m m a n d g e n e r a lly u s e d to c o n d itio n w ith m a n y b r a n c h e s . T h e c a s e s ta t e m e n t m a y p r o v id e a r e a d a b le a lte r n a tiv e to d e e p ly n e s te d if c o n d itio n a ls . A c a s e s ta t e m e n t h a s th e fo r m

Case

selectorExpression

of

caseList1:

statement1;

caseListn:

statementn;

end

W h e r e s e le c to r E x p r e s s io n is a n y e x p r e s s io n o f a n o r d in a l t y p e ( s tr in g ty p e s a r e in v a lid ) a n d e a c h c a s e L is t is o n e o f th e fo llo w in g :

C r e a t e d b y : P r o h i b i t e d t o r e p r o d u c e i n p a r t o r w h o l e d o c u m e n t w i t h o u t R e v i e w e d b y : S a m s u l H a d i p e r m i s s i o n o f t h e F a c u l t y o f E n g i n e e r i n g , Y o g y a k a r t a S t a t e

(29)

S e m e s t e r 2 B ra n c h in g /C o n d itio n a l S tru c tu re in P ro g ra m m in g

C l a s s i c a l h o u r s 8 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 4 o f 1 3

A n u m e r a l, d e c la r e d c o n s ta n t, o r o th e r e x p r e s s io n th a t th e c o m p ile r c a n e v a lu a te w ith o u t e x e c u tin g y o u r p r o g r a m . It m u s t b e o f a n o r d in a l ty p e c o m p a tib le w ith s e le c to r E x p r e s s io n . T h u s 7, T r u e , 4 + 5 * 3 , 'A ', a n d I n t e g e r ( 'A ') c a n a ll b e u s e d a s c a s e L is ts , b u t v a r ia b le s a n d m o s t fu n c t io n c a lls c a n n o t. ( A f e w b u ilt- in f u n c tio n s lik e H i a n d L o c a n o c c u r in a c a s e L is t. S e e C o n s ta n t e x p r e s s io n s .)

A s u b r a n g e h a v in g th e fo r m F ir s t. L a s t, w h e r e F ir s t a n d L a s t b o th s a tis fy th e c r ite r io n a b o v e a n d F ir s t is le s s th a n o r e q u a l to L a s t.

A lis t h a v in g th e fo r m ite m 1 , ..., ite m n , w h e r e e a c h ite m s a tis fie s o n e o f th e c r ite r ia a b o v e .

E a c h v a lu e r e p r e s e n te d b y a c a s e L is t m u s t b e u n iq u e in th e c a s e s t a t e m e n t; s u b r a n g e s a n d lis ts c a n n o t o v e r la p . A c a s e s t a t e m e n t c a n h a v e a fin a l e ls e c la u s e :

c a s e s e le c to r E x p r e s s io n o f c a s e L is t1 : s ta t e m e n t1 ;

c a s e L is tn : s ta t e m e n tn ; e ls e

s ta t e m e n ts ; e n d

w h e r e s t a t e m e n ts is a s e m ic o lo n - d e lim ite d s e q u e n c e o f s ta te m e n ts . W h e n a c a s e s t a t e m e n t is e x e c u te d , a t m o s t o n e o f s ta te m e n t1 ... s ta t e m e n tn is e x e c u te d . W h ic h e v e r c a s e L is t h a s a v a lu e e q u a l to th a t o f s e le c to r E x p r e s s io n d e te r m in e s th e s ta t e m e n t to b e u s e d . If n o n e o f th e c a s e L is ts h a s th e s a m e v a lu e a s s e le c to r E x p r e s s io n , th e n th e s ta t e m e n ts in th e e ls e c la u s e ( if t h e r e is o n e ) a r e e x e c u te d .

T h e c a s e s ta t e m e n t

c a s e I o f

1 ..5 : C a p tio n := 'L o w '; 6 ..9 : C a p tio n := 'H ig h ';

0, 1 0 ..9 9 : C a p tio n := 'O u t o f ra n g e '; e ls e

C a p tio n := ''; e n d ;

(30)

$

S e m e s t e r 2 B ra n c h in g /C o n d itio n a l S tru c tu re in P ro g ra m m in g

C l a s s i c a l h o u r s 8 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 5 o f 1 3

is e q u iv a le n t to th e n e s te d c o n d itio n a l

if I in [1 ..5 ] th e n C a p tio n := 'L o w ' e ls e if I in [6 ..1 0 ] th e n

C a p tio n := 'H ig h '

e ls e if (I = 0 ) o r (I in [1 0 ..9 9 ]) th e n C a p tio n := 'O u t o f ra n g e '

e ls e

C a p tio n := '';

f l o w c h a r t o f C A S E - O F c o m m a n d is:

e ls e :a c tio n -4

1 r

C

e n d

^

C r e a t e d b y : P r o h i b i t e d t o r e p r o d u c e i n p a r t o r w h o l e d o c u m e n t w i t h o u t R e v i e w e d b y : S a m s u l H a d i p e r m i s s i o n o f t h e F a c u l t y o f E n g i n e e r i n g , Y o g y a k a r t a S t a t e

(31)

$

S e m e s t e r 2 Bra n c h in g /C o n d itio n a l S tru c tu re in P ro g ra m m in g

C l a s s i c a l h o u r s 8 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 6 o f 1 3

B e n tu k s in ta k s d a ri p e r in ta h C A S E - O F a d a la h s e b a g a i b e rik u t:

c a s e

(parameter)

o f n ila i_ 1 : ... ;

{a k s i-1 }

n ila i_ 2 : ... ;

{a k s i-2 }

n ila i_ 3 : ... ;

{a k s i-3 }

e ls e

... ;

{a ksi-4 }

e n d ;

4 . T o o l s a n d M a t e r i a l s

• P e r s o n a l C o m p u te r

• W in d o w s X P O p e r a tin g S y s te m • B o r la n d D e lp h i 7

5 . W o r k S a f e t y

a. B e fo r e p r a c tic in g , s tu d e n ts s h o u ld u n d e r s ta n d th e g o a l a n d c o m p e te n c y o f th is p r a c tic e .

b. R e a d a n d u n d e r s ta n d a ll p r o c e d u r e s o f t h is p r a c tic e c a r e fu lly .

c. A lw a y s k e e p d a ta fro m lo s in g c a u s e s b y e x tin g u is h e d e le c tr ic ity .

6 . P r o c e d u r e s

6 . 1 . I F - T H E N P r a c t i c e

1. R u n B o r la n d D e lp h i 7 o n y o u r c o m p u te r .

2. n a c tiv e fo r m , s e le c t c o m p o n e n t s a n d p la c e o n fo r m lik e p ic tu r e b e lo w :

3. S e t th e p r o p e r tie s o f e a c h c o m p o n e n t s a s fo llo w :

(32)

$

S e m e s t e r 2 B ra n c h in g /C o n d itio n a l S tru c tu re in P ro g ra m m in g

C l a s s i c a l h o u r s 8 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 7 o f 1 3

K o m p o n e n P r o p e r tie s V a lu e

F o rm 1 C a p tio n S t r u k t u r P e r c a b a n g a n IF -T H E N

E d it1 T e x t

(dikosongi)

B u tto n 1 C a p tio n A k s i

4. T h e r e s u lt is lik e p ic tu r e b e lo w :

5. D o u b le C lic k o n B u tto n 1 , th e n w r ite c o d e p r o g r a m a s fo llo w :

p r o c e d u r e T F o rm 1 .B u tto n 1 C lic k (S e n d e r: T O b je c t);

v a r

n ila i: in te g e r;

b e g in

nilai := S trT o In t(E d it1 .T e x t);

i f (n ila i > = 7 0 ) t h e n b e g i n

M essa g e D lg ('N ilai A n da d in y a ta k a n LULUS', m tIn fo rm a tio n , [m b O k ], 0 );

e n d ; e n d ;

6. R u n p r o je c t b y c lic k in g t o o lb a r o r p r e s s F 9 o n y o u r k e y b o a r d .

7. A f t e r p r o g r a m ru n n in g , e n tr y th e n u m b e r 7 5 in to E d it1 . T h e n p r e s s b u tto n A k s i. A p o p u p m e s s a g e w il s h o w :

C r e a t e d b y : P r o h i b i t e d t o r e p r o d u c e i n p a r t o r w h o l e d o c u m e n t w i t h o u t R e v i e w e d b y : S a m s u l H a d i p e r m i s s i o n o f t h e F a c u l t y o f E n g i n e e r i n g , Y o g y a k a r t a S t a t e

(33)

$

S e m e s t e r 2 Bra n c h in g /C o n d itio n a l S tru c tu re in P ro g ra m m in g

C l a s s i c a l h o u r s 8 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 8 o f 1 3

8. E n tr y v a lu e 5 0 in to E d it 1 . T h e n p r e s s b u tto n A k s i. W h a t w o u ld h a p p e n ?

9. T r y to in p u t a n o t h e r v a lu e (0 - 1 0 0 ) in to E d it 1 , th e n p r e s s b u tto n A k s i. W h a t w o u ld h a p p e n ?

10 . S a v e y o u r p r o je c t a s P e r c a b a n g a n 1 .

6 . 2 . P r a k t i k I F - T H E N - E L S E

1. C r e a te a n e w p r o je c t in D e lp h i.

2. In a c tiv e fo r m , s e le c t c o m p o n e n t s a n d p la c e o n fo r m lik e p ic tu r e b e lo w :

(34)

S e m e s t e r 2 Bra n c h in g /C o n d itio n a l S tru c tu re in P ro g ra m m in g

C l a s s i c a l h o u r s 8 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 9 o f 1 3

3. S e t th e p r o p e r tie s o f e a c h c o m p o n e n t s a s f o llo w :

C o m p o n e n t P r o p e r tie s V a lu e

F o rm 1 C a p tio n S t r u k t u r P e r c a b a n g a n IF - T H E N -

E L S E

E d it1 T e x t

(dikosongi)

B u tto n 1 C a p tio n A k s i

L a b e l1 C a p tio n H a s il :

F o n t - S iz e 1 0

F o n t - S ty le - f s B o ld T r u e

4. T h e r e s u lt is lik e p ic tu r e b e lo w :

H a s i l :

5. D o u b le C lic k o n B u tto n 1 , th e n w r ite c o d e p r o g r a m a s fo llo w :

p r o c e d u r e T F o rm 1 .B u tto n 1 C lic k (S e n d e r: T O b je c t);

v a r

n ila i: in te g e r;

b e g in

nilai := S trT o In t(E d it1 .T e x t);

i f (n ila i > = 7 0 ) t h e n b e g i n

L a b e l1 .C a p tio n := 'H asil : N ilai A n d a d in y a ta k a n LULUS';

e n d e l s e b e g i n

L a b e l1 .C a p tio n := 'H asil : Nilai A n da d in y a ta k a n T ID A K LULUS';

e n d ;

_ _ _ _ _ _ _ e n d ; _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

C r e a t e d b y : P r o h i b i t e d t o r e p r o d u c e i n p a r t o r w h o l e d o c u m e n t w i t h o u t R e v i e w e d b y : S a m s u l H a d i p e r m i s s i o n o f t h e F a c u l t y o f E n g i n e e r i n g , Y o g y a k a r t a S t a t e

(35)

S e m e s t e r 2 Bra n c h in g /C o n d itio n a l S tru c tu re in P ro g ra m m in g

C l a s s i c a l h o u r s 8 x 5 0 m i n s N o . R e v i s i o n : D a t e :

L S C P / E K O / D E L 2 2 4 / 0 3 0 1 M a r c h , 1 2 0 0 9 P a g e 1 0 o f

Referensi

Dokumen terkait

Maka kemudian tugas kita adalah tetap untuk melakukan perlawanan terhadap kebijakan yang menumbalkan rakyat dengan “Gagalkan Kenaikan BBM atau SBY-Boediono Turun”.. Selain

Memeriksa Ayat Jurnal dan Penyesuaian Lainnya untuk Mencari Bukti Salah Saji yang Mungkin Akibat Kecurangan Pertama auditor harus memahami proses pelaporan

Perancangan halaman tambah data pakar merupakan halaman untuk menambah ciri-ciri pakar yang digunakan dalam menentukan jenis buah durian yang dapat dilihat pada

Berdasarkan hal tersebut penulis penulis mencoba membuat sistem pakar dengan judul “Sistem Pakar Untuk Diagnosa dan Pencari solusi Penyakit Tulang Menggunakan

Menurut PSAK No.1: (1) PSAK No.1 (revisi 2009) mewajibkan entitas untuk menyusun laporan laba rugi komprehensif, yang terdiri dari informasi laba rugi yang biasa dilaporkan

Hubungan jarak sumber radiasi dengan laju cacahan untuk pengujian perangkat kamera gamma menggunakan phantom linier dan phantom BAR, ditunjukkan pada Gambar 3.. Dimana x

Secara eksplisit tujuan penelitian ini adalah (1) meningkatkan kualitas kompetensi penalaran siswa dalam pembelajaran menggunakan model pembelajaran

Susu skim mengandung karbohidrat yaitu laktos ayang tinggi sehingga penambahan susu skim dapat menghambat pertumbuhan BAL seiring tingginya penambahan konsentrasi