[Gammu dan VFP] Mengirim dan menerima Pesan lebih dari 160 karakter

September 4, 2016

OK langsung aja yaa, cara menerima dan mengirim sms dengan gammu yang karakternya lebih dari 160, bagaimana implemntasinya di foxpro, gampang aja

Capture

pertama, untuk kirim sms


lcNope=ALLTRIM(Thisform.text1.Value)
lnSms=Len(Thisform.edit1.Value)

i=0
If lnSms >160
lcPesan =Alltrim(Thisform.edit1.Value)
*total Sms
lnByk = CEILING(lnSms/153)

=SQLExec(Thisform.konek,"SHOW TABLE STATUS LIKE 'outbox'","mOutbox")
Select mOutBox
lcId=VAL(mOutBox.Auto_increment)

For i=1 To lnByk
If i=1
lcPesanSplit = Substr(lcPesan,1,153)
lcPesan=SUBSTR(lcPesan,154)
lcudh= "050003A7"+Padl(Alltrim(Str(lnByk)),2,"0")+Padl(Alltrim(Str(i)),2,"0")

TEXT TO lcsql NOSHOW TEXTMERGE PRETEXT 7
INSERT INTO outbox (DestinationNumber, UDH, TextDecoded,ID, MultiPart,CreatorID)
VALUES ('<<lcnope>>', '<<lcudh>>', '<<lcPesanSplit>>','<<lcID>>', 'true','Gammu')
ENDTEXT

lnh=SQLexec(Thisform.konek,lcsql)
IF lnh <0
AERROR(laerror)
MESSAGEBOX(laerror[1,2])
endi
Else
lcPesanSplit=Substr(lcPesan,1,153)
lcPesan=SUBSTR(lcPesanSplit,154)
lcudh= "050003A7"+Padl(Alltrim(Str(lnByk)),2,"0")+Padl(Alltrim(Str(i)),2,"0")

TEXT TO lcsql NOSHOW TEXTMERGE PRETEXT 7
INSERT INTO outbox_multipart(UDH, TextDecoded, ID, SequencePosition)
VALUES ('<<lcUdh>>', '<<lcPesanSplit>>','<<lcId>>' ,' <<i>>')
ENDTEXT
lnh=SQLexec(Thisform.konek,lcsql)
IF lnh <0
AERROR(laerror)
MESSAGEBOX(laerror[1,2])
ENDIF
Endif
Endf

ENDIF

kedua, menerima/membaca inbox yang lebih dari 160 karakter


SELECT inbox
ZAP

=SQLEXEC(thisform.konek,"select * from inbox","mInbox")
SELECT * FROM mInbox INTO CURSOR TempInbox READWRITE
SELECT mInbox
SCAN
lcNope = SenderNumber
lcUDH = UDH

IF !EMPTY(lcUDH)

*Header UDH
lcHeader = SUBSTR(lcUdh,1,8)

*Total SMS
lcSplit=SUBSTR(lcUDH,9,2)
m=0
i=0
FOR i=1 TO INT(val(lcSplit))
lcUdhx = lcHeader+lcSplit+PADL(ALLTRIM(STR(i)),2,"0")
SELECT * FROM TempInbox WHERE senderNumber=lcNope AND UDH=lcUDHx INTO CURSOR InboxUDH

IF RECCOUNT("InboxUDH")>0
m=m+1
ENDIF
endf
lctext=""
IF m=INT(val(lcSplit))
FOR j=1 TO m
lcUdhx = lcHeader+lcSplit+PADL(ALLTRIM(STR(j)),2,"0")
SELECT * FROM TempInbox WHERE senderNumber=lcNope AND UDH=lcUDHx INTO CURSOR InboxUDH

