source: tol/tolbase/lib/byswidget/bfunctions/bftoltcl.tcl

devel
Last change on this file was 5e5a20f, checked in by Jorge Pérez <josp.jorge@…>, 16 years ago

updating to changes in [tol::info variable ...]

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@2669 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 22.2 KB
Line 
1#/////////////////////////////////////////////////////////////////////////////
2# FILE    : bftoltcl.tcl -> BfT
3# PURPOSE : Bayes Function TolTcl. Functions for easy Tol-Tcl comunication
4#/////////////////////////////////////////////////////////////////////////////
5
6variable TclData
7
8#///////////////////////////////////////////////////////////////////////////
9  proc TolDateFormat2TclDateFormat {format} {
10# PURPUSE: Translates TolDateFormat to TclDateFomat
11#
12# PARAMETERS:
13#   format : TOL date format
14# RETURN: Tcl date format
15#
16#///////////////////////////////////////////////////////////////////////////
17  regsub  %u $format "" format
18  regsub  %c $format "" format
19  regsub  %W $format "%A" format
20  regsub  %N $format "%B" format
21  regsub  %w $format "%a" format
22  regsub  %n $format "%b" format
23  regsub  %h $format "%H" format
24  regsub  %i $format "%M" format
25  regsub  %s $format "%S" format
26  return $format
27}
28
29#/////////////////////////////////////////////////////////////////////////////
30  proc GetUniqueName {gra {seed _TOLTK}} {
31#
32# PURPOSE: Gets a unique Name for a given grammar. Optionally user can give
33#          the initial part of the name
34#
35# PARAMETERS:
36#   gra : TOL Grammar
37#   seed: initial part of the name
38#
39#/////////////////////////////////////////////////////////////////////////////
40  set i 1
41  set end 0
42  set name $seed
43  while {[string equal $end 0]} {
44    if [catch {::tol::info variable [ list $gra $name ]}] {
45      set end 1
46    } else {
47      set name ${seed}_$i
48      incr i
49    }
50  }
51  return $name
52}
53
54#/////////////////////////////////////////////////////////////////////////////
55  proc GetGlobalUniqueName {{seed _TOLTK}} {
56#
57# PURPOSE: Gets a unique Name independent of grammar. Optionally user can give
58#          the initial part of the name
59#
60# PARAMETERS:
61#   seed: initial part of the name
62#
63#/////////////////////////////////////////////////////////////////////////////
64  set i 1
65  set end 0
66  set name $seed
67  # list of grammars
68  set lstGra [::tol::info grammars]
69
70  while {[string equal $end 0]} {
71    set end 1
72    foreach gra $lstGra {
73      set inf [TclInfoVar $gra $name]
74      if {[string length $inf]} {
75        set end 0
76      }
77    }
78    if { !$end } {
79      set name ${seed}_$i
80    }
81    incr i
82  }
83  return $name
84}
85
86#/////////////////////////////////////////////////////////////////////////////
87proc TclInfoVar {gra obj} {
88#
89# PURPOSE: Get the value of variable TOL
90#
91# PARAMETERS:
92#   gra: grammar of variable TOL
93#   obj: name of variable TOL
94#
95# RETURN: output [::tol::info var obg] information in "array get"
96#
97#/////////////////////////////////////////////////////////////////////////////
98  # eval
99  if {![catch {set lst [::tol::info variable [list $gra $obj]]}]} {
100    set lstNam [list CONTENT PATH DESC INDEXES ISFILE\
101                     HASSUBSET SUBTYPE STRUCT]
102    for {set i 0} {$i < [llength $lstNam]} {incr i} {
103      set inf([lindex $lstNam $i]) [lindex $lst [expr $i+2]]
104    }
105    #parray inf
106    return [array get inf]
107  }
108  # error
109  return {}
110}
111
112
113#/////////////////////////////////////////////////////////////////////////////
114proc TclInfoRef {obj args} {
115#
116# PURPOSE: Get the value for Set TOL
117#
118# PARAMETERS:
119#   obj:  reference of TCL
120#   args: index of set
121#
122# RETURN: output [::tol::info var ref] information in "array get"
123#
124#/////////////////////////////////////////////////////////////////////////////
125  # eval
126  set cmd "::tol::info variable {$obj $args}"
127  #puts "TclInfoRef: cmd=$cmd"
128  if {![catch {set lst [eval $cmd]}]} {
129    set lstNam [list GRAMMAR NAME CONTENT PATH DESC ISFILE\
130                     HASSUBSET SUBTYPE STRUCT]
131    for {set i 0} {$i < [llength $lstNam]} {incr i} {
132      set inf([lindex $lstNam $i]) [lindex $lst [expr $i]]
133    }
134    #parray inf
135    return [array get inf]
136  }
137  return {}
138}
139
140
141#/////////////////////////////////////////////////////////////////////////////
142proc TclInfoFun {gra fun} {
143#
144# PURPOSE: Get the value of Set TOL
145#
146# PARAMETERS:
147#   gra: grammars of functions TOL
148#   fun: name of function
149#
150# RETURN: output [::tol::info functions gre fun] information in "array get"
151#
152#/////////////////////////////////////////////////////////////////////////////
153  # eval
154  set cmd "::tol::info functions $gra $fun"
155  #puts "cmd: $cmd"
156  if {![catch {set lst [eval $cmd]}]} {
157    set lstNam [list CONTENT PATH DESC]
158    for {set i 0} {$i < [llength $lstNam]} {incr i} {
159      set inf([lindex $lstNam $i]) [lindex $lst $i]
160    }
161    #parray inf
162    return [array get inf]
163  }
164  return {}
165}
166
167#/////////////////////////////////////////////////////////////////////////////
168proc TclInfoInc {fil} {
169#
170# PURPOSE: Get the value of file included in TOL
171#
172# PARAMETERS:
173#   fil: name of file included en TOL
174#
175# RETURN: output [::tol::info included fil] information in "array get"
176#
177#/////////////////////////////////////////////////////////////////////////////
178# eval
179  set cmd "::tol::info included $fil"
180  #puts "cmd: $cmd"
181  if {![catch {set lst [eval $cmd]}]} {
182    set lstNam [list CONTENT PATH DESC HASSUBSET SUBTYPE STRUCT]
183    for {set i 0} {$i < [llength $lstNam]} {incr i} {
184      set inf([lindex $lstNam $i]) [lindex $lst $i]
185    }
186    #parray inf
187    return [array get inf]
188  }
189  return {}
190}
191
192proc TclFindObjectRoot { ref } {
193  set type [ lindex $ref 0 ]
194  if { $type eq "File" } {
195    set ref_root [ lrange $ref 0 2 ]
196  } else {
197    set ref_root [ lrange $ref 0 1 ]
198  }
199  # verifico si ref_root es un objeto con nombre
200  set info_root [ ::tol::info var $root ]
201  set name_root [ lindex $info_root 1 ]
202  if { $name_root eq "" } {
203    # el objeto raiz no tiene nombre, solo nos salvamos si la raiz es
204    # un File y bajando por el camino encontramos algun global con
205    # nombre
206    if { $type eq "File" } {
207      ...
208    }
209  } else {
210    # bingo! la raiz de ref tiene nombre
211    return $name_root
212  }
213}
214
215proc TclRefToNameTol_ { ref } {
216  set type [ lindex $ref 0 ]
217  switch $type {
218    Console {
219      set root [ lrange $ref 0 1 ]
220      set info_root [ ::tol::info var $root ]
221      # verifico si tiene nombre
222      set name_root [ lindex $info_root 1 ]
223      if { $name_root eq "" } {
224        # el objeto raiz no tiene nombre, solo nos salvamos si el
225        # objeto referenciado es global y tiene nombre
226        set info_all [ ::tol::info var $ref ]
227        set grammar_ref [ lindex $info_all 0 ]
228        set name_ref [ lindex $info_all 1 ]
229        if {  $name_ref eq "" } {
230          # no podemos hacer nada, no existe expresion de tol que
231          # pueda recuperar el valor de la referencia ref
232          return ""
233        } else {
234          # chequeamo si es un objeto global con nombre $name.
235          if { [ catch { ::tol::info var [ list $grammar_ref $name_ref ] } ] } {
236            # no se ha podido encontrar $name_ref como variable global en
237            # $grammar_ref
238            return ""
239          } else {
240            # hemos encontrado un objeto en $grammar_ref con nombre
241            # $name_ref. Dado el uso interno de PutName, eso no
242            # asegura que el objeto referenciado en $ref sea el
243            # mismo. Ya seria mala pata!!!!!
244            return $name_ref
245          }
246        }
247      } else {
248        # el objeto raiz tiene nombre, ya vamos mejorando ...
249        set name $name_root
250        foreach i [ lrange $ref 2 end ] {
251          append name "\[$i\]"
252        }
253        return $name
254      }
255    }
256    File {
257    }
258    Set {
259    }
260    NameBlock {
261    }
262  }
263}
264
265#/////////////////////////////////////////////////////////////////////////////
266proc TclRefToNameTol { ref } {
267#
268# PURPOSE: Obtain the name of an object TOL, of the form, name of the joint
269#          father, if it has, and indices of the set, if it has
270#
271# PARAMETERS:
272#   ref: reference to object TOL
273#
274# RETURN: name in format: namaVariable (variable without father)
275#                         namVarFat[x][y][z] (variable with father)
276#/////////////////////////////////////////////////////////////////////////////
277  set ref [lindex $ref 0]
278  #puts "TclRefToNameTol: ref=$ref"
279  # the object belongs to a set?
280  if {[expr [llength $ref] == 1]} {
281    set namTol $ref
282  } else  {
283    #array set infRef [TclInfoRef [lrange $ref 0 1]]
284    array set infRef [TclInfoRef $ref]
285    set namTol $infRef(NAME)
286    #puts "TclRefToNameTol: namTol=$namTol"
287    # name ?
288  #if {[string length $namTol]} {
289      # ckeck parameters
290      #if {[expr [llength $ref] > 2]} {
291        #set lstInx [lrange $ref 2 end]
292        #foreach ind $lstInx {
293          #set namTol $namTol\[$ind\]
294        #}
295      #}
296    #} else  {
297      #set namTol {}
298    #}
299  #}
300  #puts "TclRefToNameTol: namTol=$namTol"
301  return $namTol
302}
303
304
305#/////////////////////////////////////////////////////////////////////////////
306proc TclGetVar {gra obj {property CONTENT}} {
307#
308# PURPOSE: Get a property of a variable TOL (default: returns value)
309#
310# PARAMETERS:
311#   gra: grammar of variable TOL
312#   obj: name of variable TOL
313#   pro: property to return
314#
315# RETURN: the property value requested of the TOL object
316#
317#/////////////////////////////////////////////////////////////////////////////
318  array set tmparray [TclInfoVar $gra $obj]
319  set property [string toupper $property]
320  if { [lsearch [array names tmparray] $property] != -1 } {
321    return $tmparray($property)
322  }
323}
324
325
326#/////////////////////////////////////////////////////////////////////////////
327proc TclGetRef {obj args {property CONTENT}} {
328#
329# PURPOSE: Get a property of a TOL reference (default: returns value)
330#
331# PARAMETERS:
332#   obj: name of TOL object
333#   args: list with reference indexes
334#   property: property to return
335#
336# RETURN: the property value requested of the TOL object
337#
338#/////////////////////////////////////////////////////////////////////////////
339  array set tmparray [eval TclInfoRef $obj $args]
340  set property [string toupper $property]
341  if { [lsearch [array names tmparray] $property] != -1 } {
342    return $tmparray($property)
343  }
344}
345
346
347#/////////////////////////////////////////////////////////////////////////////
348proc TclGetFromSet { type set args } { 
349#
350# PURPOSE: returns the value of a reference in a set that is a real date or
351#          serie element
352# ARGUMETS:
353#  type: grammar of the element beeing accesed in the set
354#  set:  name of the tol set
355#  args: names and indices for indexing the set
356#
357#/////////////////////////////////////////////////////////////////////////////
358  switch -regexp type {
359    [Rr]eal { set type Real }
360    [Tt]ext -
361    [Tt]exto { set type Text }
362    [Dd]ate -
363    [Ff]echa { set type Date }
364  }
365
366  set name [GetGlobalUniqueName _TclGetFromSet]
367  set str "$type $name = $set"
368  foreach arg $args {
369    if { ! [regexp "^\[0-9\]*$" $arg] } {
370      set str [concat $str "\[\"$arg\"\]"]
371    } else {
372      set str [concat $str "\[$arg\]"]
373    }
374  }
375
376  ::tol::console eval $str
377  set result [lindex [::tol::info var [ list $type $name ] ] 2]
378  ::tol::console stack release $name
379  return $result
380}
381
382
383#/////////////////////////////////////////////////////////////////////////////
384proc TclLst2TolSet {lst args} {
385#
386# PURPOSE: returns a TOL code that when is evaluated creates a set equivalent
387#          to a tcl list.
388# ARGUMETS:
389#   lst  -> List to convert to TOL set (code)
390#   args  -> Function's arguments as pairs "-key value"
391#    -level  : Number of sublist levels to transform in TOL Set
392#    -grammar: Gramatica de los elementos del ultimo nivel
393#    -struct : Name of struct
394#
395#/////////////////////////////////////////////////////////////////////////////
396  array set opt [list \
397    -level   1 \
398    -grammar Text \
399    -struct  ""
400  ]
401  array set opt $args
402 
403  # name of struct ?
404  if {[string length $opt(-struct)]} {
405    set struct $opt(-struct)
406  } else {
407    switch -- $opt(-grammar) {
408      Real     { set struct SetOfReal }
409      Date     { set struct SetOfDate }
410      default  { set struct SetOfText }
411    }
412  } 
413  if {![llength $lst]} {
414    return "Copy(Empty)"
415  }
416  if [expr $opt(-level) <= 1] {
417    switch -- $opt(-grammar) {
418      Real     { set code "${struct}([join $lst ,])" }
419      Date     { set code "${struct}([join $lst {,}])" }
420      default  { set code "${struct}(\"[join $lst \",\"]\")" }
421    }
422  } else {
423    set sSet ""
424    foreach ite $lst {
425      lappend sSet [TclLst2TolSet $ite \
426        -level [expr $opt(-level)-1] \
427        -grammar $opt(-grammar)      \
428        -struct  $opt(-struct) ]
429    }
430    set code "SetOfSet([join $sSet ,])"
431  }
432  return $code
433}
434
435#/////////////////////////////////////////////////////////////////////////////
436proc TolSet2TclLst {settol} {
437#
438# PURPOSE: returns a TCL code that when is evaluated creates a set equivalent
439#          to a tol set.
440# ARGUMETS:
441#   settol  -> set tol
442#
443#///////////////////////////////////////////////////////////////////////////// 
444  set name [GetGlobalUniqueName __TolSet2TclLst__]
445  set cmd  "Text $name = TolSet2TclLst($settol);"
446  ::tol::console eval $cmd
447  set result [TclGetVar Text $name]
448  ::tol::console stack release $name
449  if {[string length $result]} {
450    eval set result $result
451  }
452  return $result
453}
454
455#/////////////////////////////////////////////////////////////////////////////
456proc TclGetIdFromName { name cjto {refs ""}} {
457#
458# PURPOSE: returns the access index equivalent to name in the set cjto
459# ARGUMETS:
460#  name: a text indexing the set that should be converted to index
461#  cjto: the TOL set
462#  refs: names and indices indexing the set
463#
464#/////////////////////////////////////////////////////////////////////////////
465  if { $refs ne "" } {
466    if { [TclGetRef $cjto $refs GRAMMAR] != "Set" } { return }
467    set n [lindex [TclGetRef $cjto $refs] 0]
468  } else {
469    set n [lindex [TclGetVar Set $cjto] 0]
470  }
471 
472  for {set i 1} { $i <= $n } { incr i } {
473    if { [TclGetRef $cjto [linsert $refs end $i] NAME] == $name } {
474      return $i
475    }
476  }
477}
478
479#/////////////////////////////////////////////////////////////////////////////
480proc TclInfoExists {gra obj} {
481#
482# PURPOSE: Get the exits of variable TOL
483#
484# PARAMETERS:
485#   gra: grammar of variable TOL
486#   obj: name of variable TOL
487#
488# RETURN: 1 -> Exists
489#         0 -> No
490#
491#/////////////////////////////////////////////////////////////////////////////
492  # eval
493  expr { ! [ catch { tol::info var [ list $gra $obj ] } ] }
494}
495
496
497#/////////////////////////////////////////////////////////////////////////////
498proc TclSetVar {gra obj value} {
499#
500# PURPOSE: Get the exits of variable TOL
501#
502# PARAMETERS:
503#   gra: grammar of variable TOL
504#   obj: name of variable TOL
505#   value: value of variable
506#
507# RETURN: 1 -> Exists
508#         0 -> No
509#
510#/////////////////////////////////////////////////////////////////////////////
511  # exists ?
512  if {[TclInfoExists $gra $obj]} {
513    set cmd "$gra $obj := $value ;"
514  } else {
515    set cmd "$gra $obj = $value ;"
516  }
517  # eval
518  ::tol::console eval $cmd
519}
520
521
522#/////////////////////////////////////////////////////////////////////////////
523proc TclTolEval {cmd} {
524#
525# PURPOSE: Execute sentence TOL
526#
527# PARAMETERS:
528#   cmd: sentenc
529#
530#/////////////////////////////////////////////////////////////////////////////
531  # trace
532  if {([info exists ::project::data(EvalTra)]) && \
533      ($::project::data(EvalTra))} {
534    ::TolConsole::HciWriter "$cmd \n"
535  } 
536  ::tol::console eval $cmd
537}
538
539
540
541#///////////////////////////////////////////////////////////////////////////
542proc TolValidateData {P typFie} {
543#
544# PURPOSE: Verifies that a given value observes the rules of a data type
545#
546# PARAMETERS:
547#   P      : value to verify
548#   typFie : data type
549#
550# RETURN: 1 -> OK, 0 -> NO
551#
552#///////////////////////////////////////////////////////////////////////////
553  set ok 1
554  # si no hay ningun caracter no comprobamos
555  if {![string length $P]} {
556    return $ok
557  }
558  # ralizamos las comprobacines
559  set sepDec {.}
560  set typeField [string tolower [lindex $typFie 0]]
561  set lonField  [string tolower [lindex $typFie 1]]
562 
563  switch $typeField {   
564    "real" {
565      #Datos numéricos de punto flotante entre –3.40E + 38 y 3.40E + 38.
566      # El tamaño de almacenamiento es 4 bytes. En SQL Server, el sinónimo
567      # de real es float(24).
568      set ok [expr {([string match {[-+]} $P] || [string is double $P]) && \
569                     $P>=[expr -3.40 * pow(10,38)] && \
570                     $P<=[expr  3.40 * pow(10,38)]}]
571    }
572   
573    "text" {
574      # Todo tipo de cadenas de caracteres
575     
576      set ok 1
577    }
578   
579    "date" {
580      # Todo tipo de cadenas de caracteres
581     
582      set ok 1
583    }
584   
585    default {puts "TolValidateData:\n\
586                   WARNING: Tipo no reconocido $typeField"}
587  }
588}
589
590  proc TolGetFieldValues { tableName field getConnection} {
591   
592    set txtSql \
593    "select distinct $field \n \
594     from $tableName \n \
595     order by $field"
596    # se ejecuta la query
597    if { [catch { set lstInfoValues [$getConnection $txtSql] } result ] } {         
598        ShowMessage E "$result" "." ;# si ha habido error, se muestra
599    } else { ;# devolvemos el valor
600      # tratamos la lista de valores para no tener { } en valores con espacios
601      set lstInfoVal {}
602      foreach it $lstInfoValues {
603        lappend lstInfoVal [lindex $it 0]
604      }
605      return $lstInfoVal
606      #return $lstInfoValues
607    }   
608  }
609
610#///////////////////////////////////////////////////////////////////////////
611  proc TolGetDelimeterField {type} {
612# PURPUSE: Comprobamos el tipo de un campo e indicamos si sus valores deben
613#          ir precedidos por algun caracter especial. Por ejemplo los textos
614#          van entre comillas, los numeros no cesesitan comillas
615#          TODO: Igual hay que usar las las funciones de TOL
616#
617# RETURN: El texto a concatenar a al valor del campo
618#
619#///////////////////////////////////////////////////////////////////////////
620
621  set delimeter {}
622  set typeField [string tolower [lindex $type 0]]
623  switch $typeField {
624    "real" {
625      # no necesita ningun delimitador
626    }
627    # datetime y smalldatetime
628    "date" {
629      set delimeter {' '}
630      set gestor [string trim [TclGetVar Text DBA] {"}]; #"
631
632      switch $gestor {
633        "SqlServer" {
634          set delimeter {{convert(datetime,'} {',121)}}       
635        }
636        "Oracle" - "Pos" {
637          set delimeter {{to_date('} {','yyyy/mm/dd')}}       
638        }
639      }
640     }
641    # Cadenas de caracteres
642    "text" {
643      set delimeter {' '}
644    }
645   
646   
647    default {puts "TolGetDelimeterField:\n\
648                   WARNING: Tipo no reconocido $typeField"}
649  }
650  #puts "TolGetDelimeterField: $delimeter"
651  return $delimeter
652}
653
654#///////////////////////////////////////////////////////////////////////////
655proc EvalTolExp {grammar expression {seed _tempName}} {
656# PURPOSE: Evaluates a tol expression $expression from grammar $grammar
657# RETURNS: Content of evaluated expression
658#
659#///////////////////////////////////////////////////////////////////////////
660  set nRes [GetUniqueName $grammar $seed]
661  set cmd "$grammar $nRes = $expression;"
662  ::tol::console eval $cmd
663  array set info [TclInfoVar $grammar $nRes]
664  eval "set lstRes $info(CONTENT)"
665  ::tol::console stack release $nRes
666  return $lstRes
667}
668
669#///////////////////////////////////////////////////////////////////////////
670proc TolObj2TclObj { obj } {
671# PURPUSE: Dado una referencia a un objeto TOL retorna una representacion en
672#          TCL equivalente. Esta funcion debe reemplazar a TolSet2TclLst.
673#
674# RETURN: Un objeto Tcl que representa el contenido del objeto TOL
675#
676#///////////////////////////////////////////////////////////////////////////
677 #puts "obj = $obj"
678  set vinfo [ tol::info variable $obj ]
679  set grammar [ lindex $vinfo 0 ]
680  if { $grammar eq "Set" || $grammar eq "NameBlock" } {
681    set result [ list ]
682    set idx 1
683    tol::foreach it $obj {
684      array set it_info $it
685      #puts "$it_info(grammar) $it_info(name) $it_info(content) "
686      lappend result [ TolObj2TclObj [ eval list $obj $idx ] ]
687      incr idx
688    }
689    set result
690  } else {
691    if { $grammar eq "Text" } {
692      #string trim [ lindex $vinfo 2 ] \"
693      set contents [ lindex $vinfo 2 ]
694      regexp {^"(.*)"$} $contents ==> contents
695      set contents
696    } else {
697      lindex $vinfo 2
698    }
699  }
700}
701
702#///////////////////////////////////////////////////////////////////////////
703proc TolSet2TclListNamed { obj } {
704# PURPUSE: procedimiento de ayuda a TolObj2TclObjNamed para construir el
705#          valor asociado a un conjunto TOL donde sus elementos van con
706#          nombre.
707#
708# RETURNS: retorna una lista con los pares nombre valor de los elementos del
709#          conjunto TOL
710#///////////////////////////////////////////////////////////////////////////
711  set value [ list ]
712  set idx 1
713  tol::foreach it $obj {
714    #puts "$it_info(grammar) $it_info(name) $it_info(content) "
715    set it_pair [ TolObj2TclObjNamed [ eval list $obj $idx ] ]
716    # esto quedaria mejor con un {*}, no usaria el eval pues creo que
717    # "abre" toda la lista.
718    lappend value [ lindex $it_pair 0 ] [ lindex $it_pair 1 ]
719    incr idx
720  }
721  set value
722}
723
724#///////////////////////////////////////////////////////////////////////////
725proc TolObj2TclObjNamed { obj } {
726# PURPUSE: Dado una referencia a un objeto TOL retorna una representacion en
727#          TCL equivalente manteniendo los nombres de los objetos TOL.
728#          Si el objeto no tiene nombre se le asigna un nombre vacio ""
729#
730# RETURN: Un par nombre,valor
731#
732#///////////////////////////////////////////////////////////////////////////
733  #puts "obj = $obj"
734  set vinfo [ tol::info variable $obj ]
735  set grammar [ lindex $vinfo 0 ]
736  if { $grammar eq "Set" || $grammar eq "NameBlock" } {
737    set value [ TolSet2TclListNamed $obj ]
738  } else {
739    if { $grammar eq "Text" } {
740      set value [ lindex $vinfo 2 ]
741      regexp {^"(.*)"$} $value ==> value
742    } else {
743      set value [ lindex $vinfo 2 ]
744    }
745  }
746  list [ lindex $vinfo 1 ] $value
747}
748
749# -------------------------------- SOME TESTS --------------------------
750
751proc loadtt { } {
752  package require Toltcl
753  tol::initkernel
754  tol::initlibrary
755}
756
757proc test1.1 { } {
758  TolObj2TclObj {Set BdtChartMet}
759}
760
761proc test1.2 { } {
762  TolObj2TclObjNamed {Set BdtChartMet}
763}
764
765proc test2.1 { } {
766  tol::console eval {
767    Set {[[ Set kk = Empty ]]}
768  }
769  set result [ TolObj2TclObj {Console 1} ]
770  tol::console stack release
771  return $result
772}
773
774proc test2.2 { } {
775  tol::console eval {
776    Set {[[ Set kk = Empty ]]}
777  }
778  set result [ TolObj2TclObjNamed {Console 1} ]
779  tol::console stack release
780  return $result
781}
782
783proc test3.1 { } {
784  tol::console eval {
785    Set {[[ 1, 2, Set kk = [[ 3, 4, "texto" ]] ]]}
786  }
787  set result [ TolObj2TclObj {Console 1} ]
788  tol::console stack release
789  return $result
790}
791
792proc test3.2 { } {
793  tol::console eval {
794    Set {[[ 1, 2, Set kk = [[ 3, 4, "texto" ]] ]]}
795  }
796  set result [ TolObj2TclObjNamed {Console 1} ]
797  tol::console stack release
798  return $result
799}
Note: See TracBrowser for help on using the repository browser.