program SmsSender;
uses sms, web, ui;
var
conn: http;
dest_id, text_id, id, res: integer;
dest, text: string;
cmd, cmdHttp, cmdSms, cmdExit, cmdSelect, cmdCancel: command;
procedure showError(error: string);
begin
showAlert('Error', 'sending incomplete: '+error, loadImage('/icon.png'), ALERT_ERROR);
delay(3000);
end;
procedure getCommand;
begin
cmd:= EmptyCommand;
repeat
cmd := GetClickedCommand;
until cmd <> EmptyCommand;
end;
function getSms(title: string; dst: string): boolean;
begin
ClearForm;
ShowForm;
SetFormTitle(title);
dest_id:= FormAddTextField('Dest number', dst, 20, TF_PHONENUMBER);
text_id:= FormAddTextField('SMS text', '', 450, TF_ANY);
AddCommand(cmdCancel);
AddCommand(cmdSelect);
getCommand;
if cmd=cmdSelect then begin
dest:= FormGetText(dest_id);
text:= FormGetText(text_id);
end;
getSms:= cmd=cmdSelect;
end;
begin
cmdExit := CreateCommand('Exit', CM_EXIT, 1);
cmdSelect := CreateCommand('OK', CM_OK, 1);
cmdCancel := CreateCommand('Cancel', CM_CANCEL, 1);
cmd:= EmptyCommand;
repeat
ShowMenu('Main menu', CH_IMPLICIT);
id:= MenuAppendString('SMS');
id:= MenuAppendString('WebForm SMS');
id:= MenuAppendString('e-mail to SMS');
id:= MenuAppendString('e-mail');
AddCommand(cmdExit);
ui.list_set_select_command(cmdSelect);
getCommand;
if cmd=cmdSelect then begin
id:= MenuGetSelectedIndex;
Debug(IntegerToString(id));
if id=0 then
if getSms('Send SMS', '+37529') then begin
id:= -1;
if sms.send('sms://'+dest, text)=0 then
showError('');
end;
Debug(IntegerToString(id));
if id=1 then
if getSms('Send WebForm', '37529') then begin
id:= -1;
if web.open('http://www.freesms.mts.by/cgi-bin/cgi.exe?function=sms_send')<>0 then begin
web.set_method('POST');
res:= 0;
if web.set_body('MMObjectType=0&MMObjectID=&To='+dest+'&Msg='+text+'&count='+
IntegerToString(Length(text))+'&Hour=0&Min=0&Day=1&Mon=05&Year=2006&Lang=2')<>0 then
res:= web.send;
if res<>200 then
showError(IntegerToString(res));
web.close;
end;
end;
end;
until cmd=cmdExit;
end.
например