SHARE
TWEET

Untitled

a guest Dec 10th, 2018 156 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     # switch to a read interface
  2.     set ::doingRefresh 1        ;# set to 1 while refreshing variables
  3.     serialevent readable {}
  4.  
  5.     dprintf "\nVariable values loading (could take a while if many vars/big arrays exist - standby)..." ;# tweak
  6.        
  7.     .symbols.text delete 1.0 end
  8.     set count 0
  9.     set textcolor ""
  10.  
  11.     foreach varEntry $variableList {
  12.         if {[lsearch {CODE SFUNCT FFUNCT WFUNCT SUB} [lindex $varEntry 1]] >= 0} continue
  13.        
  14.         set varAddr [lindex $varEntry 0]
  15.         #preformatting with spaces was a cute idea, but this is a little endian so have to reverse it anyway
  16.         set varName [lindex $varEntry 2]
  17. #       set varName [string range $varName 0 15]
  18.         set varName [format "%-$nameWidth" $varName]
  19.         set varSize [lindex $varEntry 3]
  20.         set varType [lindex $varEntry 1]
  21.        
  22.         if {$varType == "WORD"} {
  23.             set memData [refGetWord $varAddr]
  24.             .symbols.text insert end [format "$varName &H%s %d\n" $memData [expr 0x$memData]] $textcolor
  25.         } elseif {$varType == "SINGLE"} {
  26.             set memData [refGetWord $varAddr]
  27.             .symbols.text insert end [format "$varName %f\n" [calcSingle [expr 0x$memData]]] $textcolor
  28.         } elseif {($varType == "INTPTR") || ($varType == "SNGLPTR")} {
  29.             set memData [refGetWord $varAddr]
  30.             .symbols.text insert end "$varName &H$memData\n" $textcolor
  31.         } elseif {$varType == "PARRAY"} {
  32.             set numElem [expr 0x[refGetWord [expr $varAddr + 60]]]
  33.             .symbols.text insert end "$varName \[$numElem\] " $textcolor
  34.             for {set i 0} {$i <= $numElem} {incr i} {
  35.                 set mmData [expr 0x[refGetWord [expr $varAddr + ($i * 4)]]]
  36. #               puts "[expr $varAddr + ($i * 4)] $mmData"
  37.                 .symbols.text insert end "$mmData " $textcolor
  38.             }
  39.             .symbols.text insert end "\n" $textcolor
  40.         } elseif {$varType == "STRING"} {
  41.             .symbols.text insert end "$varName \"" $textcolor
  42.             for {set i 0} {$i < $varSize} {incr i} {
  43.  
  44.                 set word [refGetWord [expr $varAddr + ($i * 4)]]
  45.                
  46.                 set byte0 0x[string range $word 6 7]
  47.                 set byte1 0x[string range $word 4 5]
  48.                 set byte2 0x[string range $word 2 3]
  49.                 set byte3 0x[string range $word 0 1]
  50.                 if {$byte0 == 0} {
  51.                     break
  52.                 }
  53.                 if {$byte1 == 0} {
  54.                     .symbols.text insert end [format "%c" $byte0] $textcolor
  55.                     break
  56.                 }
  57.                 if {$byte2 == 0} {
  58.                     .symbols.text insert end [format "%c%c" $byte0 $byte1] $textcolor
  59.                     break
  60.                 }
  61.                 if {$byte3 == 0} {
  62.                     .symbols.text insert end [format "%c%c%c" $byte0 $byte1 $byte2] $textcolor
  63.                     break
  64.                 }
  65.                 .symbols.text insert end [format "%c%c%c%c" $byte0 $byte1 $byte2 $byte3] $textcolor
  66.             }
  67. #           set varSize $i
  68.             .symbols.text insert end "\"  " $textcolor
  69.             for {set i 0} {$i < $varSize} {incr i} {
  70.                 set word [refGetWord [expr $varAddr + ($i * 4)]]
  71.                 .symbols.text insert end [string range $word 6 7] $textcolor
  72.                 .symbols.text insert end [string range $word 4 5] $textcolor
  73.                 .symbols.text insert end [string range $word 2 3] $textcolor
  74.                 .symbols.text insert end "[string range $word 0 1] " $textcolor
  75.                 if {$i > 8} break
  76.             }
  77.             .symbols.text insert end "\n" $textcolor                       
  78.         } elseif {$varType == "ARRAY"} {
  79.             .symbols.text insert end "$varName " $textcolor
  80.             for {set i 0} {$i < $varSize} {incr i} {
  81.                 set memData [refGetWord [expr $varAddr + ($i * 4)]]
  82.                 .symbols.text insert end [format "%10d" [expr 0x$memData]] $textcolor
  83.                 if {$i % 8 == 7} {  .symbols.text insert end "\n" $textcolor }
  84.             }
  85.             .symbols.text insert end "\n" $textcolor
  86.         } elseif {$varType == "FARRAY"} {
  87.             .symbols.text insert end "$varName " $textcolor
  88.             for {set i 0} {$i < $varSize} {incr i} {
  89.                 set memData [refGetWord [expr $varAddr + ($i * 4)]]
  90.                 .symbols.text insert end [format "%f " [calcSingle [expr 0x$memData]]] $textcolor
  91.                 if {$i % 8 == 7} {  .symbols.text insert end "\n" $textcolor }
  92.             }
  93.             .symbols.text insert end "\n" $textcolor
  94. # other values skipped -- like FUNCTION        
  95.         } else {
  96.             continue
  97.         }
  98.         incr count
  99.         if {$count >3} {
  100.             if {$textcolor == "" } {set textcolor "colorGRAY"
  101.             } else {set textcolor ""}
  102.             set count 0
  103.         }
  104.     }
  105.     serialevent readable getUSB_SER
  106.    
  107.     set ::doingRefresh 0        ;# set to 1 while refreshing variables
  108.  
  109.     dprintf "Variable values finished loading. :)\n"        ;# tweak
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top