PDA

View Full Version : RadioButton Problem


Teriander
04-09-2008, 11:50 PM
I have a radio button that would add the format type at the end of certain text to create a file output type in my renderer.. Example:"Test.tga" But the radio button text does not show, and I do not get an error message. My code will help explain:

-- creates my radio buttons
radiobuttons rdoFileType labels:#("rpf", "tga", "jpg") default:1

-- tells the button number what text to display.
on rdoFileType changed type do (case state of
(
1: ".rpf"
2: ".tga"
3: ".jpg"
)
)

-- Creates a variable that converts my button info into text.
FileType = rdoFileType.state as string

-- Creates a variable that generates the output file type text.
-- txtSavePath.text and CameraName are other variables that add to the text, they work fine.
saveFile = txtSavePath.text + "\\" + cameraName + "\\" + cameraName + "_" + FileType

-- saves all text in the Output of the renderer.
rendOutputFilename = saveFile

What am I missing? It doesn't show .tga, .rpf, or .jpg at the end :(

Mr-BlueSummers
04-10-2008, 12:38 AM
FileType = rdoFileType.state as string


Should your filetype pulldown change event be an assignment of some kind? Right now you're assigning the FileType variable to rdoFileType.state (which would be a number like "2") as a string. Change the line quoted above to


FileType = rdoFileType.items[rdoFileType.state]


