Now see what I am using this for! It works good apart from the sleep...because when the application is asleep It CANT make a phone call!!!
Why does delphi code ether go faster than sonic the hedgehog or complete stop? isn't there a choice of speed??
My counting method looks ok but its no good for timing actions as all the sleep does is stop the code...If i take the sleeps out then it counts 12345678910 but it does it so fast that all you see is 10 because by the time its started its already finished!!!!
I need some sort of menial task that it can do instead of pausing the whole application (like juggling for a specified number of seconds), other wise my code will never work...
any ideas?
procedure TMainForm.STARTClick(Sender: TObject);
var
Stage : Integer;
pin : String;
InDevice, OutDevice: Cardinal;
begin
Stage := 0;
Repeat
//1
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
CurrentAccount := SimpleSip1.AddAccount(a1SIPCLIENT.Text, a1ACCOUNT.Text, PASSWORDALL.Text);
CurrentAccount._AddRef;
ACTIONL.Caption := 'REGISTRATION SUCCESS!';
SimpleSip1.RegisterAccount(CurrentAccount);
Sleep(0001);
Application.ProcessMessages;
//Start to fill CallPack*1*
//2
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
InDevice := AudioInDeviceNameToDeviceID(waveInDevice.Items[waveInDevice.ItemIndex]);
OutDevice := AudioInDeviceNameToDeviceID(waveOutDevice.Items[waveOutDevice.ItemIndex]);
CurrentCall := SimpleSip1.AddCall(CurrentAccount, PhoneEdit.Text, InDevice, OutDevice); //*1
CurrentCall._AddRef;
ACTIONL.Caption := 'CALLING CurrentCall: '+PhoneEdit.Text+'...';
Sleep(4000);
Application.ProcessMessages;
//3
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
ACTIONL.Caption := 'Sending Pin';
pin := 'ben pin';
pin := ExtractFilePath(ParamStr(0))+pin+'.wav';
SimpleSip1.PlayWavFile(CurrentCall, pin);
Sleep(22000);
Application.ProcessMessages;
//4
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.HoldCall(CurrentCall);
ACTIONL.Caption := 'CurrentCall on Hold';
Sleep(4000);
Application.ProcessMessages;
//5
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
CallPack[1] := CurrentCall;
ACTIONL.Caption := 'CurrentCall Transferred to CallPack*1*';
Sleep(2000);
Application.ProcessMessages;//Now CallPack*1* has 1 call
//6
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
InDevice := AudioInDeviceNameToDeviceID(waveInDevice.Items[waveInDevice.ItemIndex]);
OutDevice := AudioInDeviceNameToDeviceID(waveOutDevice.Items[waveOutDevice.ItemIndex]);
CurrentCall := SimpleSip1.AddCall(CurrentAccount, PhoneEdit.Text, InDevice, OutDevice); //*1
CurrentCall._AddRef;
ACTIONL.Caption := 'CALLING CurrentCall: '+PhoneEdit.Text+'...';
Sleep(2000);
Application.ProcessMessages;
//7
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
ACTIONL.Caption := 'Sending Pin';
pin := 'ben pin';
pin := ExtractFilePath(ParamStr(0))+pin+'.wav';
SimpleSip1.PlayWavFile(CurrentCall, pin);
Sleep(1300);
Application.ProcessMessages;
//8
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.HoldCall(CurrentCall);
ACTIONL.Caption := 'CurrentCall on Hold';
Sleep(1300);
Application.ProcessMessages;
//9
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
CallPack[2] := CurrentCall;
ACTIONL.Caption := 'CurrentCall Transferred to CallPack*1*';
Sleep(2000);
Application.ProcessMessages;//Now CallPack*1* has 2 call (FULL)
//FULL notice *** CallPack*2*
//10
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
ACTIONL.Caption := 'CallPack*1* is FULL...';
Sleep(2000);
Application.ProcessMessages;
//Hold/UnHold CallPack*1*
//11
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.UnHoldCall(CallPack
);
ACTIONL.Caption := 'UnHold CallPack*1* -3sec-';
Sleep(2000);
Application.ProcessMessages;
//12
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.HoldCall(CallPack);
ACTIONL.Caption := 'CallPack*1* on Hold';
Sleep(3000);
Application.ProcessMessages;
//CallPack*1* Transferred to BOX
//13
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
CallPack := BOX[1];
ACTIONL.Caption := 'CallPack*1* Transferred to BOX';
Sleep(2000);
Application.ProcessMessages;//Now BOX has 1 CallPack
//******************************************************************************CallPack 1 END
//Start to fill CallPack*2*
//14
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
InDevice := AudioInDeviceNameToDeviceID(waveInDevice.Items[waveInDevice.ItemIndex]);
OutDevice := AudioInDeviceNameToDeviceID(waveOutDevice.Items[waveOutDevice.ItemIndex]);
CurrentCall := SimpleSip1.AddCall(CurrentAccount, PhoneEdit.Text, InDevice, OutDevice); //*1
CurrentCall._AddRef;
ACTIONL.Caption := 'CALLING CurrentCall: '+PhoneEdit.Text+'...';
Sleep(2000);
Application.ProcessMessages;
//15
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
ACTIONL.Caption := 'Sending Pin';
pin := 'ben pin';
pin := ExtractFilePath(ParamStr(0))+pin+'.wav';
SimpleSip1.PlayWavFile(CurrentCall, pin);
Sleep(13000);
Application.ProcessMessages;
//16
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.HoldCall(CurrentCall);
ACTIONL.Caption := 'CurrentCall on Hold';
Sleep(4000);
Application.ProcessMessages;
//17
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
CallPack[1] := CurrentCall;
ACTIONL.Caption := 'CurrentCall Transferred to CallPack*2*';
Sleep(2000);
Application.ProcessMessages;//Now CallPack*2* has 1 call
//18
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
InDevice := AudioInDeviceNameToDeviceID(waveInDevice.Items[waveInDevice.ItemIndex]);
OutDevice := AudioInDeviceNameToDeviceID(waveOutDevice.Items[waveOutDevice.ItemIndex]);
CurrentCall := SimpleSip1.AddCall(CurrentAccount, PhoneEdit.Text, InDevice, OutDevice); //*1
CurrentCall._AddRef;
ACTIONL.Caption := 'CALLING CurrentCall: '+PhoneEdit.Text+'...';
Sleep(200);
Application.ProcessMessages;
//19
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
ACTIONL.Caption := 'Sending Pin';
pin := 'ben pin';
pin := ExtractFilePath(ParamStr(0))+pin+'.wav';
SimpleSip1.PlayWavFile(CurrentCall, pin);
Sleep(13000);
Application.ProcessMessages;
//20
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.HoldCall(CurrentCall);
ACTIONL.Caption := 'CurrentCall on Hold';
Sleep(4000);
Application.ProcessMessages;
//21
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
CallPack[2] := CurrentCall;
ACTIONL.Caption := 'CurrentCall Transferred to CallPack*2*';
Sleep(2000);
Application.ProcessMessages;//Now CallPack*2* has 2 call (FULL)
//FULL notice *** CallPack*2*
//22
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
ACTIONL.Caption := 'CallPack*2* is FULL...';
Sleep(2000);
Application.ProcessMessages;
//Hold/UnHold CallPack*2*
//23
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.UnHoldCall(CallPack);
ACTIONL.Caption := 'UnHold CallPack*2* -3sec-';
Sleep(2000);
Application.ProcessMessages;
//24
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.HoldCall(CallPack);
ACTIONL.Caption := 'CallPack*2* on Hold';
Sleep(3000);
Application.ProcessMessages;
//CallPack*2* Transferred to BOX
//25
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
CallPack := BOX[2];
ACTIONL.Caption := 'CallPack*2* Transferred to BOX';
Sleep(2000);
Application.ProcessMessages;//Now BOX has 1 CallPack
//******************************************************************************CallPack 1 END
//Begin UnHold/Hold BOX
//BOX 6x Hold/UnHold
//26
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.UnHoldCall(BOX);
ACTIONL.Caption := 'UnHold BOX -3sec-';
Sleep(2000);
Application.ProcessMessages;
//27
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.HoldCall(BOX);
ACTIONL.Caption := 'BOX on Hold -30sec-';
Sleep(3000);
Application.ProcessMessages;
//28
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.UnHoldCall(BOX);
ACTIONL.Caption := 'UnHold BOX -3sec-';
Sleep(30000);
Application.ProcessMessages;
//29
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.HoldCall(BOX);
ACTIONL.Caption := 'BOX on Hold -30sec-';
Sleep(3000);
Application.ProcessMessages;
//30
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.UnHoldCall(BOX);
ACTIONL.Caption := 'UnHold BOX -3sec-';
Sleep(30000);
Application.ProcessMessages;
//31
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.HoldCall(BOX);
ACTIONL.Caption := 'BOX on Hold -30sec-';
Sleep(3000);
Application.ProcessMessages;
//32
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.UnHoldCall(BOX);
ACTIONL.Caption := 'UnHold BOX -3sec-';
Sleep(30000);
Application.ProcessMessages;
//33
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.HoldCall(BOX);
ACTIONL.Caption := 'BOX on Hold -30sec-';
Sleep(3000);
Application.ProcessMessages;
//34
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.UnHoldCall(BOX);
ACTIONL.Caption := 'UnHold BOX -3sec-';
Sleep(30000);
Application.ProcessMessages;
//35
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.HoldCall(BOX);
ACTIONL.Caption := 'BOX on Hold -30sec-';
Sleep(3000);
Application.ProcessMessages;
//36
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.UnHoldCall(BOX);
ACTIONL.Caption := 'UnHold BOX -3sec-';
Sleep(30000);
Application.ProcessMessages;
//37
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.HoldCall(BOX);
ACTIONL.Caption := 'BOX on Hold -30sec-';
Sleep(3000);
Application.ProcessMessages;
//38
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.UnHoldCall(BOX);
ACTIONL.Caption := 'UnHold BOX -3sec-';
Sleep(30000);
Application.ProcessMessages;
//39
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.HoldCall(BOX);
ACTIONL.Caption := 'BOX on Hold -30sec-';
Sleep(3000);
Application.ProcessMessages;
//BOX END CALL
//40
Stage := Stage +1;
STAGEL.Caption := IntToStr(Stage);
SimpleSip1.EndCall(BOX);
ACTIONL.Caption := 'All BOX Calls Ended!';
Sleep(30000);
Application.ProcessMessages;
//END
until Stage = 39;
end;