![]() |
| | #1 |
| Registered User Join Date: Aug 2009
Posts: 2
| TCL Scripting I want to ask someone to explain to me the syntax below. This syntax is a TCL script. And I want to modify it in order for it to work with my RADIUS Billing Server. Code: proc do_get_card_number {} {
global state
global account
global pin
global promptFlag
global count
global accountLen
global pinLen
global retryCnt
global prefix
global param1
global param2
set cardLen [expr $accountLen + $pinLen]
set param1(maxDigits) $cardLen
if {$count == 0} {
set ev [playPrompt param1 info [set prefix]_enter_card_num.au]
} else {
switch -regexp $promptFlag {
{1} {set ev [playPrompt param1 info [set prefix]_invalid_digits.au]}
{2} {set ev [playPrompt param1 info [set prefix]_auth_fail.au]}
{3} {set ev [playPrompt param1 info [set prefix]_no_card_entered.au]}
}
}
switch -regexp $ev {
{collect success} {set number $info(digits)
set numberlen [string length $number]
if {$numberlen == $cardLen} {
set account [ string range $number 0 [expr $accountLen -1]]
set pin [ string range $number $accountLen [expr $cardLen -1]]
set state do_first_authorize
} else {
incr count
set promptFlag 1
if {$count < $retryCnt} {
set state do_get_card_number
} else {
# no more tries
set ev [playPrompt param2 info [set prefix]_final.au]
set state end
}
}
}
{collect aborted} {set state do_get_card_number}
{collect fail} -
{collect timeout} {incr count
set promptFlag 3
if {$count < $retryCnt} {
set state do_get_card_number
} else {
set ev [playPrompt param2 info [set prefix]_final.au]
set state end
}
}
default {set state end}
}
return 0
}
proc do_first_authorize {} {
global state
global pin
global account
global count
global retryCnt
global promptFlag
global prefix
global param2
global amt
global returncode
set ev [authorize $account $pin "" [ani] info]
set returncode [getVariable radius returnCode]
switch -regexp $ev {
{authorized} {set amt [getVariable radius creditAmount]
set state do_get_dest
}
{authorization failed} {incr count
set promptFlag 2
if {$returncode == "Uknown variable name"} {
set ev [playPrompt param2 info [set prefix]_no_aaa.au]
set state end
return 0
}
if { $count < $retryCnt } {
set state do_get_card_number
} else {
set state do_first_authorize_fail
}
}
default {set state end}
}
return 0
}
|
| johndejesus is offline | |
| | #2 |
| critical genius Join Date: Jul 2008 Location: SE Queens
Posts: 5,201
| What don't you understand? |
| MK27 is offline | |
| | #3 |
| Registered User Join Date: Oct 2008
Posts: 563
| Completely offtopic... I've looked at TCL a few times... And every time the same thought forms in my brain: That's gotta be one of, if not the, most horrible languages ever invented. That includes brainfok Seriously, I'd rather code amsn in brainfok than in this piece of sht. The forum filters out the bad words, so I had to do it like this. |
| EVOEx is offline | |
| | #4 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,693
| Moved to tech (other post deleted) |
| Salem is offline | |
| | #5 |
| Registered User Join Date: Aug 2009
Posts: 2
| Like [set prefix], $, expr, switch, and ev. what does it do ? |
| johndejesus is offline | |
| | #6 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,693
| Tcl Tutorial While you're working out what it does, you'll be learning how to change it to do what you want. |
| Salem is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| cgi scripting using c | cmay | C Programming | 18 | 07-15-2009 10:05 AM |
| Reviving my old scripting language. | suzakugaiden | Game Programming | 4 | 06-15-2006 03:02 PM |
| Scripting | loopshot | Game Programming | 2 | 03-24-2006 06:29 PM |
| Free scripting library? | PsychoBrat | Windows Programming | 3 | 11-09-2002 03:49 AM |