VCOO0020
OmniOutliner: Format Selected Columns
A set of commands for applying formatting to the selected columns.
- “Format Columns as Whole Numbers” • Formats the selected number columns as whole (non-decimal) numbers: 1234
- “Format Columns as Percentages” • Formats the selected number columns as standard non-decimal percentage values: 45%
- “Format Columns as Decimal Percentages” • Formats the selected number columns as decimal percentage values: 45.01%
- “Format Columns as Currency” • Formats the selected number columns as localized currency values: $12.34
- “Format Columns as Decimal Numbers” • Formats the selected number columns as decimal numbers with 2-digit precision: 12.34
- “Format Columns as Dates” • Formats the selected date columns with localized short date format: 12/23/22
- “Format Columns as Dates and Times” • Formats the selected date columns with localized short date and time format: 12/3/22, 3:45 AM
- “Format Columns as Times” • Formats the selected date columns with localized short time format: 3:45 AM
Scope and Syntax
Language: English (United States 🇺🇸 · Great Britain 🇬🇧 · Australia 🇦🇺 · Canada 🇨🇦)
Scope: OmniOutliner
Command phrase variations (words in [brackets] are optional):
- “Format Columns as Whole Numbers”
- “Format Columns as Integers”
- “Format Columns as Percentages”
- “Format Columns as Decimal Percentages”
- “Format Columns as Currency”
- “Format Columns as Decimal Numbers”
- “Format Columns as Dates”
- “Format Columns as Times”
- “Format Columns as Dates and Times”
Requirements
IMPORTANT: In the iOS/iPadOS version of OmniOutliner, columns cannot be “selected” as elements.
- Application: OmniOutliner: 5.10 (macOS), OmniOutliner 3.9.1 (iOS/iPadOS)
- System: macOS 12, iOS 15, iPadOS 15
Video: Format Selected Columns |
A set of commands for applying formatting to the selected columns. |
|
Video: Format Chosen Columns |
A set of commands for applying formatting to the chosen columns. |
|
Downloads
- ⇩ COMMANDS-FILE (OmniOutliner 5) (macOS)
- ⇩ SHORTCUT-LINK (“Format Columns as Whole Numbers”) (iOS/iPadOS)
- ⇩ SHORTCUT-LINK (“Format Columns as Percentages”) (iOS/iPadOS)
- ⇩ SHORTCUT-LINK (“Format Columns as Decimal Percentages”) (iOS/iPadOS)
- ⇩ SHORTCUT-LINK (“Format Columns as Currency”) (iOS/iPadOS)
- ⇩ SHORTCUT-LINK (“Format Columns as Decimal Numbers”) (iOS/iPadOS)
- ⇩ SHORTCUT-LINK (“Format Columns as Dates”) (iOS/iPadOS)
- ⇩ SHORTCUT-LINK (“Format Columns as Times”) (iOS/iPadOS)
- ⇩ SHORTCUT-LINK (“Format Columns as Dates and Times”) (iOS/iPadOS)
Script Code
Here is the script code for the commands:
Format Columns as Whole Numbers
(async () => {
try {
function createUtterance(textToSpeak){
AlexID = (
(app.platformName === "macOS") ?
"com.apple.speech.synthesis.voice.Alex" :
"com.apple.speech.voice.Alex"
)
voiceObj = Speech.Voice.withIdentifier(AlexID)
voiceRate = 0.4
utterance = new Speech.Utterance(textToSpeak)
utterance.voice = voiceObj
utterance.rate = voiceRate
return utterance
}
var synthesizer = new Speech.Synthesizer()
var fmtr = Formatter.Decimal.plain
var responsePhrase = "Columns Formatted as Rounded Integers"
tree = document.outline
editor = document.editors[0]
selectedColumns = editor.selection.columns
if(selectedColumns.length === 0){
throw {
name: "Selection Issue",
message: "Please select one or more columns."
}
} else {
selectedColumns.forEach(col => {
if(col.type === Column.Type.Number){
col.formatter = fmtr
} else {
throw {
name: "Type Error",
message: `The contents of column “${col.title}” cannot be formatted as a numeric value.`
}
}
})
utterance = createUtterance(responsePhrase)
synthesizer.speakUtterance(utterance)
}
}
catch(err){
utterance = createUtterance(err.message)
synthesizer.speakUtterance(utterance)
//new Alert(err.name, err.message).show()
}
})();
Format Columns as Percentages
(async () => {
try {
function createUtterance(textToSpeak){
AlexID = (
(app.platformName === "macOS") ?
"com.apple.speech.synthesis.voice.Alex" :
"com.apple.speech.voice.Alex"
)
voiceObj = Speech.Voice.withIdentifier(AlexID)
voiceRate = 0.4
utterance = new Speech.Utterance(textToSpeak)
utterance.voice = voiceObj
utterance.rate = voiceRate
return utterance
}
var synthesizer = new Speech.Synthesizer()
var fmtr = Formatter.Decimal.percent
var responsePhrase = "Columns Formatted as Percentages"
tree = document.outline
editor = document.editors[0]
selectedColumns = editor.selection.columns
if(selectedColumns.length === 0){
throw {
name: "Selection Issue",
message: "Please select one or more columns."
}
} else {
selectedColumns.forEach(col => {
if(col.type === Column.Type.Number){
col.formatter = fmtr
} else {
throw {
name: "Type Error",
message: `The contents of column “${col.title}” cannot be formatted as percentage values.`
}
}
})
utterance = createUtterance(responsePhrase)
synthesizer.speakUtterance(utterance)
}
}
catch(err){
utterance = createUtterance(err.message)
synthesizer.speakUtterance(utterance)
//new Alert(err.name, err.message).show()
}
})();
Format Columns as Decimal Percentages
(async () => {
try {
function createUtterance(textToSpeak){
AlexID = (
(app.platformName === "macOS") ?
"com.apple.speech.synthesis.voice.Alex" :
"com.apple.speech.voice.Alex"
)
voiceObj = Speech.Voice.withIdentifier(AlexID)
voiceRate = 0.4
utterance = new Speech.Utterance(textToSpeak)
utterance.voice = voiceObj
utterance.rate = voiceRate
return utterance
}
var synthesizer = new Speech.Synthesizer()
var fmtr = Formatter.Decimal.percentWithDecimal
var responsePhrase = "Columns Formatted as Decimal Percentages"
tree = document.outline
editor = document.editors[0]
selectedColumns = editor.selection.columns
if(selectedColumns.length === 0){
throw {
name: "Selection Issue",
message: "Please select one or more columns."
}
} else {
selectedColumns.forEach(col => {
if(col.type === Column.Type.Number){
col.formatter = fmtr
} else {
throw {
name: "Type Error",
message: `The contents of column “${col.title}” cannot be formatted as decimal percentage values.`
}
}
})
utterance = createUtterance(responsePhrase)
synthesizer.speakUtterance(utterance)
}
}
catch(err){
utterance = createUtterance(err.message)
synthesizer.speakUtterance(utterance)
//new Alert(err.name, err.message).show()
}
})();
Format Columns as Currency
(async () => {
try {
function createUtterance(textToSpeak){
AlexID = (
(app.platformName === "macOS") ?
"com.apple.speech.synthesis.voice.Alex" :
"com.apple.speech.voice.Alex"
)
voiceObj = Speech.Voice.withIdentifier(AlexID)
voiceRate = 0.4
utterance = new Speech.Utterance(textToSpeak)
utterance.voice = voiceObj
utterance.rate = voiceRate
return utterance
}
var synthesizer = new Speech.Synthesizer()
var fmtr = Formatter.Decimal.currency()
var responsePhrase = "Columns Formatted as Currency"
tree = document.outline
editor = document.editors[0]
selectedColumns = editor.selection.columns
if(selectedColumns.length === 0){
throw {
name: "Selection Issue",
message: "Please select one or more columns."
}
} else {
selectedColumns.forEach(col => {
if(col.type === Column.Type.Number){
col.formatter = fmtr
} else {
throw {
name: "Type Error",
message: `The contents of column “${col.title}” cannot be formatted as currency values.`
}
}
})
utterance = createUtterance(responsePhrase)
synthesizer.speakUtterance(utterance)
}
}
catch(err){
utterance = createUtterance(err.message)
synthesizer.speakUtterance(utterance)
//new Alert(err.name, err.message).show()
}
})();
Format Columns as Decimal Numbers
(async () => {
try {
function createUtterance(textToSpeak){
AlexID = (
(app.platformName === "macOS") ?
"com.apple.speech.synthesis.voice.Alex" :
"com.apple.speech.voice.Alex"
)
voiceObj = Speech.Voice.withIdentifier(AlexID)
voiceRate = 0.4
utterance = new Speech.Utterance(textToSpeak)
utterance.voice = voiceObj
utterance.rate = voiceRate
return utterance
}
var synthesizer = new Speech.Synthesizer()
var fmtr = Formatter.Decimal.decimal
var responsePhrase = "Columns Formatted as Decimal Numbers"
tree = document.outline
editor = document.editors[0]
selectedColumns = editor.selection.columns
if(selectedColumns.length === 0){
throw {
name: "Selection Issue",
message: "Please select one or more columns."
}
} else {
selectedColumns.forEach(col => {
if(col.type === Column.Type.Number){
col.formatter = fmtr
} else {
throw {
name: "Type Error",
message: `The contents of column “${col.title}” cannot be formatted as decimal numeric values.`
}
}
})
utterance = createUtterance(responsePhrase)
synthesizer.speakUtterance(utterance)
}
}
catch(err){
utterance = createUtterance(err.message)
synthesizer.speakUtterance(utterance)
//new Alert(err.name, err.message).show()
}
})();
Format Columns as Dates
(async () => {
try {
function createUtterance(textToSpeak){
AlexID = (
(app.platformName === "macOS") ?
"com.apple.speech.synthesis.voice.Alex" :
"com.apple.speech.voice.Alex"
)
voiceObj = Speech.Voice.withIdentifier(AlexID)
voiceRate = 0.4
utterance = new Speech.Utterance(textToSpeak)
utterance.voice = voiceObj
utterance.rate = voiceRate
return utterance
}
var synthesizer = new Speech.Synthesizer()
var fmtr = Formatter.Date.withStyle(Formatter.Date.Style.Short)
var responsePhrase = "Columns Formatted as Dates"
tree = document.outline
editor = document.editors[0]
selectedColumns = editor.selection.columns
if(selectedColumns.length === 0){
throw {
name: "Selection Issue",
message: "Please select one or more columns."
}
} else {
selectedColumns.forEach(col => {
if(col.type === Column.Type.Date){
col.formatter = fmtr
} else {
throw {
name: "Type Error",
message: `The contents of column “${col.title}” cannot be formatted as a date value.`
}
}
})
utterance = createUtterance(responsePhrase)
synthesizer.speakUtterance(utterance)
}
}
catch(err){
utterance = createUtterance(err.message)
synthesizer.speakUtterance(utterance)
//new Alert(err.name, err.message).show()
}
})();
Format Columns as Dates and Times
(async () => {
try {
function createUtterance(textToSpeak){
AlexID = (
(app.platformName === "macOS") ?
"com.apple.speech.synthesis.voice.Alex" :
"com.apple.speech.voice.Alex"
)
voiceObj = Speech.Voice.withIdentifier(AlexID)
voiceRate = 0.4
utterance = new Speech.Utterance(textToSpeak)
utterance.voice = voiceObj
utterance.rate = voiceRate
return utterance
}
var synthesizer = new Speech.Synthesizer()
var fmtr = Formatter.Date.withStyle(Formatter.Date.Style.Short, Formatter.Date.Style.Short)
var responsePhrase = "Columns Formatted as Dates and Times"
tree = document.outline
editor = document.editors[0]
selectedColumns = editor.selection.columns
if(selectedColumns.length === 0){
throw {
name: "Selection Issue",
message: "Please select one or more columns."
}
} else {
selectedColumns.forEach(col => {
if(col.type === Column.Type.Date){
col.formatter = fmtr
} else {
throw {
name: "Type Error",
message: `The contents of column “${col.title}” cannot be formatted as a date value.`
}
}
})
utterance = createUtterance(responsePhrase)
synthesizer.speakUtterance(utterance)
}
}
catch(err){
utterance = createUtterance(err.message)
synthesizer.speakUtterance(utterance)
//new Alert(err.name, err.message).show()
}
})();
Format Columns as Times
(async () => {
try {
function createUtterance(textToSpeak){
AlexID = (
(app.platformName === "macOS") ?
"com.apple.speech.synthesis.voice.Alex" :
"com.apple.speech.voice.Alex"
)
voiceObj = Speech.Voice.withIdentifier(AlexID)
voiceRate = 0.4
utterance = new Speech.Utterance(textToSpeak)
utterance.voice = voiceObj
utterance.rate = voiceRate
return utterance
}
var synthesizer = new Speech.Synthesizer()
var fmtr = Formatter.Date.withFormat('h:mm a')
var responsePhrase = "Columns Formatted as Times"
tree = document.outline
editor = document.editors[0]
selectedColumns = editor.selection.columns
if(selectedColumns.length === 0){
throw {
name: "Selection Issue",
message: "Please select one or more columns."
}
} else {
selectedColumns.forEach(col => {
if(col.type === Column.Type.Date){
col.formatter = fmtr
} else {
throw {
name: "Type Error",
message: `The contents of column “${col.title}” cannot be formatted as a time value.`
}
}
})
utterance = createUtterance(responsePhrase)
synthesizer.speakUtterance(utterance)
}
}
catch(err){
utterance = createUtterance(err.message)
synthesizer.speakUtterance(utterance)
//new Alert(err.name, err.message).show()
}
})();
iOS/iPadOS Versions
Since OmniOutliner on iOS/iPadOS does not support the selection of columns, the user is presented with a list of appropriate columns to be chosen via checkbox selection. These versions are used in the corresponding Shortcuts actions. (above)
Format Columns as Whole Numbers (iOS/iPadOS)
(async () => {
try {
function createUtterance(textToSpeak){
AlexID = (
(app.platformName === "macOS") ?
"com.apple.speech.synthesis.voice.Alex" :
"com.apple.speech.voice.Alex"
)
voiceObj = Speech.Voice.withIdentifier(AlexID)
voiceRate = 0.4
utterance = new Speech.Utterance(textToSpeak)
utterance.voice = voiceObj
utterance.rate = voiceRate
return utterance
}
var synthesizer = new Speech.Synthesizer()
matchedColumns = columns.filter(col => {return col.type === Column.Type.Number})
if (matchedColumns.length === 0){
throw {
name: "No Matches",
message: "This outline does not contain “Number” columns."
}
}
columnTitles = matchedColumns.map(col => col.title)
columnIndexes = columnTitles.map((item, index) => index)
multiOptionMenu = new Form.Field.MultipleOptions(
"columnIndexes",
"Columns",
columnIndexes,
columnTitles,
[]
)
// CREATE NEW FORM AND ADD FIELD
var inputForm = new Form()
inputForm.addField(multiOptionMenu)
// VALIDATE SELECTION
inputForm.validate = function(formObject){
indexes = formObject.values["columnIndexes"]
// ensure at least one item is selected
return (indexes.length > 0)
}
// DISPLAY THE FORM
formPrompt = "Select the columns to format:"
buttonTitle = "Continue"
utterance = createUtterance(formPrompt)
synthesizer.speakUtterance(utterance)
formObject = await inputForm.show(formPrompt, buttonTitle)
// RETRIVE FORM INPUT
columnIndexes = formObject.values["columnIndexes"]
console.log("columnIndexes", JSON.stringify(columnIndexes))
// DETERMINE SELECTION
chosenColumns = new Array()
columnIndexes.forEach(indx => chosenColumns.push(matchedColumns[indx]))
// PROCESS COLUMNS
fmtr = Formatter.Decimal.plain
chosenColumns.forEach(col => {
console.log("column title", col.title)
col.formatter = fmtr
})
// CONFIRMATION
columnCount = chosenColumns.length
columnOrColumns = (columnCount === 1) ? "column":"columns"
oneOrMultiple = (columnCount === 1) ? "a rounded integer":"rounded integers"
responsePhrase = `${columnCount} ${columnOrColumns} formatted as ${oneOrMultiple}.`
utterance = createUtterance(responsePhrase)
synthesizer.speakUtterance(utterance)
}
catch(err){
if(!err.causedByUserCancelling){
utterance = createUtterance(err.message)
synthesizer.speakUtterance(utterance)
//new Alert(err.name, err.message).show()
}
}
})();
Format Columns as Percentages (iOS/iPadOS)
(async () => {
try {
function createUtterance(textToSpeak){
AlexID = (
(app.platformName === "macOS") ?
"com.apple.speech.synthesis.voice.Alex" :
"com.apple.speech.voice.Alex"
)
voiceObj = Speech.Voice.withIdentifier(AlexID)
voiceRate = 0.4
utterance = new Speech.Utterance(textToSpeak)
utterance.voice = voiceObj
utterance.rate = voiceRate
return utterance
}
var synthesizer = new Speech.Synthesizer()
matchedColumns = columns.filter(col => {return col.type === Column.Type.Number})
if (matchedColumns.length === 0){
throw {
name: "No Matches",
message: "This outline does not contain “Number” columns."
}
}
columnTitles = matchedColumns.map(col => col.title)
columnIndexes = columnTitles.map((item, index) => index)
multiOptionMenu = new Form.Field.MultipleOptions(
"columnIndexes",
"Columns",
columnIndexes,
columnTitles,
[]
)
// CREATE NEW FORM AND ADD FIELD
var inputForm = new Form()
inputForm.addField(multiOptionMenu)
// VALIDATE SELECTION
inputForm.validate = function(formObject){
indexes = formObject.values["columnIndexes"]
// ensure at least one item is selected
return (indexes.length > 0)
}
// DISPLAY THE FORM
formPrompt = "Select the columns to format:"
buttonTitle = "Continue"
utterance = createUtterance(formPrompt)
synthesizer.speakUtterance(utterance)
formObject = await inputForm.show(formPrompt, buttonTitle)
// RETRIVE FORM INPUT
columnIndexes = formObject.values["columnIndexes"]
console.log("columnIndexes", JSON.stringify(columnIndexes))
// DETERMINE SELECTION
chosenColumns = new Array()
columnIndexes.forEach(indx => chosenColumns.push(matchedColumns[indx]))
// PROCESS COLUMNS
fmtr = Formatter.Decimal.percent
chosenColumns.forEach(col => {
console.log("column title", col.title)
col.formatter = fmtr
})
// CONFIRMATION
columnCount = chosenColumns.length
columnOrColumns = (columnCount === 1) ? "column":"columns"
oneOrMultiple = (columnCount === 1) ? "a percentage":"percentages"
responsePhrase = `${columnCount} ${columnOrColumns} formatted as ${oneOrMultiple}.`
utterance = createUtterance(responsePhrase)
synthesizer.speakUtterance(utterance)
}
catch(err){
if(!err.causedByUserCancelling){
utterance = createUtterance(err.message)
synthesizer.speakUtterance(utterance)
//new Alert(err.name, err.message).show()
}
}
})();
Format Columns as Decimal Percentages (iOS/iPadOS)
(async () => {
try {
function createUtterance(textToSpeak){
AlexID = (
(app.platformName === "macOS") ?
"com.apple.speech.synthesis.voice.Alex" :
"com.apple.speech.voice.Alex"
)
voiceObj = Speech.Voice.withIdentifier(AlexID)
voiceRate = 0.4
utterance = new Speech.Utterance(textToSpeak)
utterance.voice = voiceObj
utterance.rate = voiceRate
return utterance
}
var synthesizer = new Speech.Synthesizer()
matchedColumns = columns.filter(col => {return col.type === Column.Type.Number})
if (matchedColumns.length === 0){
throw {
name: "No Matches",
message: "This outline does not contain “Number” columns."
}
}
columnTitles = matchedColumns.map(col => col.title)
columnIndexes = columnTitles.map((item, index) => index)
multiOptionMenu = new Form.Field.MultipleOptions(
"columnIndexes",
"Columns",
columnIndexes,
columnTitles,
[]
)
// CREATE NEW FORM AND ADD FIELD
var inputForm = new Form()
inputForm.addField(multiOptionMenu)
// VALIDATE SELECTION
inputForm.validate = function(formObject){
indexes = formObject.values["columnIndexes"]
// ensure at least one item is selected
return (indexes.length > 0)
}
// DISPLAY THE FORM
formPrompt = "Select the columns to format:"
buttonTitle = "Continue"
utterance = createUtterance(formPrompt)
synthesizer.speakUtterance(utterance)
formObject = await inputForm.show(formPrompt, buttonTitle)
// RETRIVE FORM INPUT
columnIndexes = formObject.values["columnIndexes"]
console.log("columnIndexes", JSON.stringify(columnIndexes))
// DETERMINE SELECTION
chosenColumns = new Array()
columnIndexes.forEach(indx => chosenColumns.push(matchedColumns[indx]))
// PROCESS COLUMNS
fmtr = Formatter.Decimal.percentWithDecimal
chosenColumns.forEach(col => {
console.log("column title", col.title)
col.formatter = fmtr
})
// CONFIRMATION
columnCount = chosenColumns.length
columnOrColumns = (columnCount === 1) ? "column":"columns"
oneOrMultiple = (columnCount === 1) ? "a decimal percentage":"decimal percentages"
responsePhrase = `${columnCount} ${columnOrColumns} formatted as ${oneOrMultiple}.`
utterance = createUtterance(responsePhrase)
synthesizer.speakUtterance(utterance)
}
catch(err){
if(!err.causedByUserCancelling){
utterance = createUtterance(err.message)
synthesizer.speakUtterance(utterance)
//new Alert(err.name, err.message).show()
}
}
})();
Format Columns as Currency (iOS/iPadOS)
(async () => {
try {
function createUtterance(textToSpeak){
AlexID = (
(app.platformName === "macOS") ?
"com.apple.speech.synthesis.voice.Alex" :
"com.apple.speech.voice.Alex"
)
voiceObj = Speech.Voice.withIdentifier(AlexID)
voiceRate = 0.4
utterance = new Speech.Utterance(textToSpeak)
utterance.voice = voiceObj
utterance.rate = voiceRate
return utterance
}
var synthesizer = new Speech.Synthesizer()
matchedColumns = columns.filter(col => {return col.type === Column.Type.Number})
if (matchedColumns.length === 0){
throw {
name: "No Matches",
message: "This outline does not contain “Number” columns."
}
}
columnTitles = matchedColumns.map(col => col.title)
columnIndexes = columnTitles.map((item, index) => index)
multiOptionMenu = new Form.Field.MultipleOptions(
"columnIndexes",
"Columns",
columnIndexes,
columnTitles,
[]
)
// CREATE NEW FORM AND ADD FIELD
var inputForm = new Form()
inputForm.addField(multiOptionMenu)
// VALIDATE SELECTION
inputForm.validate = function(formObject){
indexes = formObject.values["columnIndexes"]
// ensure at least one item is selected
return (indexes.length > 0)
}
// DISPLAY THE FORM
formPrompt = "Select the columns to format:"
buttonTitle = "Continue"
utterance = createUtterance(formPrompt)
synthesizer.speakUtterance(utterance)
formObject = await inputForm.show(formPrompt, buttonTitle)
// RETRIVE FORM INPUT
columnIndexes = formObject.values["columnIndexes"]
console.log("columnIndexes", JSON.stringify(columnIndexes))
// DETERMINE SELECTION
chosenColumns = new Array()
columnIndexes.forEach(indx => chosenColumns.push(matchedColumns[indx]))
// PROCESS COLUMNS
fmtr = Formatter.Decimal.currency()
chosenColumns.forEach(col => {
console.log("column title", col.title)
col.formatter = fmtr
})
// CONFIRMATION
columnCount = chosenColumns.length
columnOrColumns = (columnCount === 1) ? "column":"columns"
responsePhrase = `${columnCount} ${columnOrColumns} formatted as currency.`
utterance = createUtterance(responsePhrase)
synthesizer.speakUtterance(utterance)
}
catch(err){
if(!err.causedByUserCancelling){
utterance = createUtterance(err.message)
synthesizer.speakUtterance(utterance)
//new Alert(err.name, err.message).show()
}
}
})();
Format Columns as Decimal Numbers (iOS/iPadOS)
(async () => {
try {
function createUtterance(textToSpeak){
AlexID = (
(app.platformName === "macOS") ?
"com.apple.speech.synthesis.voice.Alex" :
"com.apple.speech.voice.Alex"
)
voiceObj = Speech.Voice.withIdentifier(AlexID)
voiceRate = 0.4
utterance = new Speech.Utterance(textToSpeak)
utterance.voice = voiceObj
utterance.rate = voiceRate
return utterance
}
var synthesizer = new Speech.Synthesizer()
matchedColumns = columns.filter(col => {return col.type === Column.Type.Number})
if (matchedColumns.length === 0){
throw {
name: "No Matches",
message: "This outline does not contain “Number” columns."
}
}
columnTitles = matchedColumns.map(col => col.title)
columnIndexes = columnTitles.map((item, index) => index)
multiOptionMenu = new Form.Field.MultipleOptions(
"columnIndexes",
"Columns",
columnIndexes,
columnTitles,
[]
)
// CREATE NEW FORM AND ADD FIELD
var inputForm = new Form()
inputForm.addField(multiOptionMenu)
// VALIDATE SELECTION
inputForm.validate = function(formObject){
indexes = formObject.values["columnIndexes"]
// ensure at least one item is selected
return (indexes.length > 0)
}
// DISPLAY THE FORM
formPrompt = "Select the columns to format:"
buttonTitle = "Continue"
utterance = createUtterance(formPrompt)
synthesizer.speakUtterance(utterance)
formObject = await inputForm.show(formPrompt, buttonTitle)
// RETRIVE FORM INPUT
columnIndexes = formObject.values["columnIndexes"]
console.log("columnIndexes", JSON.stringify(columnIndexes))
// DETERMINE SELECTION
chosenColumns = new Array()
columnIndexes.forEach(indx => chosenColumns.push(matchedColumns[indx]))
// PROCESS COLUMNS
fmtr = Formatter.Decimal.decimal
chosenColumns.forEach(col => {
console.log("column title", col.title)
col.formatter = fmtr
})
// CONFIRMATION
columnCount = chosenColumns.length
columnOrColumns = (columnCount === 1) ? "column":"columns"
oneOrMultiple = (columnCount === 1) ? "a decimal number":"decimal numbers"
responsePhrase = `${columnCount} ${columnOrColumns} formatted as ${oneOrMultiple}.`
utterance = createUtterance(responsePhrase)
synthesizer.speakUtterance(utterance)
}
catch(err){
if(!err.causedByUserCancelling){
utterance = createUtterance(err.message)
synthesizer.speakUtterance(utterance)
//new Alert(err.name, err.message).show()
}
}
})();
Format Columns as Dates (iOS/iPadOS)
(async () => {
try {
function createUtterance(textToSpeak){
AlexID = (
(app.platformName === "macOS") ?
"com.apple.speech.synthesis.voice.Alex" :
"com.apple.speech.voice.Alex"
)
voiceObj = Speech.Voice.withIdentifier(AlexID)
voiceRate = 0.4
utterance = new Speech.Utterance(textToSpeak)
utterance.voice = voiceObj
utterance.rate = voiceRate
return utterance
}
var synthesizer = new Speech.Synthesizer()
matchedColumns = columns.filter(col => {return col.type === Column.Type.Date})
if (matchedColumns.length === 0){
throw {
name: "No Matches",
message: "This outline does not contain “Date” columns."
}
}
columnTitles = matchedColumns.map(col => col.title)
columnIndexes = columnTitles.map((item, index) => index)
multiOptionMenu = new Form.Field.MultipleOptions(
"columnIndexes",
"Columns",
columnIndexes,
columnTitles,
[]
)
// CREATE NEW FORM AND ADD FIELD
var inputForm = new Form()
inputForm.addField(multiOptionMenu)
// VALIDATE SELECTION
inputForm.validate = function(formObject){
indexes = formObject.values["columnIndexes"]
// ensure at least one item is selected
return (indexes.length > 0)
}
// DISPLAY THE FORM
formPrompt = "Select the columns to format:"
buttonTitle = "Continue"
utterance = createUtterance(formPrompt)
synthesizer.speakUtterance(utterance)
formObject = await inputForm.show(formPrompt, buttonTitle)
// RETRIVE FORM INPUT
columnIndexes = formObject.values["columnIndexes"]
console.log("columnIndexes", JSON.stringify(columnIndexes))
// DETERMINE SELECTION
chosenColumns = new Array()
columnIndexes.forEach(indx => chosenColumns.push(matchedColumns[indx]))
// PROCESS COLUMNS
fmtr = Formatter.Date.withStyle(Formatter.Date.Style.Short)
chosenColumns.forEach(col => {
console.log("column title", col.title)
col.formatter = fmtr
})
// CONFIRMATION
columnCount = chosenColumns.length
columnOrColumns = (columnCount === 1) ? "column":"columns"
oneOrMultiple = (columnCount === 1) ? "a short date":"short dates"
responsePhrase = `${columnCount} ${columnOrColumns} formatted as ${oneOrMultiple}.`
utterance = createUtterance(responsePhrase)
synthesizer.speakUtterance(utterance)
}
catch(err){
if(!err.causedByUserCancelling){
utterance = createUtterance(err.message)
synthesizer.speakUtterance(utterance)
//new Alert(err.name, err.message).show()
}
}
})();
Format Columns as Dates and Times (iOS/iPadOS)
(async () => {
try {
function createUtterance(textToSpeak){
AlexID = (
(app.platformName === "macOS") ?
"com.apple.speech.synthesis.voice.Alex" :
"com.apple.speech.voice.Alex"
)
voiceObj = Speech.Voice.withIdentifier(AlexID)
voiceRate = 0.4
utterance = new Speech.Utterance(textToSpeak)
utterance.voice = voiceObj
utterance.rate = voiceRate
return utterance
}
var synthesizer = new Speech.Synthesizer()
matchedColumns = columns.filter(col => {return col.type === Column.Type.Date})
if (matchedColumns.length === 0){
throw {
name: "No Matches",
message: "This outline does not contain “Date” columns."
}
}
columnTitles = matchedColumns.map(col => col.title)
columnIndexes = columnTitles.map((item, index) => index)
multiOptionMenu = new Form.Field.MultipleOptions(
"columnIndexes",
"Columns",
columnIndexes,
columnTitles,
[]
)
// CREATE NEW FORM AND ADD FIELD
var inputForm = new Form()
inputForm.addField(multiOptionMenu)
// VALIDATE SELECTION
inputForm.validate = function(formObject){
indexes = formObject.values["columnIndexes"]
// ensure at least one item is selected
return (indexes.length > 0)
}
// DISPLAY THE FORM
formPrompt = "Select the columns to format:"
buttonTitle = "Continue"
utterance = createUtterance(formPrompt)
synthesizer.speakUtterance(utterance)
formObject = await inputForm.show(formPrompt, buttonTitle)
// RETRIVE FORM INPUT
columnIndexes = formObject.values["columnIndexes"]
console.log("columnIndexes", JSON.stringify(columnIndexes))
// DETERMINE SELECTION
chosenColumns = new Array()
columnIndexes.forEach(indx => chosenColumns.push(matchedColumns[indx]))
// PROCESS COLUMNS
fmtr = Formatter.Date.withStyle(Formatter.Date.Style.Short, Formatter.Date.Style.Short)
chosenColumns.forEach(col => {
console.log("column title", col.title)
col.formatter = fmtr
})
// CONFIRMATION
columnCount = chosenColumns.length
columnOrColumns = (columnCount === 1) ? "column":"columns"
oneOrMultiple = (columnCount === 1) ? "a date and time":"dates and times"
responsePhrase = `${columnCount} ${columnOrColumns} formatted as ${oneOrMultiple}.`
utterance = createUtterance(responsePhrase)
synthesizer.speakUtterance(utterance)
}
catch(err){
if(!err.causedByUserCancelling){
utterance = createUtterance(err.message)
synthesizer.speakUtterance(utterance)
//new Alert(err.name, err.message).show()
}
}
})();
Format Columns as Times (iOS/iPadOS)
(async () => {
try {
function createUtterance(textToSpeak){
AlexID = (
(app.platformName === "macOS") ?
"com.apple.speech.synthesis.voice.Alex" :
"com.apple.speech.voice.Alex"
)
voiceObj = Speech.Voice.withIdentifier(AlexID)
voiceRate = 0.4
utterance = new Speech.Utterance(textToSpeak)
utterance.voice = voiceObj
utterance.rate = voiceRate
return utterance
}
var synthesizer = new Speech.Synthesizer()
matchedColumns = columns.filter(col => {return col.type === Column.Type.Date})
if (matchedColumns.length === 0){
throw {
name: "No Matches",
message: "This outline does not contain “Date” columns."
}
}
columnTitles = matchedColumns.map(col => col.title)
columnIndexes = columnTitles.map((item, index) => index)
multiOptionMenu = new Form.Field.MultipleOptions(
"columnIndexes",
"Columns",
columnIndexes,
columnTitles,
[]
)
// CREATE NEW FORM AND ADD FIELD
var inputForm = new Form()
inputForm.addField(multiOptionMenu)
// VALIDATE SELECTION
inputForm.validate = function(formObject){
indexes = formObject.values["columnIndexes"]
// ensure at least one item is selected
return (indexes.length > 0)
}
// DISPLAY THE FORM
formPrompt = "Select the columns to format:"
buttonTitle = "Continue"
utterance = createUtterance(formPrompt)
synthesizer.speakUtterance(utterance)
formObject = await inputForm.show(formPrompt, buttonTitle)
// RETRIVE FORM INPUT
columnIndexes = formObject.values["columnIndexes"]
console.log("columnIndexes", JSON.stringify(columnIndexes))
// DETERMINE SELECTION
chosenColumns = new Array()
columnIndexes.forEach(indx => chosenColumns.push(matchedColumns[indx]))
// PROCESS COLUMNS
fmtr = Formatter.Date.withFormat('h:mm a')
chosenColumns.forEach(col => {
console.log("column title", col.title)
col.formatter = fmtr
})
// CONFIRMATION
columnCount = chosenColumns.length
columnOrColumns = (columnCount === 1) ? "column":"columns"
oneOrMultiple = (columnCount === 1) ? "a time":"times"
responsePhrase = `${columnCount} ${columnOrColumns} formatted as ${oneOrMultiple}.`
utterance = createUtterance(responsePhrase)
synthesizer.speakUtterance(utterance)
}
catch(err){
if(!err.causedByUserCancelling){
utterance = createUtterance(err.message)
synthesizer.speakUtterance(utterance)
//new Alert(err.name, err.message).show()
}
}
})();
LEGAL
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Mention of third-party websites and products is for informational purposes only and constitutes neither an endorsement nor a recommendation. OMNI-AUTOMATION.COM assumes no responsibility with regard to the selection, performance or use of information or products found at third-party websites. OMNI-AUTOMATION.COM provides this only as a convenience to our users. OMNI-AUTOMATION.COM has not tested the information found on these sites and makes no representations regarding its accuracy or reliability. There are risks inherent in the use of any information or products found on the Internet, and OMNI-AUTOMATION.COM assumes no responsibility in this regard. Please understand that a third-party site is independent from OMNI-AUTOMATION.COM and that OMNI-AUTOMATION.COM has no control over the content on that website. Please contact the vendor for additional information.