SELECT inBoxUDH
lcNope = inboxUDH.senderNumber
lcText= lctext+inBoxUDH.Textdecoded
ldTgl=inboxUDH.ReceivingDateTime
lcId=inboxUDH.id
DELETE from TempInbox where id=lcId
* =SQLEXEC(thisform.konek,"DELETE from inbox where id=?lcId")
endf
INSERT INTO Inbox values(lcnope,lctext,ldTgl)

ENDIF
ENDIF
ends
SELECT inbox
GO top
thisform.grid1.Refresh

OK berikut saya sertakan formnya https://www.dropbox.com/s/gmweh2nxg01hayy/SmsGammu.rar?dl=0

 

[Tambahan]

sesuai penjelasan di blog om http://blog.rosihanari.net/teknik-mengirim-long-text-sms-gammu-dengan-query-sql/
yaitu tentang format UDH adalah “AAAAAAAA XX YY”, yang mana “AAAAAAA”  adalah format random hexadecimal, pertanyaannya bagaimana membuat format random hexadecimal?

ok berikut copasnya, bikin function

FUNCTION DecToHex
PARAMETERS liDecNumber
lsHexNumber = ""
IF liDecNumber > 0 && It's not negative, so do a straight TRANSFORM.
lsHexNumber = TRANSFORM(liDecNumber, "@0")
ELSE

*-- The number is negative, so we'll have to do a little more work,
*-- since it's not as straight forward as converting and adding a
*-- minus sign.

*-- Find the length of the resulting hex string.
lsHexNumber = TRANSFORM(ABS(liDecNumber), "@0")
IF SUBSTR(lsHexNumber, 3, 1) = "0" && The number has filled the
&& eight places of DWORD.
liLength = LEN(SUBSTR(lsHexNumber, NotAt("0", lsHexNumber, 2)))
ELSE
*-- Subtract to account for "0x".
liLength = LEN(TRANSFORM(ABS(liDecNumber), "@0")) - 2
ENDIF

lsTempHex = 0xFFFFFFFF
lsHexNumber = TRANSFORM(lsTempHex-ABS(liDecNumber) + 1, "@0")
ENDIF
RETURN lsHexNumber

selanjutnya edit tombol kirim,yang mana sebelumnya cuma statis yaitu “050003A7” , jadi dinamis dengan merubah jadi begini


lcHex =RIGHT(Dectohex(RAND()*100),2)
lcUDH1="050003"+lcHex

...

...

..

for i=1 to lnByk

...

if  i=1

....

lcudh= lcUDH1+Padl(Alltrim(Str(lnByk)),2,"0")+Padl(Alltrim(Str(i)),2,"0")

else

.....

lcudh= lcUDH1+Padl(Alltrim(Str(lnByk)),2,"0")+Padl(Alltrim(Str(i)),2,"0")

....

endif

endfor

Ok, silahkan dicopas aja, mg sukses selalu kawan


Upload File (Image) menggunakan Foxpro+PHP ke Hosting

September 3, 2016

Ok langsung aja, biasanya kita menggunakan FTP untuk melakuakn transfer file terutama image lah, tp bagaimana jika dilakukan tanpa FTP tapi kita menggunakan Php sebagai jalan alternatifnya, yaa kita bisa menggunakan webservice salah satunya, tp saya tidak melakukan itu (saya gagal maaf nubi), tp saya muncul ide melakukan dengan cara berbeda, yaitu memanfaatkan olebrowser :), ok sukses deh, berikut kodingnya sederhananya

pertama, pastinya bikin dulu formnya beserta ole browsernya

1

kedua, isi sintax di command button

with thisform.obrowser
.navigate("http://bumiantaludin.co.nf/sdmk/index.php")
do while .busy or .readystate#4
enddo
inkey(1)
with .document
.getElementbyId("upload").click
thisform.text1.Value=.getElementbyId("upload").value
.getElementbyId("uploadimg").click
endwith

ENDWITH

ketiga, bikin file uploadnya kasih namanya index.php,


