Sunday, June 16, 2019

#1 2019-06-07 05:29:28 am

FlameCoder
Member
From:: USA
Registered: 2009-10-28
Posts: 87

List to String in ASOC

Converting a list to a string doesn't work the same within ASOC Xcode.
What needs done to get the correct string back?

I have a table view connected to an array controller. I then get the data and iterate thru each one removing the first two characters, but when I log the result I have returns. Tried delimiters with no success.

Applescript:

repeat with i in insigniaNumberData
set my insignia to ((item 3 thru 8 of i) as string)
log insignia
end repeat

2019-06-07 07:20:25.471108-0400 Retriever[17822:4828239] 4
1
0
4
4
5

Doing the same in the will finish launching handler I get this result...

Applescript:

set insigniaNumbers to {"MP112233", "AC223344", "DC334455", "CI445566"}
repeat with i in insigniaNumbers
   set insignia to ((items 3 thru -1 of i) as string)
   log insignia
end repeat

Current result
2019-06-06 16:12:13.245294-0400 Retriever[17260:4714616] 1/1/2/2/3/3
2019-06-06 16:12:13.246630-0400 Retriever[17260:4714616] 2/2/3/3/4/4
2019-06-06 16:12:13.247960-0400 Retriever[17260:4714616] 3/3/4/4/5/5
2019-06-06 16:12:13.249269-0400 Retriever[17260:4714616] 4/4/5/5/6/6


Filed under: list, delimiters

Offline

 

#2 2019-06-07 05:51:09 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5698

Re: List to String in ASOC

You're not dealing with a list, you're dealing with an array. So you either coerce that to a list first, or use different approach.

You also shouldn't be using (items x thru y of ...) as string -- it's inefficient and relies on the value of text item delimiters. You should use text x thru y of ... instead.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)