Belajar FoxPro Dari Dasar
Tutorial ini akan membahas dasar-dasar Foxpro, Saya
menggunakan Visual FoxPro9 contoh hasil seperti gambar di atas.
Pembahasan meliputi pembuatan database beserta tabelnya,
memasukkan menghapus dan mengedit data, dan pembahasan sedikit skrip2 dasar.
Buat database:
Dengan nama : data1 dan
kemudian buat tabel dengan nama : data_siswa dan n_siswa.
Buatlah field2 pada data_siswa seperti:
Dan kemudian field2 n_siswa seperti:
Setelah itu buatlah form seperti :
Command1 : -Caption:Lihat Data , -Picture: c:\program
files\microsoft visual foxpro 9\graphics\icons\mail\mail03.ico
Command2: -Caption: New
Command3:-Caption:Edit
Command4:-Caption:Delete
Command5:-Caption:Exit
Timer1:-Interval:100
Form1:-Caption:Siswa, -ShowWindow:2
Command1 | click
SELECT 2 BROWSE
Command2 | click
IF thisform.command2.Caption="New" then thisform.command2.Caption="Save" thisform.aktif thisform.command3.enabled = .F. thisform.command4.enabled = .F. thisform.text1.SetFocus ELSE SELECT 2 SEEK thisform.text1.value IF EMPTY(thisform.text3.Value) OR FOUND() then MESSAGEBOX("Data Sudah Ada/ Data Belum Lengkap!",0+64,"ERROR") ELSE APPEND BLANK replace nis WITH thisform.text1.Value replace nama WITH thisform.text2.value replace kelas WITH thisform.text3.Value replace agama WITH thisform.text4.value replace ppkn WITH thisform.text5.Value replace sejarah WITH thisform.text6.value replace matematika WITH thisform.text7.Value MESSAGEBOX("Data Tersimpan",0+64,"Berhasil") ENDIF thisform.command2.Caption="New" thisform.semula thisform.nonaktif thisform.command3.Enabled= .T. thisform.command4.Enabled= .T. ENDIF
Command3 | click
thisform.aktif thisform.text1.Enabled= .F. IF thisform.command3.Caption="Edit" then thisform.command3.Caption="Save" x=INPUTBOX("Masukkan NIS","NIS") SEEK x SELECT 2 thisform.text1.Value=nis thisform.text2.Value=nama thisform.text3.Value=kelas thisform.text4.Value=agama thisform.text5.Value=ppkn thisform.text6.Value=sejarah thisform.text7.Value=matematika ELSE SELECT 2 replace nis WITH thisform.text1.Value replace nama WITH thisform.text2.Value replace kelas WITH thisform.text3.Value replace agama WITH thisform.text4.Value replace ppkn WITH thisform.text5.Value replace sejarah WITH thisform.text6.Value replace matematika WITH thisform.text7.Value MESSAGEBOX("Data Telah Diganti",0+64,"Success") thisform.command3.Caption="Edit" thisform.semula ENDIF
Command4 | click
thisform.Release
Timer1 |Timer
A = thisform.text4.Value B = thisform.text5.Value C = thisform.text6.Value D = thisform.text7.Value x = A+B+C+D thisform.text9.Value = x thisform.text8.Value = x / 4
Form1 | Destroy
CLEAR EVENTS
Form1 | Load
SET DELETED ON SELECT 1 USE data_siswa SET ORDER TO tag nis SELECT 2 USE n_siswa SET ORDER TO tag nis
Buat Methode dengan cara meng-klik FORM>NEW METHOD,
Sehingga muncul kotak dialog spt:
Buat 3 method baru : semula, aktif, nonaktif.
Kemudian ketik lagi skripnya:
Form1 | Semula
thisform.text1.Value="" thisform.text2.Value="" thisform.text3.Value="" thisform.text4.Value=0 thisform.text5.Value=0 thisform.text6.Value=0
Form1 | Aktif
thisform.text1.Enabled= .T. thisform.text2.Enabled= .T. thisform.text3.Enabled= .T. thisform.text4.Enabled= .T. thisform.text5.Enabled= .T. thisform.text6.Enabled= .T. thisform.text7.Enabled= .T. thisform.command3.Enabled= .T. thisform.command4.Enabled= .T.
Form1 | nonaktif
thisform.text1.Enabled= .F.
thisform.text1.Enabled= .F.
thisform.text2.Enabled= .F. thisform.text3.Enabled= .F. thisform.text4.Enabled= .F. thisform.text5.Enabled= .F. thisform.text6.Enabled= .F. thisform.text7.Enabled= .F. thisform.command3.Enabled= .F. thisform.command4.Enabled= .F.
Selamat Anda sudah berhasil membuat program, sekarang
jalankan program dengan menekan tombol [CTRL+D].
Langkah Selanjutnya kita akan membuat file EXE-nya, buka tab
Code seperti ini:
Buat program baru kemudian ketik skrip berikut:
_screen.Visible = .F.
_screen.WindowState = 2
DO FORM siswa
READ event
Setelah itu klik kanan pada program yang kita buat dan
centanglah pilihan Set Main.
Kemudian pindahlah ke tab Other seperti ini:
Buatlah file config.pfw kemudian ketik skirp berikut:
SCREEN = OFF
Setelah itu kita build jadi Exe dengan cara mengklik tombol
Build pada Project manager :
No comments:
Post a Comment