<?php
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['upload']['name']);
if(move_uploaded_file($_FILES['upload']['tmp_name'], $target_path)) {
echo "Nama File ". basename( $_FILES['upload']['name']).
" Sukses Di Upload";
} else{
echo "Upload Error, Coba sekali lagi Brow!";
}
?>
<html>
<body>
<form enctype="multipart/form-data" action="<?php echo($_SERVER['PHP_SELF']) ?>" method="post">

<p>File: <input type="file" id="upload" name="upload" /></p>
<p><input type="submit" name="uploadimg" id="uploadimg" value="Post" /></p>
</form>
<body>
</html>

pastikan anda sudah membuat folder upload

ok coba kita running deh

coba klik bottonnya, pilih file imagenya

Capture

dan sukses terupload sempurna

Silahkan dkreasi sendiri,OK sukses 🙂


Tips 1 Line di Detail Report Foxpro

Agustus 24, 2016

Bingung mau kasih judul apa 😀 pokonya liat aja deh maksud dan tujuannya hihi, berikut penjelasan singkatnya, Ok rencana mau bikin report dengan tampilan begini

x

dan pengennya itu didetail biar dinamis perihalnya bisa aja lebih 1 dan pasalnya juga bisa lebih 1, Ok ,kita desain aja reportnya, ups sebelumnya kita bikin contoh cursor dulu


CREATE CURSOR cData (cKet C(15),cPerihal C(15))

INSERT INTO cData values("Perihal","1. Alamat Saya")
INSERT INTO cData values("Perihal","2. Alamat Temana")
INSERT INTO cData values("Perihal","3. Alamat Siapa Saja")

INSERT INTO cData values("Pasal","1. Pasal 45 Ayat 1")
INSERT INTO cData values("Pasal","2. Pasal 30 Ayat 2")

SELECT cData
REPORT FORM 'report\report1' PREVIEW

naa desain reportnya begini

1

dan klik kanan pada field cKet pilih propertis, pilih print when

2

udah selesai dan hasilnya

2

naa bisa kan 😀

 

 


Menghitung Parsing ISO 8583 dengan foxpro

Agustus 22, 2016

Ini cuma cara sederhana (maksudnya cara yg saya bisa 😀 akalin )

langsung aja yaa, cara ngitungnya ada disini bacanya

https://lmanxp.wordpress.com/2011/04/09/parsing-iso8583/

dan dengan sintak foxpro

 


Clear
Create Cursor siso ( nbit C(3),cTipe C(10),nPanjang N(3),nfix N(3))
Insert Into siso Values("1","b",32,0)
Insert Into siso Values("7","n",10,0)
Insert Into siso Values("11","n",6,0)
Insert Into siso Values("33","n",11,1)
Insert Into siso Values("70","n",3,0)
iso8583("080082200000800000000400000000000000000000590100000103123001")
Function iso8583(cIso)
Local lnbaris[30],lnbits[30],dataMit[15]

*MTI
cMti=Substr(cIso,1,4)
*MTI Sisa
cSisa=Substr(cIso,Len(cMti)+1)

huruf1=Left(cSisa,1)
*Panjang Bit map hex2bin
nPBitmap=hex2bin(huruf1)
nPBitmap=Iif(Left(nPBitmap,1)="0",16,32)

*Bit 1 Lokasi BitMap
nDataSisa=Substr(cSisa,1,nPBitmap)

*sisa BitMap
nSisa=Substr(cSisa,nPBitmap+1)
*Bit 1
datasisa=nSisa

j=0
lnUrut=""
lnurutxx=""
i=0
For i=1 To Len(nDataSisa)
lnurutxx=hex2bin(Substr(nDataSisa,i,1))
lnUrutx=lnUrut+lnurutxx
lnUrut=lnUrutx
Endfor
i=0

*hitung Bitmap Aktif=1
For i=1 To Len(lnUrut)
lnaktif=Substr(lnUrut,i,1)
If Alltrim(lnaktif)="1"
j=j+1
lnbaris[j]=i
Endif
Endfor
j=0
x=0

