C Board  

Go Back   C Board > Community Boards > Tech Board

Reply
 
LinkBack Thread Tools Display Modes
Old 08-06-2009, 08:26 AM   #1
Registered User
 
Join Date: Aug 2009
Posts: 2
TCL Scripting

Hi,

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   Reply With Quote
Old 08-06-2009, 08:43 AM   #2
critical genius
 
MK27's Avatar
 
Join Date: Jul 2008
Location: SE Queens
Posts: 5,201
What don't you understand?
__________________

"A man can't just sit around." -- Larry Walters
MK27 is offline   Reply With Quote
Old 08-06-2009, 08:47 AM   #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   Reply With Quote
Old 08-06-2009, 09:20 AM   #4
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,693
Moved to tech (other post deleted)
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

Salem is offline   Reply With Quote
Old 08-07-2009, 02:59 AM   #5
Registered User
 
Join Date: Aug 2009
Posts: 2
Like [set prefix], $, expr, switch, and ev. what does it do ?
johndejesus is offline   Reply With Quote
Old 08-07-2009, 03:35 AM   #6
and the hat of Jobseeking
 
Salem's Avatar
 
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.
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

Salem is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 06:35 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22