Retail POS

www.pcland.com.pk

Monday 16 November 2015

USING SMS API in VISUAL FOXPRO

[Visual fox pro SMS using API]

Visual fox pro uses two method of  programming for SMS sending from VFP build applications.

1. Direct Comport Interface with Local or Network server logging tables/database.

Following two method can be used for this type of communication.
a.) From VFP custom build application, directly open the local Comport, & push the SMS to your mobile operator SMS gateway in real time.

b.) Dedicated VFP build SMS pooling (Push) application is hosted on local or network server.
In this way of sending SMS, a log database (tables) is created & used to Que the messages to Push on SMS gateway on FIFO based algorithm. Pooling application can be configured as "service" or "Startup/Scheduled application" on local or server based machine
Multiple applications can send SMS using this shared way.

VFP  good SMS pooler example with source code to modify according to your needs :

Vivek Deodhar shows you how to send SMS text messages with VFP. smspooler.zip - Download ID: 225



2. WEB-SMS  (Using SMS Gateway on internet via SMS PUSH method) 
In this method , all message is composed locally in VFP application (using variables, properties, or textbox etc.) and merged, validated before Pushing to server according to calling Syntax of every Web Gateway server. (for proper syntax refer to documentation of every service provider)


[WEB SMS] 

1. UFONE API CODE Example:

Local lcUrl, lcresult
lcUrl="http://bsms.ufone.com/bsms_app4/sendapi.jsp?id=011111111&message=&lcTempTxtFile&shortcode=fox&lang=English&mobilenum=&ccnum&password=12345&groupname=groupname"

**-----------------------*
** Red high lighted variable values will be replaced  provided by Ufone against your account.

lcresult = Sms_Push(lcUrl)

wait wind lcresult
RETURN

*------------------------------*
FUNCTION Sms_Push
*-----------------------------*
Lparameters lcurl
Local lcRetstatus, XmlHttpobj As Microsoft.XMLHTTP
lcRetstatus = ""

Try
        XmlHttpobj = Createobject("Microsoft.XMLHTTP")
        XmlHttpobj.Open("GET", lcurl, .F.)
        XmlHttpobj.setRequestHeader("Content-Type", "text/urlencoded")
        XmlHttpobj.Send()
   
    If (XmlHttpobj.Status = 404)
        lcRetstatus = "Error#: 404"
    Else
        lcRetstatus = XmlHttpobj.ResponseText
    endif
   
        XmlHttpobj = Null
Catch To oErr
        lcRetstatus = "Following Error Occurs:"+oErr.Message
endtry

        Return lcRetstatus

endfunc



**************----------------------------------------------*******************************

2. SmsGatewayhub.com  API CODE Example:


Local lcuser,lcPassword,lcUrl, lcresult
lcUrl="http://login.smsgatewayhub.com/smsapi/pushsms.aspx?user="+lcuser+"&pwd="+lcPassword+"&to="+lcNumber+"&sid="+lcuser+"&msg="+lcMsg+"&fl=0&gwid=2"
**-----------------------*
** Red high lighted variable values will be replaced  provided by service provider against your
** account.


 lcresult = Sms_Push(lcUrl)
wait wind lcresult
RETURN


*------------------------------*
FUNCTION Sms_Push
*-----------------------------*
Lparameters lcurl
Local lcRetstatus, XmlHttpobj As Microsoft.XMLHTTP
lcRetstatus = ""

Try
        XmlHttpobj = Createobject("Microsoft.XMLHTTP")
        XmlHttpobj.Open("GET", lcurl, .F.)
        XmlHttpobj.setRequestHeader("Content-Type", "text/urlencoded")
        XmlHttpobj.Send()
   
    If (XmlHttpobj.Status = 404)
        lcRetstatus = "Error#: 404"
    Else
        lcRetstatus = XmlHttpobj.ResponseText
    endif
   
        XmlHttpobj = Null
Catch To oErr
        lcRetstatus = "Following Error Occurs:"+oErr.Message
endtry

        Return lcRetstatus

endfunc

******************************** Code end *******************

Cheers!


Hope this will help you to choose according to your Requirement of SMS for your VFP Application development !

Tuesday 20 January 2015

VFP Scanning using WIA.Common Dialog


Visual Foxpro & Scanning :


Visual Foxpro is having great feature to connect any hardware device  via windows class libraries, it may be  Dynamic link Library (.dll), Object Linking and Embedding OCX, Foxpro Link Library (.Fll) or Window API calls.

These all above need's proper syntax & calling method parameters to use in programming. Passing parameter type and function /procedure returning value type.

Now coming toward our scanning project.Here we will use a easy & common way of scanning a document in vfp using windows API  library call of "WIA.CommonDialog".

This library interacts with scanning or capturing device's driver provided by manufacturer of this device,  stores basic properties and relevant data as windows API interface.

Well different manufacture uses different methods & properties of their dll/ocx declaration. That is not our headace because we are not interacting their .dlls or ocx to get directly data from driver libraries.

We will use WIA.CommonDialog to get any device's list of  properties, names &  values  with VFP. This list of properties will help us to manage our desired out put format & relevent size of scanned document as our requirement.

Note:

* For adjusting properties of any device we have to communicate directly with device by calling functions of dll/ocx. WIA.CommonDialog will not allow to adjust properties values in some cases.


*********************************************
* Programe :   ReadScanner.prg
* Author :     witten by Zia Mughal

* CopyRight :  Pcland Software Inc. Pakistan
* http://www.pcland.com.pk
**********************************

#DEFINE WIA_FORMAT_JPEG = "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"
#DEFINE DPI = 150  && or what you want

LOCAL cdg As Object
cdg = CREATEOBJECT("Wia.CommonDialog")
DevMgr = CREATEOBJECT ("WIA.DeviceManager")

 dev = cdg.ShowSelectDevice
clear

set printer to fullpath(sys(2003))+"\Property.txt"
set printer on
set device to printer

**  May your loop vary according to device properties
for i=1 to 33 step 1
a= dev.Properties(i).name
b= dev.Properties(i).value
? alltrim(str(i)) + " : "
??  alltrim(a) + " = "
?? b
endfor
set device to screen
set printer off
set printer to

modify file fullpath(sys(2003))+'\Property.txt' noedit
********assume example of HP scanjet g4050
*dev.properties(24).value = 2  && 'Access Rights
*dev.properties(25).value = 300  && 'DPI horizontal
*dev.properties(26).value = 300  && 'DPI horizontal

*dev.properties(6149).value = 0 && 'x point to start scan
*dev.properties(6150).value = 0 && 'y point to start scan
*dev.properties(6151).value = 8.5 * DPI && 'Horizontal Extent
*dev.properties(6152).value = 11# * DPI && 'Vertical Extent for letter

Img = cdg.ShowAcquireImage
IF ISNULL(Img)
WAIT WINDOW TIMEOUT 1 "User Cancelled"
RETURN .F.
ENDIF
*dev.Transfer(WIA_FORMAT_JPEG)
Img.SaveFile(FULLPATH(sys(2003))+"\test.jpg")

************************************************

Enjoy the COFFEE!
My Respects!