Version 2 of hexScope

Updated 2022-06-22 20:04:43 by dox

Change log:

- 2022/06/22 - Draft

Description: hexScope hexScope is a small procedure which where it allows you to inspect indiviual values of an hexidemical string. The code below allows you to inspect each character in a hex string based on the "x" and "y".

# The length of the string, used in the forloop
# The forloop will shuffle through our hexstring
# we then check each character of the string based
# on incremented variables values and if they match 
# do something

# the for loop sets the "a" counter to 0,
# we are then comparing if variable a is less than the string length
# of our hex string;. Then we increment the variable value x and y variable by one 
# we repeat this 

# within the loop, we debug print the x and y which represent our index of char
# as hex has double digits -- "7" = 37 "3 7"
#                                                                   hex  x y
# increment x, increment x
# increment y, increment y

## The hexstring of the raw input. 
## this is an example of a hexstring 
## within the hexstring variable
#a1 b7 c3 7c 24

set hexString "a1b7c37c24" ;#Should be set to the raw input of the hexString
set frame_button "" ;# collected query
set hexkey ""        ;# hexkey of the user
set cycle 0     ;# internal counter
    set x_pos 0                                ;# set the first hex character within the hex string (0)
    set y_pos 1                                ;# set the second hex character within the hex string (1)
                                                 # as one ascii character uses two hex characters
        switch $debug { 1 { puts ">? x y :: hex" } } ;#debug switch of the x,y and hex that represents those ranges

set string_length [string length $hexString]  ;# get the length of the string example: "abc" = 3 | 
for {set z 0} {$z < $string_length} {incr z} {  ;# for a less than string length, incr $z as $z = cursor point of the length 
                                                
set string_range  [string range "$hexString" $x_pos $y_pos] 
# switch below switches between the string_range 
# the string range is a the cursor between the two marks.
# and if the string range output is equal to the value "7c" we then preform a counter increment
# then switch between this cycle 
# 7c is the seperator given to 

switch $string_range { 
7c { incr cycle ; switch $debug { 1 { puts "seperator found at range: $x_pos $y_pos" } } }
"" { break }
default { 
                 switch $cycle { 
                 0 { append hexkey $string_range }
                 1 { append frame_button $string_range }
                 }}
} ;#end switch
switch $debug { 1 { puts ">? $x_pos $y_pos :: [string range "$hexString" $x_pos $y_pos]" } }        
                                                ;#show debug for the x y and hexString 
incr x_pos  ; incr x_pos ;# incr x twice
incr y_pos  ; incr y_pos ;# incr y twice

} ;#end for
#############
##