Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Delphi and a dial-up modem, to dial several numbers.

Status
Not open for further replies.

draakans

Programmer
Dec 20, 2007
13
CA
Hello, I'm using Delphi for few years but I've been doing some really basics stuff yet. Actually, I'm working on a program with Delphi 7.

Basically, it's a program to make orders. There is a phone system where you have to dial all items manually. I want to use my dial-up modem to make it automatically.

In my program, You use check boxes to select items (which are related to an item number). Then I press "ORDER" and It appears like that on a TMemo.

1-555-555-5555
4 // options
*2355322# // user ID
12345678 // password
1 // new order
123456 * 1# {items * quantity and # to confirm the end of a lines}
234567 * 3#
345678 * 10#
678901 * 5# {end}
# // end of order
1,,,9 // 1 to confirm, 9 to disconnect.
THE-END

I use a string. I append each Memo.lines to it with ',,,' between (to give the time to the phone system). I figured out that a string was only 256 char max. So I'm trying with a widestring. But I can't get it to work.

First, I've been using TTapiDial Component as well as HbTapi. But it wasn't working properly.
I had to make short orders of like 5-6 items at the time, hang up and start over with some other items. That could take up to 7 times sometimes to pass through the whole order.

I gave up on that few months ago. But yesterday, I said : THAT HAS TO BE DONE :) . So I reconsider some codes and I tried with Window's Tapi32.DLL (TapiRequestMakeCall). But I can't dial as a widestring, it only signal 1 digit. I tried with a PWideChar (cause I think it needs a Null terminated string) and I have the same issue.

Basically, I need something that would :

Pick Up the phone line and hold it,
dial line by line
release the phone line when it's done.

It sounds so simple. But right now I'm running out of ideas. I have googled for hours! Tried several thing, but can't get it done.

Any comments, suggest, question are really welcomed!!!
HELPPPP please!!!
thx :)
Yannick.
 
Wow - a flashback to the 90's!

If you must work with a modem, AsyncPro (free download from SourceForge) is the only way to go:

History:
Developed by TurboPower - then later donated to public domain via Source Forge.



Roo
Delphi Rules!
 
Hey, thanks for your reply. It looks like the company I'm working with is still in the 90's lol. There's a way to do order via Internet but they don't want to allow it. They say we would order to many things. But that's another story.

So I've installed AsyncPro which is great. But it gives the same result as TapiDial or HBtapi. It seems to be a way more complete program though.

I tried using ApdTapiDevice and I understand something. It's not a string issue. I "showmessage" of the string to dial. It contains all items and the last codes which should terminated the order and accept it. (#,,1,,,9)

But at some point (while dialing items) it stops dialing. Probably the ApdTapiDevice.dial has a phone number max length.

I've tried with ApdComPort1.Output (which send order to the modem directly)

ApdComPort1.Output := 'ATZ'#13;
ApdComPort1.Output := 'ATDT 1-555-555-5555'#13;
ApdComPort1.Output := 'ATDT ,,,4,,,'#13;

But it doesn't work, It crashes at the second ATDT saying that the modem is already dialing. However IF I could find a way to make it works with the Comport.output that would definitely be the best way. I could add items by items... Any thought?
 
It crashes at the second ATDT saying that the modem is already dialing.
That is exactly what you should expect after sending 2 consecutive "dial" commands. [ATDT]

It's been too long for me to remember the sequencing structure, and don't have AsyncPro in my current Delphi, or a modem in my PC, but have you tried just dropping the second modem dial command?
Code:
  ApdComPort1.Output:= 'ATZ'#13;
  ApdComPort1.Output:= 'ATDT 1-555-555-5555'#13;
  ApdComPort1.Output:= ',,,4,,,'#13;
or combining them
Code:
  ApdComPort1.Output:= 'ATZ'#13;
  ApdComPort1.Output:= 'ATDT 1-555-555-5555'#13',,,4,,,'#13;
There should have been some demo code in your download you could look at...

Roo
Delphi Rules!
 
Hey, thank again for your reply :)

First I just notice I didn't put 'ATZ' 1st. I tried with It and it doesn't want to dial at all. I add to set ComPort to 3 cause it wasn't able to auto-detect it. I guess since ATZ is reset it might be resetting the ComPort value to 0 (which is auto-detect).

But still, I 've tried both ways. Using the 1st method was only dialing the line with ATDT on it. And for the 2nd method, it appears like the ApdComport1.Output doesn't want command larger than 32 chars.

Working:
apdComport1.Output := 'ATDT 15555555555,,,,,4,,,,*23553220,,21088500#,,,1,,195626*1#,107190*1#,,#,,4,,9'#13;

Not Working:
apdComport1.Output := 'ATDT 18882776447,,,,,4,,,,*23553220,,21088500#,,,1,,195626*1#,107190*1#1,,#,,4,,9'#13;

It's disappointing cause I really thought the 1st method was a damn good idea lol.
 
Please understand you are using different components from the package than I did and it was way over 10 years ago. 32 may be a default max length, you may be able to change that. I'd consult the documentation.

Based on your first error, I would assune that calling apdComport1.Output sends a string to the port and that two consecutive calls will work. That said, I'd break it up... like this:
Code:
  apdComport1.Output:= 'ATDT 15555555555'#13;
  //put call to function to verify connected here
  apdComport1.Output:= ',,,,,4,,,,*23553220,,21088500#,,,1,,195626*1#,107190*1#,,#,,4,,9'#13;
In short:
1) Dial
2) Wait for connection
3) Send request string


Roo
Delphi Rules!
 
I red some pages, but the pdf file as around 260 pages. I ll read it more carefully.
 
Several years ago I did an application that used a serial port modem extensively. I used AsyncPro. I was able to get the modem to pretty much jump through all the hoops and loops I needed, but everything was completely event driven - that is, I would wait for the modem's response to each operation or message I sent it, and based on its response I would take the next step. I never assumed that a command sent to the modem was a command received and correctly interpreted. Async has everything you need to do this. The code was not the simplest to walk through since which function or method would be called next was determined by previous events, but it was reliable and effective.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top