PDA

View Full Version : Okay, why doesn't this work!!!



Matt
07-23-2004, 08:11 AM
I've written a script that renames selected polygon's surface names; uniquely.

You can specify a basename, separator and the script adds the number on the end; based on how many polys were selected (if you selected 30 polys, it would index: 01, 02, 03 etc. If you selected 100 polys it would index: 001, 002, 003 etc - so they appear in order in the surface editor).

However, what I can't get to work is the ctlrefresh function to update a text gadget to show a preview of what the string will look like (e.g. surface_name_001)

My code looks like (just showing relevant parts):




gad_basename = ctlstring("Base Name", basename);
ctlposition(gad_basename,xoffset+20, yoffset,width - 20,height);

. . .

gad_preview = ctlstring("Preview", samplename);
ctlposition(gad_preview,xoffset + 37, (yoffset * 3) + (smallgap * 2) ,width - 37,height);

. . .

ctlrefresh( gad_basename, "refreshpreviewname" );

. . .


refreshpreviewname: value
{

trailing_zeros_string = "";
for( innerloop = 1; innerloop <= suffix_string_length - 1; innerloop ++ )
{
trailing_zeros_string = trailing_zeros_string +"0";
}

previewstring = basename + suffixseparator + trailing_zeros_string + "1";

setvalue( gad_preview, previewstring );
}



It refreshes the first time, but never after that, any ideas?

Cheers
Matt

Blypht
07-23-2004, 05:02 PM
My first suspicion is that you need to include

requpdate();

after you set the new value.

If that doesn't work, you're probably hosed. There are occasions when I find the inflexibility of LScript controls to be quite annoying.

Best!

faulknermano
07-24-2004, 03:19 AM
gad_preview;


generic
{
reqbegin("Test");

gad_basename = ctlstring("Base Name", "hello");


gad_preview = ctlstring("Preview", " ");

ctlrefresh( gad_basename, "refreshpreviewname" );

reqpost();

reqend();

}

refreshpreviewname: value
{


setvalue( gad_preview, value);
}



this works. first make sure that the setvalue is indeed changing the variable. next, make sure the the value in setvalue() is the one you want. the string processing might be wrong, for example.