This seems like it would be a very easy problem to solve, but I've been banging my head against it for almost an hour. All I need is a snippet of javascript/extendscript code so that my InDesign CS6 script can create a folder. I know the existing folder in which the new one should be created, and I know the name that this new folder should be called. But how do I get javascript to do it?
By the way, all searches online for the folderObj.create() method, which is in the JavaScript Tools Guide, prove useless. I've tried several variations on that method, but nothing seems to actually create the folder. What am I missing?
var f = new Folder('/c/myfolder/');
if (!f.exists)
f.create();
Okay, found a work-around: I have to specify the folder absolutely, rather than use the ~ home shortcut. In addition, I have use /Volumes at the very beginning. Thus, the code becomes:
var f = new Folder("/Volumes/apache HD/Users/apache/Desktop/my_new_fodler");
f.create();
And that seems to work, finally. Thanks for your help, #Anna Forrest and #fabiantheblind! (You seem to be the resident ExtendScript expert around here.)
try this:
var f = new Folder("~/Desktop/my_new_fodler");
f.create();
Related
I have been searching the web for a answer but cant find it. In vscode i cant get intellisense for javascript working.
Example:
var name = "test";
var name.to.... here i want it to suggest touppercase, but nothing is happening.
Any good suggestions about fixing this?
make sure the language selected is set to javaScript. when the file extension is .js it's automatically set the lang to js. if your file does not have the .js extension you just need to set it manually in the bottom bar.
docs
Had a situation today, s1 has intellisense, but s2 has Not
adding 'let' to s2 fixed the issue, maybe a scoped variable can help VS code infer the type & provide intellisense.
Some Background:
I've been looking for a way to programmatically create a pdf from a collection of images. It’s possible to do 90% of what I need through Word automation, but the problem is you can’t disable JPEG conversion when exporting to a PDF. Originally, I had hoped there’d be a free command line utility out there, but that’s not the case.
The best thing I could find is the JavaScript library jsPDF. I know almost nothing about Javascript, but library seems easy enough to use from the documentation.
This page has an extremely basic example of using JavaScript with VBA. Sadly there’s very little information out there on doing this kind of thing.
The only relevant thing I could find on Stackoverflow is this one unresolved post. I attempted the same method here and not surprisingly, it didn’t work. I get an error stating saying “syntax error” on the add code line.
Sub PDF1()
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim script As String
script = fso.OpenTextFile("***\jsPDF-master\src\jspdf.js", 1, False).ReadAll
‘This requires a reference to Microsoft Script Control 1.0
Dim o As New ScriptControl
o.Language = "JScript"
With o
.AddCode script
End With
End Sub
I really doubt this is the right approach. The entire library is probably 20k+ lines of code. Is what I’m trying to do even possible?
Any help would be greatly appreciated. Any other suggestions of alternate methods creating PDFs would also be helpful.
I tried searching, but with not luck.
I want to convert/wrap an executable to use it easily and nicely in node, and not calling child_process.exec all the time.
For example, if I wanted to do it with git, instead of git help or git clone git://repo.git I'll have somethings like:
var git = new cmd('git');
git.help();
git.clone('git://repo.git');
etc..
Doe's anyone knows if something like that exist?
The closest thing I've found so far is run-cmd which can do somethings like that but not automatically. I'll need to create the object with all the parameters I want.
Thanks,
Ariel
I have this code in a JavaScript file:
this.tooltipWindow = new Window("__tooltip__", TooltipManager.options);
This gives me the TypeError: Window is not a constructor error in Firefox. Is there something wrong with this code and yes, how can I rewrite it, so it works?
Thanks!
If you have a type defined by the word "Window", it's likely interfering with the actual 'window' object that exists on all pages.
If you're actually trying to create a new 'Window', as in the browser-typed object, that way, then I think that you're entering into some unfamiliar areas to me...are you just trying to create a popup window?
https://developer.mozilla.org/en-US/docs/Web/API/Window.open
A quick search on that line of code pointed me to a library called ATK, specifically the tooltip.js file. At first glance it's quite a complete library, but it seems like you are only using tooltip.js. Since the Window class is defined in window.js you'll need to include that script as well to make it work.
I don't know the framework myself, so it might be wise to check if it even supports cherry-picking specific pieces of code like that.
Many resources on the internet (including here) suggest using Meteor.startup to fix dependency issues caused by the order in which JS files load. However, nobody spells out exactly how this is accomplished.
Specifically, it seems like file order dependency is the reason I can't get my posts.coffee collection to recognize permissions defined in my permissions.coffee. I think this is happening because posts.coffee is in /lib/collections, whereas permissions.coffee is in /lib, and files in subdirectories get loaded first. (Incidentally, I would prefer /collections to be in the root directory, but I had to move it into /lib previously to solve a similar problem.)
Here is my posts.coffee:
#Posts = new Meteor.Collection('posts')
Posts.allow(
update: ownsDocument
remove: ownsDocument
)
Meteor.methods(
...
And here is my permissions.coffee:
#ownsDocument = (userId, doc)->
doc && doc.userId == userId
(This is all from the "Discover Meteor" book tutorial, by the way, around these commits, except in CoffeeScript.)
My question: Assuming my analysis of the problem is correct, how would you solve it using Meteor.startup? This answer is hard for me to interpret; one interpretation is that I should wrap Posts.allow(...) in Meteor.startup somehow, but that seems really clumsy. Maybe I'm wrong, but it seems like there should be one general/config file with all the necessary startup code, and specific controllers should remain ignorant of it.
BTW, I realize I could hack a solution by taking advantage of Meteor's default file load ordering rules (e.g. /lib first; subdirectories first; main.* last; alphabetically), but that's a really inelegant solution to what should be a simple problem. I don't want to have to append "a" in front of a filename or create spurious directories just to get it load before another file.
One last note: I'm using CoffeeScript, and I wonder if the way CS handles global scope has something to do with it. (E.g., instead of defining my Posts collection as a JS variable without the var keyword, in CS I have to define is as #Posts, which I believe makes it a property of the window.)
Yes, you do just that:
Meteor.startup ->
Posts.allow(
...
)
Basically, any piece of code that uses a variable defined in another file should be preceded by Meteor.startup ->, unless you are sure that the loading order is correct (the variable is in lib, for example).
Yes, the loading order is poorly chosen.
I highly suggest you consider working entirely out of smart packages. That's how Meteor itself is largely written.
I go into more detail here: http://www.matb33.me/2013/09/05/meteor-project-structure.html