Skip to main content
__Alain__
Inspiring
April 13, 2022
Answered

How to store color-data in a txt-file?

  • April 13, 2022
  • 1 reply
  • 247 views

Hi

 

 

I would like to store color-data in a txt-file.

To do this I need data from type string (I guess).

 

The data comes from a RGBColor-Object.

 

var newRGBColor = new RGBColor();

 

 

To convert to string I tried this
(the idea was to concatenate red, green and blue to a comma speparated string):

 

var newRGBColorAsStringRed = newRGBColor.red.toString();

 

But it does not work.

 

This does not work as well:

var newRGBColorAsString = JSON.stringify(newRGBColor);

 

Does anybody know how to store the color-data in the txt-file?

This topic has been closed for replies.
Correct answer femkeblanco
var newRGBColor = new RGBColor();

// to get string of names and values of properties of object 
var string1 = "";
for (var k in newRGBColor) {
    string1 += k + ": " + newRGBColor[k] + "\r";
}
// to save to txt file on desktop
var file1 = new File("~/Desktop/New Text Document.txt");
file1.open("e");
file1.write(string1);
file1.close;

1 reply

femkeblanco
femkeblancoCorrect answer
Legend
April 13, 2022
var newRGBColor = new RGBColor();

// to get string of names and values of properties of object 
var string1 = "";
for (var k in newRGBColor) {
    string1 += k + ": " + newRGBColor[k] + "\r";
}
// to save to txt file on desktop
var file1 = new File("~/Desktop/New Text Document.txt");
file1.open("e");
file1.write(string1);
file1.close;