That should yield the string you want. (Can't test it, though. Gotta go!)

erilaz
04-10-2008, 01:21 AM
You don't appear to be assigning the strings to the actual labels in your case statement. I think you need to assign like this:




on rdoFileType changed type do
(
fileType = case state of
(
1: ".rpf"
2: ".tga"
3: ".jpg"
)
)



I haven't got time to test right now, but try that. Check the example code in the help file related to radio buttons.

Teriander
04-10-2008, 02:11 AM
Mr-BlueSummers,

I get an error message when I modify my fileType variable to your settings...

"Unknown property: "items" in RadioControl:rdoFileType"

This is what I have:

group "Final Rendering"
(
radiobuttons rdoFileType labels:#("rpf", "tga", "jpg") default:1
)

on rdoFileType changed type do
(
case state of
(
1: ".rpf"
2: ".tga"
3: ".jpg"
)
)
local fileType = rdoFileType.items[rdoFileType.state]



Erilaz,

I get an error message when I change my code to your settings...

"Unable to convert: undefined to type: String"

If I keep my old variable "fileType = rdoFileType.state as string" Then it works except a number is behind my output file name. Like "test1" not "test.tga"

What am I doing wrong?

Also, I have been using the script help file, I wouldn't have gotten this far without it;) But Im at a roadblock and can't find the solution.

erilaz
04-10-2008, 03:32 AM
Mr-BlueSummers,

I get an error message when I modify my fileType variable to your settings...

"Unknown property: "items" in RadioControl:rdoFileType"

This is what I have:

group "Final Rendering"
(
radiobuttons rdoFileType labels:#("rpf", "tga", "jpg") default:1
)

on rdoFileType changed type do
(
case state of
(
1: ".rpf"
2: ".tga"
3: ".jpg"
)
)
local fileType = rdoFileType.items[rdoFileType.state]



Erilaz,

I get an error message when I change my code to your settings...

"Unable to convert: undefined to type: String"

If I keep my old variable "fileType = rdoFileType.state as string" Then it works except a number is behind my output file name. Like "test1" not "test.tga"

What am I doing wrong?

Also, I have been using the script help file, I wouldn't have gotten this far without it;) But Im at a roadblock and can't find the solution.

Instead of state, maybe try (rdoFileType.state) in the case expression

Teriander
04-10-2008, 03:48 AM
Still no go :( It's driving me crazy because I feel like it should be simple but Im at a lost :cry: Im trying modified version of from the feedback you gave me, but nothing Im doing works. If you need more information, please let me know!

The closest I can get are the numbers listing properly, but I can't get the text like ".rpf" to show up in the number's place...

erilaz
04-10-2008, 04:07 AM
Still no go :( It's driving me crazy because I feel like it should be simple but Im at a lost :cry: Im trying modified version of from the feedback you gave me, but nothing Im doing works. If you need more information, please let me know!

The closest I can get are the numbers listing properly, but I can't get the text like ".rpf" to show up in the number's place...

When I get a moment i'll try to recreate what you're doing. :)

erilaz
04-10-2008, 04:15 AM
Found a moment. :)



(
rollout testCase "Test"
(
radioButtons testRadio Labels:#("test1", "test2", "test3")
on testRadio changed state do
(
fileType = case testRadio.state of
(
1:"test1"
2:"test2"
3:"test3"
)
print fileType
)
)
createDialog testCase
)


I ran this and I get the correct string output.

Teriander
04-10-2008, 04:53 AM
Im home now, I will try this first thing in the morning. I swore I had something like this already, but I will try exactly what you have. Thanks for helping!! :D

Bobo
04-10-2008, 05:01 AM
You don't appear to be assigning the strings to the actual labels in your case statement. I think you need to assign like this:




on rdoFileType changed type do
(
fileType = case state of
(
1: ".rpf"
2: ".tga"
3: ".jpg"
)
)



I haven't got time to test right now, but try that. Check the example code in the help file related to radio buttons.

You had 'type' in the handler but 'state' in the case statement. Use either one twice and it will work. So


on rdoFileType changed type do
(
fileType = case type of
(
1: ".rpf"
2: ".tga"
3: ".jpg"
)
)


or


on rdoFileType changed state do
(
fileType = case state of
(
1: ".rpf"
2: ".tga"
3: ".jpg"
)
)

erilaz
04-10-2008, 05:44 AM
You had 'type' in the handler but 'state' in the case statement. Use either one twice and it will work.


This is what happens when I try to remember code without max in front of me. :D

Mr-BlueSummers
04-10-2008, 05:56 AM
This is what happens when I try to remember code without max in front of me. :D

Ditto. :hmm:

Teriander
04-10-2008, 04:35 PM
My code is still returning a number value :( Here is what I have exactly:


group "Final Rendering"
(
radiobuttons rdoFileType labels:#("rpf", "tga", "jpg") default:1
button butFinal "Setup Final Rendering"
)
on rdoFileType changed state do
(
fileType = case state of
(
1: ".rpf"
2: ".tga"
3: ".jpg"
)
)

on butFinal pressed do
(
FileType = rdoFileType.state as string

-- ignore the txtSavePath.text and cameraName variables, they work fine.
saveFile = txtSavePath.text + "\\" + cameraName + "\\" + cameraName + "_" + fileType
rendOutputFilename = saveFile
)

Pressing the button returns a value of 1, 2, or 3. Not .rpf, tga, or jpg. What am I missing?

Teriander
04-10-2008, 09:11 PM
I create a "Getto" solution for the moment... Since my variable is only getting integer values back from the Radiobuttons, instead of the text like is should be. I created this script for it:

FileType = rdoFileType.state as integer

if Filetype == 1 then
(
Filetype = ".rpf"
)
if Filetype == 2 then
(
Filetype = ".tga"
)
if Filetype == 3 then
(
Filetype = ".jpg"
)

It works now, but this seems like a bad way to code.. Oh well :( Thanks for helping guys!!

labbejason
04-10-2008, 09:35 PM
Here is what I did, and works fine for me.

(
rollout test "TEST"
(
group "Final Rendering"
(
radiobuttons rdoFileType labels:#("rpf", "tga", "jpg") default:1
button butFinal "Setup Final Rendering"
)

on butFinal pressed do
(
fileType = case rdoFileType.state of
(
1: ".rpf"
2: ".tga"
3: ".jpg"
)
print fileType
)
)
createDialog test 500 100
)

Before you were calling state, which was just giving you the current state of the radio button (returning an integer)

Teriander
04-10-2008, 09:57 PM
Labbejason,

It's working now! That was exactly my problem :) Thanks man!

labbejason
04-10-2008, 10:00 PM
Good stuff :D!

CGTalk Moderation
04-10-2008, 10:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.