Select siso
Scan
x=x+1
lnBit=nbit
lcTipe=cTipe
lnPanjang=nPanjang
lnfix=nfix
If ALLTRIM(lcTipe)="b"
Loop
ENDIF
*panjang statis
If lnfix=0
ctmp=Substr(datasisa,1,lnPanjang)
If Len(ctmp)=lnPanjang
If lcTipe="n"
dataMit[x] = Substr(datasisa,1,lnPanjang)
Else
dataMit[x]= Alltrim(Substr(datasisa,1,lnPanjang))
Endif
datasisa=Substr(datasisa,lnPanjang+1,Len(datasisa)-lnPanjang)
Endif

ELSE
*panjang Dinamis
nLen = Len(Alltrim(Str(lnPanjang)))
ctmp=Substr(datasisa,1,nLen)
If Len(ctmp)=nLen
cNum=INT(val(ctmp))
datasisa=Substr(datasisa,nLen,Len(datasisa)+nLen)

cTmp2= Substr(datasisa,1+1,cNum)
If Len(cTmp2)=cNum
If lcTipe="n"
dataMit[x] =INT(Val(cTmp2))
Else
dataMit[x] =cTmp2
Endif
datasisa=Substr(datasisa,(cNum+1)+1,Len(datasisa)-cNum)
Endif
Endif
Endif

Endscan
i=0
For i=1 To 15
If Vartype(dataMit[i])="L"
Loop
Endif
?IIF(VARTYPE(dataMit[i])="N",ALLTRIM(STR(dataMit[i])),dataMit[i])
Endf
Endfunc

Function hex2bin
Parameters cHexString

Store '' To cBinString, cBinString1
Store Len(cHexString) To nStrLen
For zzz = 1 To nStrLen
cBinString = cBinString + ;
Padl(dec2basx(Int(Val('0x' + Substr(cHexString, zzz, 1))), 2), 4, '0')
Next
Return cBinString

Function dec2basx
Parameters nTempNum, nNewBase

Store 0 To nWorkVal,;
remainder,;
dividend,;
nextnum,;
digit

nWorkVal = nTempNum
ret_str = ''

Do While .T.
digit = Mod(nWorkVal, nNewBase)
dividend = nWorkVal / nNewBase
nWorkVal = Int(dividend)

Do Case
Case digit = 10
ret_str = 'a' + ret_str
Case digit = 11
ret_str = 'b' + ret_str
Case digit = 12
ret_str = 'c' + ret_str
Case digit = 13
ret_str = 'd' + ret_str
Case digit = 14
ret_str = 'e' + ret_str
Case digit = 15
ret_str = 'f' + ret_str
Otherwise
ret_str = Ltrim(Str(digit)) + ret_str
Endcase

If nWorkVal = 0
Exit
Endif ( nWorkVal = 0 )
Enddo ( .T. )
Return ret_str

dan hasilnya

1

OK ini cuma contoh 😀

 


Remote Database Hosting dengan Visual Foxpro

Agustus 12, 2016

langsung aja nih hemat kouta 🙂 lg ga ada duit 😀 (mohon donasinya) 😀

kali ini saya memberikan pencerahan cara remote database di hosting , ingat hosting berbayar

pertama, pastinya masuk ke cpanel hosting,bikin database, terus bikin username dan password

1

pastikan juga user privilages pada database yang dibuat tadi conteng semua

1

terus Remote database access hostnya kasih %

1

kecuali kalian punya IP client yg statis bisa didaftarkan siapa aja yg bisa akses, not rekomen pake %

selesai

kedua, di foxpronya, sintaxnya sama kaya connect di lan,


lcconn="Driver={MySQL ODBC 5.1 Driver};Server=NamaDomain;Database=namadatabase;User=usernamenya;Password=passwordnya;Option=3;"
nch=SQLSTRINGCONNECT(lcconn)

btw saya gunakan jagoanhosting