Copy link to clipboard
Copied
For example:
My initial data for: var valueA1=ABCDEDR;
Now I perform a transformation on it:
Repeat for the first digit, and the last digit. I get the following:
var valueA2=AABCDEDRR;
Next, mix it again.
At the end, merge in a specific character, e.g. var ValueB=yesOKNO@22@
Eventually get:
var ValueA3=AABCDEDRRyesOKNO@22@;
Thank you very much.
Here are examples of the relevant string methods
var str = 'Hello World';
$.writeln(str.charCodeAt(0))
//Returns unicode for "H" 72
$.writeln(str.concat(' Hello', " There"))
//returns: Hello World Hello There
$.writeln(str.indexOf('o'))
// Returns: 4 (the first o index)
$.writeln(str.lastIndexOf('o'))
// Returns: 7 (the last o index)
$.writeln(str.match("\\w+"))
// Returns: regular expression search "Hello"
$.writeln(str.replace("World", "Planet"))
// Returns: Hello Planet
$.writeln(str
Copy link to clipboard
Copied
You can do this:
var valueA1 = "ABCDEDR"
valueA1 = "A"+valueA1+"R"
valueA1 = valueA1 + "yesOKNO@22@"
alert(valueA1)
Copy link to clipboard
Copied
Hi rob day
How to repeat a character, such as the 1st, 3rd, and last.
They are indeterminate, not necessarily A or R.
determines just the position.
Copy link to clipboard
Copied
Here are examples of the relevant string methods
var str = 'Hello World';
$.writeln(str.charCodeAt(0))
//Returns unicode for "H" 72
$.writeln(str.concat(' Hello', " There"))
//returns: Hello World Hello There
$.writeln(str.indexOf('o'))
// Returns: 4 (the first o index)
$.writeln(str.lastIndexOf('o'))
// Returns: 7 (the last o index)
$.writeln(str.match("\\w+"))
// Returns: regular expression search "Hello"
$.writeln(str.replace("World", "Planet"))
// Returns: Hello Planet
$.writeln(str.slice(0, 7))
// Returns: Hello W
$.writeln(str.split(" "));
// Returns an array of words: [Hello,World] array
$.writeln(str.substring(0, str.length-6))
// Returns: "Hello"
$.writeln(str.substring(4))
// Returns: "o World"
$.writeln(str.substring(6, 11));
// Returns: "World"
$.writeln(str.substring(str.length-1));
// Returns: "d"
$.writeln(str.toLocaleLowerCase());
// Returns: "hello world"
$.writeln(str.toLowerCase());
// Returns: "hello world"
$.writeln(str.toLocaleUpperCase());
// Returns: "hello world"
$.writeln(str.toUpperCase());
// Returns: "hello world"
$.writeln(str.indexOf('Y'))
// Returns: -1 because Y is not in the string
Copy link to clipboard
Copied
Hi rob day.
This is great.
I'm testing them one by one.
This is so comprehensive. I've been stuck or learning that there are no simple examples in the hand rules.
$.writeln
But I still want to ask what is $.writeln?
Is it something like alert();
but $.writeln doesn't output that either.
It seems that it is also not possible to directly repeat the 1st character of the command.
Thank you very much.
Copy link to clipboard
Copied
$.writeln prints the message in the console of the editor from which you execute the script i.e. VSCode or ESTK. This is used by script developers, it won't display anything if you execute the script via scripts panel.
-Manan
Copy link to clipboard
Copied
In VSCode you get this
Copy link to clipboard
Copied
Hi rob day, Manan Joshi
Learned, thank you very much.
I'm all about testing with alert in ID, and I feel like ID comes pretty fast and doesn't need to be configured.
Mostly I don't have time to configure VS right now.
Copy link to clipboard
Copied
Without a debugger app you would have to use alert().
You also can't get much in the way of error feedback or code help from a plain text editor.
Copy link to clipboard
Copied
What you described is just string manipulation and currently it is just appending string at the start or end. If your actual need would require operations like adding/removing/querying part of string from a defined location etc you would need more that append functionality. For all the string functions available to you, check out the following link
InDesign ExtendScript API Adobe InDesign 2025 (20.0.0.95) Object Model - String
-Manan
Copy link to clipboard
Copied
Hi Manan Joshi
This is it, thank you very much.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now