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

Can you have a eval a variable within an object in scriptui?

Enthusiast ,
Mar 27, 2017 Mar 27, 2017

Copy link to clipboard

Copied

Is what I'm trying to do below possible? I want to loop through an array and create radio buttons and at least set whether they're enabled. I know my syntax is way off here, but just wondering if I can create radio1, radio2 and radio3 using variables or if I have to hardcode these. Plase note "radios.radio.eval(i).enabled" is a complete shot in the dark, and I've confirmed it doesn't work, but a lot of Adobe scripting is just closing your eyes and guessing.

radios = win.add ("group");

    radios.radio1 = radios.add ("radiobutton", undefined, "Long");

    radios.radio2 = radios.add ("radiobutton", undefined, "Short");

    radios.radio3 = radios.add ("radiobutton", undefined, "Full");

    for(i = 1; i<=3; i++) {

    radios.radio.eval(i).enabled = false;}

TOPICS
Scripting

Views

405

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

Community Expert , Mar 28, 2017 Mar 28, 2017

you could try adding the radio button along with the state in your loop

var w = new Window ('dialog', 'Create Radio Buttons');

var g = w.add('group');

var radioNames = ['tomatoes', 'onions', 'potatoes'];

var radioState = [false, true, false];

var r = [];

for (var i=0; i<radioNames.length; i++) {

    r = g.add('radiobutton', undefined, radioNames);

    r.value = radioState;

}

w.show();

createRadioButtons.PNG

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

you could try adding the radio button along with the state in your loop

var w = new Window ('dialog', 'Create Radio Buttons');

var g = w.add('group');

var radioNames = ['tomatoes', 'onions', 'potatoes'];

var radioState = [false, true, false];

var r = [];

for (var i=0; i<radioNames.length; i++) {

    r = g.add('radiobutton', undefined, radioNames);

    r.value = radioState;

}

w.show();

createRadioButtons.PNG

Votes

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
Enthusiast ,
Mar 29, 2017 Mar 29, 2017

Copy link to clipboard

Copied

LATEST

Thanks Carlos! I had a bit of trouble at first with scope, as I was using an example that had radios with functions, but I was able to make them global and your instructions worked like a charm. I clearly need a better understanding of the object model since I ask so many novice questions, but appreciate the community always coming through answering and documenting hidden features.

Votes

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