Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tok, unexpected result (tok array item has incorrect len)
#1
Macro treadmill_log_SetImageLog
Code:
Copy      Help
str s="e:\__qm_testdirs\_treadmill_log_test\log\‎10-‎6-‎2016.JPG"
str fn.getfilename(s) ;; 10-‎6-‎2016
ARRAY(str) arr
tok fn arr -1 "-" ;; [0]=10 , [1]=6 , [2]=2016
out arr[0]
out arr[1]
out arr[2]
out arr[0].len ;; OUTPUT: 5 , in stead of 2

The .len of the first item in arr should be '2', but I get '5'
"s" is an actual file and the filename is the date when the picture was taken.
The first item = "10" which is 2 characters in length (len), but why am I getting '5' as an output?

I have tried the same code in a different macro but in stead of the full path I put in "s", i put the only the date in it "10-6-2016" and then it works! (I get '2' in the output pane below)
#2
Your string contains some hidden characters. Probably copied from some app that adds them.

example
Macro Macro2818
Code:
Copy      Help
out
str s

;normal
s="a"
out s.len
outb s s.len

;replaced from your string; the hidden characters remains
s="‎a"
out s.len
outb s s.len

;result
;1
;61
;4
;E2 80 8E 61

google for E2 80 8E
#3
That explains why it worked in another macro!
Thank you!
#4
I found out where it went wrong I think.

I have some images taken with the Iphone 4 which I then copy to the pc.
I then run a script based on this example:
MS Word document built-in Properties (get file extended properties)

I assume the example script is ok, but the problem is the way the "Date taken" get's written by the phone.
I tested it again and it this seems to be the case.

This still leaves me with the hidden characters and this leads me to this question:
Is it possible to remove the hidden characters from a string, especially the "E2 80 8E"?
#5
s.findreplace("copy paste what seems to be empty but actually contains these 3 bytes")

Macro hidden characters
Code:
Copy      Help
out
str s

;normal
s="a"
out s.len
outb s s.len

;replaced from your string; the hidden characters remains
s="‎a"
out s.len
outb s s.len

;result
;1
;61
;4
;E2 80 8E 61

;s.findreplace("‎") ;;3 hidden bytes in ""
s.findreplace("[0xE2][0x80][0x8E]") ;;visual
out s
out s.len
outb s s.len
#6
Thank you!!!


Forum Jump:


Users browsing this thread: 1 Guest(s)