1 / 20

Dasar-Dasar Pemrograman 2

Dasar-Dasar Pemrograman 2. Mengedit Data Mengurutkan Data Mencari Data Relasi Antar Tabel Variabel Memori Array Ekspresi , Operator dan Fungsi. Editing Record. Menghapus record DELETE [scope] [FOR syarat ] Membatalkan tanda penghapusan

byrd
Download Presentation

Dasar-Dasar Pemrograman 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Dasar-DasarPemrograman 2 Mengedit Data Mengurutkan Data Mencari Data RelasiAntarTabel VariabelMemori Array Ekspresi, Operator danFungsi

  2. Editing Record • Menghapus record • DELETE [scope] [FOR syarat] • Membatalkantandapenghapusan • RECALL [scope] [FOR syarat]  scope: ALL • Penghapusanpermanen • PACK • Penyisipan record • INSERT [before] [blank] • Contoh: • INSERT • Menginsertpadarecno 3 • Go 3 • Insert before

  3. Koreksiterhadap record tertentu • REPLACE [scope] nama_field1 WITH ekspresi [nama_field2 WITH eksspresi] [FOR syarat] • Contoh: • Replace n_akhir with 0.2*tugas+0.3*uts+0.5*uas

  4. Pengurutan Data • Sort menghasilkan file baru (*.dbf) • SORT ON filed[/D][C] TO nama_file [FOR kriteria] • Contoh: • SORT ON n_akhir TO urut • Indeks menghasilkan file baru (*.idx/*.cdx) • INDEX ON eExpression TO IDXFileName | TAG TagName [FOR lExpression] [COMPACT] [ASCENDING | DESCENDING] [UNIQUE | CANDIDATE] [ADDITIVE] • Contoh: • INDEX ON nim TO mhs_idx • INDEX ON str(nim)+kode_mk TO nilai_cdx

  5. Pengurutan Data (2) • Mengaktifkan file indeks • SET INDEX TO IDXFileName • Contoh: • USE MHS • SET INDEX TO mhs_idx • Melakukanindeksulang • REINDEX • Menutup file indeks • SET INDEX TO • CLOSE INDEX

  6. Pencarian Data • Pencarian data pada field terindeks • SEEK kriteria kriteria data kunciindeks • Contoh: • Seek 1008  mencarinim 1008 • FIND kriteriakhususuntukkuncitipekarakter • Contoh • FIND ‘Ahmad’  mencarinama Ahmad

  7. RelasiAntarTabel • Denganperintah SET RELATION, langkah-langkahnya • Memilihdaerahkerjaaktif • SELECT ekspresi • Contoh: SELECT A, SELECT B, SELECT 1, SELECT 2 • Membuatrelasi • SELE 1 • USE MK • SET INDEX TO MK_IDX • SELE 2 • USE NILAI • SET INDEX TO NILAI_IDX • SET RELATION TO KODE_MK INTO MK

  8. RelasiAntarTabel (2) • Retrieve data, misalnyamenampilkan • LIST KODE_MK, MK.NAMA_MK, N_AKHIR • Menyimpanhasil retrieve (biladiperlukan) • CREATE VIEW namaFile • Menutup database • CLOSE DATABASES • Menampilkanhasilrelasi yang pernahdibuat • SET VIEW TO namaFile

  9. VARIABEL MEMORY

  10. Variabel Memory • Variabel memory di simpandalam RAM • Data yang disimpandalamvariabelmemoriakanhilangjikakomputerdimatikan • Biasadipakaiuntukmenyimpan data sementara • Sangatpentingpadasaatmembuat program aplikasi • Variabelmemori: • Standar: disediakanoleh FoxPro • Buatan: dibuatolehprogramer

  11. Variabel Memory (2) • Berdasarkancakupannya, variabelmemori: • Public • Privat • Penamaan: • Maksimum 10 karakter • Diawalidenganhuruf • Tidakmemakaikarakterspasidankoma • Bolehdiikutidenganangka

  12. Variabel Memory (3) • Menyimpanvariabelmemori: • STORE • STORE data TO namaVariabel • Contoh: • STORE 87 TO nilai • STORE ‘Ahmad’ TO nama • namaVariabel=data • Contoh: • Nilai=87 • Nama=‘Ahmad’

  13. Variabel Memory (4) • Menampilkanisivariabelmemori: • ? nilai • ?”Nilaiku = “+STR(nilai) • ?”Namaku= “+nama+ “ nilaiku = “+STR(nilai) • Dalampemrogramanakandibahasbagaimanamenampilkanvariabelmemori

  14. ARRAY

  15. ARRAY • Array termasukvariabelmempribuatan • Mendeklarasikan • namaArray (baris,kolom) • Contoh: • Barang(3,2) • Mengisi array • Barang(1,1)=“mobil” • Barang(1,2)=“BMW” • Barang(2,1)=“motor” • Barang(2,2)=“YAMAHA” • Barang(3,1)=“sepeda” • Barang(3,2)=“BMX” • Ataudenganperintah STORE

  16. ARRAY(2) • Menampilkanisivariabel array • DISPLAY MEMORY LIKE namaArray • DISPLAY MEMORY LIKE Barang • Untukmelihatsatupersatu • ?Barang(1,2) • Pelajarijuga: pengolahan array denganfungsi

  17. EKSPRESI, OPERATOR danfungsi

  18. Ekspresi • Ekspresisamadenganrumus • Ekspresiterdiridari: komponendan operator • Komponenterdiridariangka, karakter, filed, variabelmemori, fungsiatauelemen array • Operator adalahpenghubungantarkomponen • Contoh: • REPLACE n_Akhir WITH 0.2*tugas+0.3*uts+0.5*uas • Luas=panjang*lebar

  19. Operator • Matematika: (),^, . , / , %, + , - • Relasi: =, <, >, <=, >=, <> atau != atau #, == • Logika: (), NOT atau ! , AND, OR • Karakter: +, -, $

  20. FungsiStandar • Jumlah • SUM namaFields[TO namaVariabel] [FOR kriteria] • SUM uas, n_akhir TO juas, jnakhir FOR kode_MK=11 • Rata-rata • AVERAGE namaFields[TO namaVariabel] [FOR kriteria] • AVERAGE uas, n_akhir TO ruas, rnakhirFOR kode_MK=11 • Jumlah record • Count [FOR kriteria] [TO namaVariabel] • COUNT FOR n_akhir>85 TO nGradeA • Pelajarifungsi-fungsi yang lain

More Related