Shoopity
Shoopity

Reputation: 3

General assistance in Google Apps scripting

OK, I'm tired of searching for specific questions to help with a project, finding answers, changing my implementation which just adds more questions, realizing there's a better way to do things, etc. So allow me to ask for general assistance, I will then do my best to research how to do it and ask further questions if needed.

I've got the layout mostly. Some problems I'm coming across:

Upvotes: -1

Views: 643

Answers (1)

Mogsdad
Mogsdad

Reputation: 45710

Since you asked, yes, separate questions would be appropriate, because the combination of questions is very specialized, while the individual problems might be more general, and of use to more people. But let me take a stab at it anyway...

[With the result of find()]... how can I also get the ID that's stored somewhere else?

DocsList.find() returns a list of File objects. Class File has a getId() method that returns the document ID you are used to seeing in Google Drive. To get the IDs of all your files:

var files = DocsList.getAllFiles();
for (var i in files) {
  Logger.log(files[i].getId());
}

You should also look at DocsListDialog for creating a file picker that works on Google Drive.

RichTextArea has been deprecated, is there a replacement?

No, not in apps-script. You've just got TextArea. However, you may be able to embed a third-party rich text editor in your UI.

To do the transposing, ... is there a better way to do this?

Change the TextArea.value into an array of lines, then manipulate those, without needing to manage an on/off state. See How do I get information out of TextArea in Google App Script on the button click? and Javascript: Convert textarea into an array.

// aTextArea contains user's input. Probably a Johnny Cash song.
var inputText = e.parameter.aTextArea;
var inputLines = inputText.split('\n');
for (var i in inputLines) {
  if (inputLines[i].charAt(0) == '.') {
    // Transpose
  }
}
// Put lines back together, if you wish
var outputText = inputLines.join('\n');

..is there way to add a script to a Google Document that would do the transposing...

Yes (capability extended to Docs and Forms since question was originally asked). No, Spreadsheets are the only document type that can be a container for scripts at this time.

Alternatively, you could employ a stand-alone script to operate directly on Docs! Perhaps with a script deployed as a Web App that lets users pick the target music to transpose from documents on their Google Drive, and that then writes a new copy of the document, transposed?

Upvotes: 2

Related Questions