1

I created a code which count the length of a variable and take action regarding the length.

It's work well except when I have a variable in this format :

"00108030-00045C9E2638502E"

1: the count is returning 8 and not 25 2: I have the error :

"Can’t make 8 into type boolean." number -1700 from 8 to boolean"

Here is a preview of my code : "

set theGUIDLength to (get length of (GUID as text))
if theGUIDLength is equal to 25 or 8 then
--
end if

"

1
  • - my script work if I set if theGUIDLength is equal to 8 then
    – Kevin
    Nov 25, 2018 at 11:22

2 Answers 2

1

I believe what you're looking for is:

if theGUIDLength = 25 or theGUIDLength = 8 then
## do code
end if
3
  • Yes thank you, any idea why the result is 8 and not 25 though? it's stop the count after "-"
    – Kevin
    Nov 25, 2018 at 11:30
  • Not without testing exactly sorry on phone. I would modify how you're going about it because it looks like you're comparing text VS an integer
    – ʀ2ᴅ2
    Nov 25, 2018 at 11:33
  • 1
    I actually found the issue, before I have "set [serialNumber, GUID] to the words of myClipboard" so that the issue. anyway thank you again.
    – Kevin
    Nov 25, 2018 at 11:37
0

Perhaps a cleaner way to do this:

if theGUIDLength is in {25, 8} then
## do code
end if

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .