func CallAndConnect:integer intparm DialNum INTEGER r=0 long timeout =0 set dialdir maxdial redials #ifndef test if dial DialNum assign s0, "Dialing" statmsg "waiting for call to complete" timeout=$ltime+dialtime while $dialing if $ltime >= timeout statmsg "connect timed out" dialcancel ; turn off the dialing directory assign s0, "Dial Failed" exitwhile endif endwhile if success statmsg "waiting for carrier" timeout=$ltime+waittime strcmp s0, "Dialing" if success while ! $CARRIER if $ltime >= timeout statmsg "connect timed out" r=0 assign s0, "Connect Failed" exitwhile endif endwhile endif if $carrier r=1 endif endif endif #else r=1 ; in test mode force return to OK (1) #endif return r endfunc