• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

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

Explorer ,
Apr 13, 2022 Apr 13, 2022

Copy link to clipboard

Copied

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?

TOPICS
Scripting

Views

60

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Apr 13, 2022 Apr 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;

Likes

Translate

Translate
Guide ,
Apr 13, 2022 Apr 13, 2022

Copy link to clipboard

Copied

LATEST
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;

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines