Re: Change a aJSON list to an Applescript list?
Brian, I'm sure you can roll your own, but you might be interested in this tool:
Best Regards,
Jim Underwood
aka JMichaelTX
From: AppleScript-Users <applescript-users-bounces+jmichael=apoemail.us@...> on behalf of Brian Christmas <ozsanta@...>
Date: Friday, September 8, 2017 at 11:41 AM To: "ASUL (AppleScript)" <applescript-users@...>, Applescript Xcode new list <applescript@apple-dev.groups.io> Subject: Change a aJSON list to an Applescript list?
G’day
I’m very slowly making progress in getting my Application “Mail Manager” to a saleable state. So much to learn about.
However, I’m using a subscriion model via fastSpring, and need to check monthly if the serial number for each App is still in FastSprings valid serials active list.
This list is downloadable as a JSON file, and I’m trying to work out how to interpret that information into an Applescript list.
|
|
Change a aJSON list to an Applescript list?
Brian Christmas
G’day
I’m very slowly making progress in getting my Application “Mail Manager” to a saleable state. So much to learn about. However, I’m using a subscriion model via fastSpring, and need to check monthly if the serial number for each App is still in FastSprings valid serials active list. This list is downloadable as a JSON file, and I’m trying to work out how to interpret that information into an Applescript list. The JSON API is in the form… { "action": "subscription.getall", "result": "success", "nextPage": 3, "subscriptions": [ "khyNPLY3TYiQhBfHyjZINg", "w46bQ2-gTayzJfFXbV1VWg", "86cFjtgCRlSmOPbLcX_mCA", "v0yPCSTLSyarVe9NlNalSA", "FWhWZ3b6StyfiJ_GnyHswQ", "A5xx9TF_R26PcCMdagAC8Q", "pgNumDwTSbaLeNY6FtUF3Q", "IK2eD1nvSP-L3yilE6K7BQ", "iZ8qUO-MSwuezTn_elPb3g", "gLspcP3NRqmdOm615HSTig", "HYKxh1JfTcyUhTgJxAxfWg", "1RkJixj_QKOg_c7G_wGIZA", "LiPzVuKnT2Go1WWteQkZtw", "V5wXtLilSsWGkMYSiLVy2g", "MseNZ_LBRu63R84k9knIKg" ] } I’ve found a page on GitHub that espouses Json Helper, but cannot for the life of me work out how to add this to my App. I just need to check if the localised, encrypted serial number is in the JSON list. Is it possible to convert the JSON list to text, and just see if the text ‘contains’ the serial number. Inelegant, but if it would work???? Any advice please? Regards Santa
|
|
Re: What's the REAL problem, please?
Shane Stanley
On 2 Sep 2017, at 3:05 pm, Brian Christmas <ozsanta@gmail.com> wrote:
Blaming someone else every time you fail to understand something gets very tiresome after a while. It's not something peculiar to GraphicConverter -- you may have seen com.apple.ScriptEditor2, for example -- and if more developers did it, it would make writing scripts where people use multiple versions a damn sight easier. Thorsten deserves a thankyou note, not blame-shifting. If the command is going to work with every version of GraphicConverter, then it doesn't matter which version's name you use terms from. And if it isn't going to work with every version of GraphicConverter, you can't use it anyway. Here's the first link that comes up on a Google search on "using terms from": A terms block dictates which application's dictionary AppleScript should get the enclosed terminology from, without actually targeting that application. Terminology is resolved at compile time; therefore the application must be a literal application specifier (otherwise there's a compile-time error, "Can't make some data into the expected type"). A terms block is important only at compile time (and decompile time); it is effectively ignored at runtime.It's from 'AppleScript: The Definitive Guide', 2nd Edition by Matt Neuburg. You should read it some time. -- Shane Stanley <sstanley@myriad-com.com.au> <www.macosxautomation.com/applescript/apps/>, <latenightsw.com>
|
|
Re: What's the REAL problem, please?
Brian Christmas
Thank you Andrew
toggle quoted messageShow quoted text
However, as cannot test your suggestion, I want to make myself absolutely clear on my understanding of what you’re saying. Thorsten has changed his App name from just ‘GraphicConverter’, to now ‘GraphicConverter 10’, and presumably in the future to ‘GraphicConverter 11’, ‘GraphicConverter 12', etc.. He rarely changes his dictionary options. If (because I’m always recompiling), I use ‘GraphicConverter 10’ now, and the present bundle identifier is “com.lemkesoft.graphicconverter10”, will future bundle identifiers “com.lemkesoft.graphicconverter11”, “com.lemkesoft.graphicconverter12” work with my code? Thank you for offering a ray of hope!! Regards Santa
|
|
Re: What's the REAL problem, please?
Brian Christmas
Shane, look, I really, really appreciate your advice, but I cannot for the life of me see how it changes my situation.
In order to get ‘using terms from’ to work, I have to enter a non-variable item, such as in my example below. The commented line #using terms from (application id theApp) shows what I WANT to use, but still doesn’t work. To get using terms from to work, I’m still restricted to knowing the exact name of the bundle identifier, which I REALLY absolutely need as a variable. The possible name are …
Even other App works with a defined bundle identifier that does not alter between releases, but Thorsten in his infinite wisdom, has decided to link bundle indentifiers to version releases from now on. Version releases have numbers because of App Store release. Why he decided to add the same number to his bundle identifiers only he knows, but I’ve sent a grumbling email to him pointing out the problem it causes. Is there any way around this situation? OR, am I up the proverbial creek without a paddle? Regards Santa property theItem : ((path to desktop as text) & "Numbers_Chart.jpg") tell application "Finder" to set theApps to (name of (every item of folder (path to applications folder))) as list repeat with theApp2 in theApps if theApp2 contains "GraphicConverter" then set theUserApp to application theApp2 exit repeat end if end repeat tell application "System Events" set theApp to bundle identifier of (info for (path to theUserApp)) as text end tell tell application id theApp to activate tell application "Finder" to set theProcesses to (name of processes) as list repeat with theApp2 in theProcesses if theApp2 contains "GraphicConverter" then set theUserProcess to theApp2 as text exit repeat end if end repeat using terms from application "GraphicConverter 10" # if I use the line below instead, Script Editor alters it to the same as the line above # using terms from (application id "com.lemkesoft.graphicconverter10”) — SEE, he damnwell alters the bundle identifier between releases!!! #using terms from (application id theApp) -- Fails tell (application id theApp) activate silentopen file (my theItem) — NOW WORKS!! #open file (my theItem) tell window 1 try set TheRes to resolution set resolutionChangeFlag to false if item 1 of TheRes < 600 then set item 1 of TheRes to 600 set resolutionChangeFlag to true end if if item 2 of TheRes < 600 then set item 2 of TheRes to 600 set resolutionChangeFlag to true end if if resolutionChangeFlag then change resolution to TheRes with resample — NOW WORKS!! end try end tell end tell end using terms from
|
|
Re: What's the REAL problem, please?
Shane Stanley
On 2 Sep 2017, at 12:16 pm, Shane Stanley <sstanley@myriad-com.com.au> wrote:
Hint: look up "using terms from". -- Shane Stanley <sstanley@myriad-com.com.au> <www.macosxautomation.com/applescript/apps/>, <latenightsw.com>
|
|
Re: What's the REAL problem, please?
Shane Stanley
On 2 Sep 2017, at 11:46 am, Brian Christmas <ozsanta@gmail.com> wrote:
Yes: read the AppleScript Language Guide, or buy one of the beginner AppleScript books. This has nothing to do with Script Debugger or GraphicConverter -- it's AppleScript 101: if you use a variable for the target, either name or id, there's no way AppleScript can know at compile time which application's terminology to use. This is REALLY importantThis is REALLY basic. -- Shane Stanley <sstanley@myriad-com.com.au> <www.macosxautomation.com/applescript/apps/>, <latenightsw.com>
|
|
What's the REAL problem, please?
Brian Christmas
G’day
I’m trying altering code in my printing App to be able to use almost ANY recent version of different printing Apps. So, I've resorted to trying to open each app with its bundle identifier. Compiled OK (Acrobat, Illustrator, InDesign), until I got to GraphicConverter (using Script Debugger), where I found the bundle id has a number, the same as the App version number (10) So, I wrote code to overcome this, then found certain aspects of my GraphicConverter handler will no longer compile. Trouble is, is it the Compiler, or GraphicConverter??? I’ve whipped of a request to Thorsten Lemke, but also thought I’d bounce the question of these two groups. Below is a snippet I wrote to test the problem. Any thoughts, particularly from the Authors of Script Debugger? Any alternative methods? This is REALLY important, please! Regards Santa property theItem : ((path to desktop as text) & "Numbers_Chart.jpg") tell application "Finder" to set theApps to (name of (every item of folder (path to applications folder))) as list repeat with theApp2 in theApps if theApp2 contains "GraphicConverter" then set theUserApp to application theApp2 exit repeat end if end repeat tell application "System Events" set theApp to bundle identifier of (info for (path to theUserApp)) — Returns "com.lemkesoft.graphicconverter10" end tell tell application id theApp to activate tell application "Finder" to set theProcesses to (name of processes) as list repeat with theApp2 in theProcesses if theApp2 contains "GraphicConverter" then set theUserProcess to theApp2 as text exit repeat end if end repeat tell (application id theApp) activate # silentopen file (my theItem) — Won’t compile open file (my theItem) tell window 1 try set TheRes to resolution set resolutionChangeFlag to false if item 1 of TheRes < 600 then set item 1 of TheRes to 600 set resolutionChangeFlag to true end if if item 2 of TheRes < 600 then set item 2 of TheRes to 600 set resolutionChangeFlag to true end if #if resolutionChangeFlag then change resolution to TheRes with resample — Won’t compile end try end tell end tell
|
|
Double clicking sigle entry Table not working.
Brian Christmas
G’day all
First, I fixed my lasr error bu methodically going over every deatil, and discovered a Text Field Cell in a Text Field has somehow been assigned a value, linked to an array controller, with ‘self’ as the Model Key Path. Don’t know how it happened. I was very tired, but knowe I cannot sleep until I’ve solved any problems. I AM finding some unusual tthing being added/altered in Xcode 8 sometimes. Don’t know id it’s me, or a bug? However, this problem is text book ‘Explored’ ebook code, that’s not working. I built a Table, with Double Clicking access, theTableOne's setDoubleAction:"displaySelection:" -- so double-click will call action handler Worked fine with multiple entries, then I added a column, reduced the files to the only one containing 4 items of data, and now a Double Click on the single line, which is always hilited, refuses to work. Refuses to call the handler. 1. Would the fact the line is hilited in blue make a difference? 2. Is this a bug? Regards Santa
|
|
Re: Dilemma after moving Project.
By "project" do you mean just the .xcodeproj, or the enclosing folder with the project file and source files? Moving just the .xcodeproj will definitely break everything, because by default it uses relative paths to find all the other files. Moving the entire project folder should be OK; if it breaks your build it's probably because you've ended up with absolute paths to some files, which are now broken links. Use the File Inspector pane to look at the paths for the files in your project. —Jens
|
|
Re: Dilemma after moving Project.
Sandor Szatmari
Did you try looking at the 'file attribute' inspector in the Utilities pane of Xcode to check how Xcode is referencing your XIB? If you had an absolute path and moved your project Xcode wouldn't be able to find your XIB. But I this should cause a build error not a runtime error. Did you do a clean, then build? Sandor
On Aug 27, 2017, at 22:02, Brian Christmas <ozsanta@...> wrote:
|
|
Dilemma after moving Project.
Brian Christmas
G’day folks
I had a nice working project saved at 3 am this morning. Got up at 8:30, and added 11 tick boxes with true/false properties, and added them to the .plist saving and reading handlers. Also added an internal ‘Scripts’ folder, and dragged in an .rtf example file, which opens with button. Then, before testing, stupidly dragged the Project from the desktop to the folder I keep my Projects in. Built it, tried to open, and got a ‘copyWithZone' error below. Have researched, and it seems most likely I have to somehow ‘re-link’ my xib file to my Project. Can’t find exactly HOW though. Nothing on what to do with ASCObjC Project for MacOSX. Path to Project is… /Users/OzSanta/Documents/My XCode Projects/MM Sierra App Store/Mail Manager Accountancy/Mail Manager Accountancy/Base.lproj/MainMenu.xib Any, any help please? Tried dragging back to Desktop, too late. Only simple things added!! I DID accidently drop the .rtf file outside the ‘Scripts’ folder, then dragged it in. That cause a problem? If no advice, I’ll have to restore from Time Machine, and re-build step by step. BUT, would like to know WHY this happened! Regards Santa System Integrity Protection: enabled Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Application Specific Information: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AppDelegate copyWithZone:]: unrecognized selector sent to object <AppDelegate @0x61000022eaa0: OSAID(4) ComponentInstance(0xdf0000)>' terminating with uncaught exception of type NSException abort() called Application Specific Backtrace 1: 0 CoreFoundation 0x00007fff8d3442cb __exceptionPreprocess + 171 1 libobjc.A.dylib 0x00007fffa215448d objc_exception_throw + 48 2 AppleScriptObjC 0x00007fff8bb4aa23 -[BAObjectProto methodSignatureForSelector:] + 0 3 CoreFoundation 0x00007fff8d2b6755 ___forwarding___ + 1061 4 CoreFoundation 0x00007fff8d2b62a8 _CF_forwarding_prep_0 + 120 5 AppKit 0x00007fff8add4b4a -[NSCell _setContents:] + 73 6 AppKit 0x00007fff8ade1199 -[NSCell setObjectValue:] + 166 7 AppKit 0x00007fff8ade10a6 -[NSTextFieldCell setObjectValue:] + 93 8 AppKit 0x00007fff8aeb70c2 -[_NSPlaceholderTextFieldPlugin showValue:inObject:] + 110 9 AppKit 0x00007fff8aeb69cc -[NSValueBinder _adjustObject:mode:observedController:observedKeyPath:context:editableState:adjustState:] + 391 10 AppKit 0x00007fff8aeb67b6 -[NSValueBinder _observeValueForKeyPath:ofObject:context:] + 286 11 AppKit 0x00007fff8aeb661f -[NSTextValueBinder _observeValueForKeyPath:ofObject:context:] + 43 12 AppKit 0x00007fff8ae0bc03 -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] + 773 13 AppKit 0x00007fff8ad8181d -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 1284 14 AppKit 0x00007fff8ad78af0 loadNib + 375 15 AppKit 0x00007fff8ad7803a +[NSBundle(NSNibLoading) _loadNibFile:nameTable:options:withZone:ownerBundle:] + 308 16 AppKit 0x00007fff8ad77df2 -[NSBundle(NSNibLoading) loadNibNamed:owner:topLevelObjects:] + 201 17 AppKit 0x00007fff8ad77baf +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 414 18 AppKit 0x00007fff8ad72b2b NSApplicationMain + 498 19 Mail Manager Accountancy 0x00000001087b68a2 main + 98 20 libdyld.dylib 0x00007fffa2a3a235 start + 1
|
|
Is it possible to triple click at mouse position???
Brian Christmas
G’day scripters
I have a situation where an app is cycling for receiving Barcode scans. Also, two columns in a table with number formatters. I have a button placed over the numbers, that is active (invisibly) when the barcode scanning is active, and if a number is clicked above it, the button becomes hidden, and turns the scanning off. However, it’s then cumbersome to have to triple click after a short while to select the number formatters. I’d like to automate this, and triple click exactly where the mouse was clicked above the number, but everything I’ve found on the net indicates I need a system addition to get the mouse position, and click there. What I want is something that can be added to and distributed with the App, and also works with Shane’s fordEvents. Any suggestions, please?? Regards Santa PS, Shane, thanks for the tip on Cocoa variables. I WAS opening the report in TextEdit, but had utterly no idea of what I was looking at. I’ve listed each variable now (36), and coerced them individually, and everything works fine, thank you.
|
|
Re: The strangest thing is happening!!!
Shane Stanley
On 24 Aug 2017, at 2:32 am, Brian Christmas <ozsanta@gmail.com> wrote:
Have you tried looking at it in a text editor? It's basic trouble-shooting. If you do, you'll see two instances of "ocid" and "optr", which suggest you're saving pointers to Cocoa objects. That means you're saving memory locations that could contain anything at all next time you read them. Both your files are nasty crashes waiting to happen. -- Shane Stanley <sstanley@myriad-com.com.au> <www.macosxautomation.com/applescript/apps/>, <latenightsw.com>
|
|
Re: The strangest thing is happening!!!
Michael Bauer
Have you tried comparing the files with FileMerge (type into spotlight to find it)? I have two differences that show up but don’t know what I’m looking at exactly.
toggle quoted messageShow quoted text
On Aug 23, 2017, at 12:32 PM, Brian Christmas <ozsanta@gmail.com> wrote:
|
|
The strangest thing is happening!!!
Brian Christmas
G’day folks I’m trying to deal with a situation that is crashing one on my Apps, and don’t know what’s causing it. My main app saves a list of variables on the desktop, and the printing app reads them, and deals with the emailed files, which are saved in a special folder. Only the folder reference is saved, no mention of the files inside it. The folder and the saved files are being created just fine. The separate App that prints all the emailed images only crashes when I use an .indd file, and it’s working fine with every file type except when I use any InDesign file, then actually reading the file that transfers the variables, crashes the App cold turkey! It CAN’T be the actual file format, but must be one of the written variables, but because it’s crashing, I can’t error trap it. Even logging doesn’t work. I’m attaching a compressed folder of two.dat files, one OK, the right one crashes. Does anyone know of a way of interpreting the data to tell me which variable is at fault, please? I’ve tried reading the .dat file with Applescript, but Script Editor crashes. I’ve been over and over my code since 8 am this morning, (it’s now 2:30 am the next morning), but can't locate what’s wrong, or why just a .indd file would do this. My 13,000+ lines of code is obviously wrong somewhere, but the handler compiling the variable file is not erroring, so I’m up the proverbial creek without a paddle! I need to somehow know which variable is causing the crash, please. The crash log is below, but I don’t know how to read the information. Does it help??? Googling has been useless. Alongside the arrowed line is this... Regards Santa libobjc.A.dylib`objc_retain: 0x7fffb03faf10 <+0>: pushq %rbp 0x7fffb03faf11 <+1>: movq %rsp, %rbp 0x7fffb03faf14 <+4>: xorl %eax, %eax 0x7fffb03faf16 <+6>: testq %rdi, %rdi 0x7fffb03faf19 <+9>: je 0x7fffb03faf64 ; <+84> 0x7fffb03faf1b <+11>: testb $0x1, %dil 0x7fffb03faf1f <+15>: jne 0x7fffb03faf61 ; <+81> 0x7fffb03faf21 <+17>: movq (%rdi), %rax 0x7fffb03faf24 <+20>: movabsq $0x7ffffffffff8, %rcx ; imm = 0x7FFFFFFFFFF8 0x7fffb03faf2e <+30>: andq %rax, %rcx -> 0x7fffb03faf31 <+33>: testb $0x2, 0x20(%rcx) 0x7fffb03faf35 <+37>: je 0x7fffb03faf66 ; <+86> 0x7fffb03faf37 <+39>: testb $0x1, %al 0x7fffb03faf39 <+41>: je 0x7fffb03faf5b ; <+75> 0x7fffb03faf3b <+43>: movabsq $0x100000000000000, %rcx ; imm = 0x100000000000000 0x7fffb03faf45 <+53>: movq %rax, %rdx 0x7fffb03faf48 <+56>: addq %rcx, %rdx 0x7fffb03faf4b <+59>: jb 0x7fffb03faf76 ; <+102> 0x7fffb03faf4d <+61>: lock 0x7fffb03faf4e <+62>: cmpxchgq %rdx, (%rdi) 0x7fffb03faf52 <+66>: je 0x7fffb03faf61 ; <+81> 0x7fffb03faf54 <+68>: movq (%rdi), %rax 0x7fffb03faf57 <+71>: testb $0x1, %al 0x7fffb03faf59 <+73>: jne 0x7fffb03faf45 ; <+53> 0x7fffb03faf5b <+75>: popq %rbp 0x7fffb03faf5c <+76>: jmp 0x7fffb0403118 ; objc_object::sidetable_retain() 0x7fffb03faf61 <+81>: movq %rdi, %rax 0x7fffb03faf64 <+84>: popq %rbp 0x7fffb03faf65 <+85>: retq 0x7fffb03faf66 <+86>: leaq 0x97555fb(%rip), %rax ; SEL_retain 0x7fffb03faf6d <+93>: movq (%rax), %rsi 0x7fffb03faf70 <+96>: popq %rbp 0x7fffb03faf71 <+97>: jmp 0x7fffb03fb040 ; objc_msgSend 0x7fffb03faf76 <+102>: xorl %esi, %esi 0x7fffb03faf78 <+104>: popq %rbp 0x7fffb03faf79 <+105>: jmp 0x7fffb04028ac ; objc_object::rootRetain_overflow(bool) 0x7fffb03faf7e <+110>: nop 0x7fffb03faf7f <+111>: nop
|
|
Re: How do I 'Lock in' the appearance of a Finder window???
You may be interested in a couple of scripts posted by Chris Stone earlier in the year:
Also see this post by Chris, to make the changes permanent after you have set them:
Best Regards,
Jim Underwood
aka JMichaelTX
From: AppleScript-Users <applescript-users-bounces+jmichael=apoemail.us@...> on behalf of Brian Christmas <ozsanta@...>
Date: Tuesday, August 22, 2017 at 12:12 AM To: Applescript Xcode new list <applescript@apple-dev.groups.io>, "ASUL (AppleScript)" <applescript-users@...> Subject: How do I 'Lock in' the appearance of a Finder window???
Is there ANY way of saving/opening that darn folder so nothing except the background image and the two icons display, please?
I’ve tried locking the folder, but nothing changes, except when it’s unlocked, a line appears in the window, that represents the old right edge of the saved folder, and a white right vertical bar the same width as the sidebar is ‘locked’ onto the right of the
window.
There must be someway of doing it, as distributed Apps usually have a window with just the App icon, and backgound image, and an Application ‘alias’ icon.
|
|
Re: How do I 'Lock in' the appearance of a Finder window???
2551phil
You need to set the Finder view options when you open that folder, otherwise it’ll just use the default options on the user’s machine.
toggle quoted messageShow quoted text
You already know how to do that in AppleScript. Just check the Finder dictionary for the properties you want to change. E.g: tell application "Finder" tell front window # or the window’s name, better set toolbar visible to false # set… # what ever other properties you need end tell end tell Best Phil @sqwarq
|
|
How do I 'Lock in' the appearance of a Finder window???
Brian Christmas
G’day again
I’ve researched this for 3 hours, and no one seems to address my problem. I have a folder buried in my Application, that contains an image as a background, and two Applications. EVERYTHING about the folder display is turned OFF, even the Toolbar. However, when I save it and use a button to open it, the Toolbar reactivates, and the Sidebar also shows. Is there ANY way of saving/opening that darn folder so nothing except the background image and the two icons display, please? I’ve tried locking the folder, but nothing changes, except when it’s unlocked, a line appears in the window, that represents the old right edge of the saved folder, and a white right vertical bar the same width as the sidebar is ‘locked’ onto the right of the window. There must be someway of doing it, as distributed Apps usually have a window with just the App icon, and backgound image, and an Application ‘alias’ icon. Regards Santa
|
|
Re: Asking for Advice on distribution, please?
Brian Christmas
G’day Takaaki
toggle quoted messageShow quoted text
Thankd for this tip. I use the GUI heavily, and haden’t thought of localisation. I usually use numbers instead of names, but have used names where newer versions of Apps change the number of a GU I item between version numbers. I’ll have to change manu lines of code, but it will be worth it. Perhaps you’ll now be able to answer the next question I’m asbout to post. Regards Santa
|
|