How to toggle between inactive and active radio buttons?

Hi!

I would like to program a GUI in which the user can toggle if a file selector is active or inactive where one of the two radio buttons is choosed.

 

void templateChoiceUpdate(DBE xx)
{
    if(get(templateChoice) == 0)
    {
        inactive exportFileSelect
    }
    else
    {
        active exportFileSelect
    }
}

 

void makeBoxForFolderExport()
{   
    //Do not parent to current module, use excelBox = create(dbExplorer, "String_Export_Excel", styleCentered)
    excelBox = create(dbExplorer, "String_Export_Excel", styleCentered)
    //excelBox = centered LS_("String_Export_Excel", NLSTEMP_("Export Excel"))
    
    //This for-loop is needed for excelTrigger, because trigger-function
    //expects a module in parameter list, but we don't have a module because
    //we will export modules in folder. So we have to "search" ANY module
    Item i
    for i in f do
    {
        currentModule = read(fullName(i), false, true)
        if(currentModule != null)    //If ANY module was found, break.
        {
            break
        }
    }
    
    excelTrigger = trigger(module, close, 10, closeModuleTrig)    //"Schliessen"-functionality of GUI
    
    mainChoice = choice(excelBox, LS_("String__Main_column", NLSTEMP_("'Main' column:")), mainChoices, mainIgnore, 30, false)
    mainView = choice(excelBox, LS_("String__Main_views", NLSTEMP_("'Main' views:")), mainViews, mainIntegrTest_Export, 30, false)
    titleToggle = toggle(excelBox, LS_("String_Include_column_titles", NLSTEMP_("Include column titles")), includeColumnTitles)
    preserveRichTextFormattingToggle = toggle(excelBox, LS_("String_Preserve_rich_text_formatting", NLSTEMP_("Preserve rich text formatting")), preserveRichTextFormatting)
    
    string choices[] = {"Standard spreadsheet", "Another spreadsheet"}
    templateChoice = radioBox(excelBox, "Export to: \n", choices, 0)
    set(templateChoice, templateChoiceUpdate)
    
    exportFileSelect = fileName(excelBox, "c:\\", "*.xl*", "Excel files", true)
    inactive exportFileSelect
   
    apply(excelBox, "Export", doExcel)
    close(excelBox, true, closeDB)
}

 

The problem is in the function templateChoiceUpdate. There I get these action-windows outputs:

-E- DXL: <Line:1202> Falsche Argumente für ==)
-E- DXL: <Line:1202> Falsche Argumente für Funktion (get)
-E- DXL: <Line:1204> Falsche Argumente für Funktion (inactive)
-E- DXL: <Line:1204> Nicht deklarierte Variable (exportFileSelect)
-E- DXL: <Line:1202> Nicht deklarierte Variable (templateChoice)
-E- DXL: <Line:1208> Falsche Argumente für Funktion (active)
-E- DXL: <Line:1208> Nicht deklarierte Variable (exportFileSelect)
-E- DXL: <Line:1202> Falsche Argumente für if)
-E- DXL: <Line:1273> Falsche Argumente für Funktion (set)
-I- DXL: Fertig. Zurückgemeldete Fehler: 9. Zurückgemeldete Warnungen: 0.

 

Can anybody help me?


tobi_mehrl - Tue Oct 06 08:55:08 EDT 2015

Re: How to toggle between inactive and active radio buttons?
sekrbo - Tue Oct 06 09:08:19 EDT 2015

Seems like you have not declared the DBE variables exportFileSelect and templateChoice before you used them in the functions. Just declare them

DBE exportFileSelect, templateChoice

in the beginning of the script.

/sekrbo

Re: How to toggle between inactive and active radio buttons?
Martin_Hunter - Tue Oct 06 09:59:28 EDT 2015

sekrbo - Tue Oct 06 09:08:19 EDT 2015

Seems like you have not declared the DBE variables exportFileSelect and templateChoice before you used them in the functions. Just declare them

DBE exportFileSelect, templateChoice

in the beginning of the script.

/sekrbo

Hi Tobias,

I concur with Kristian, it's always good practice to declare dialog box variables at the beginning of the script.

I suggest you set auto declare off to ensure all variables are declared

add  XFLAGS_ &=~AutoDeclare_ to the start of your script, startup.dxl or a specific file in startupFiles folder

---

Martin

Re: How to toggle between inactive and active radio buttons?
tobi_mehrl - Wed Oct 07 08:12:10 EDT 2015

Hi!

 

Thank you for your answer!

 

As against to your assumption I don't have declared the DBE objects: I have declared them at the beginning of the whole script. But: Do you maybe mean I have to declare this variables at the beginning of the function, in which the DBE objects where must be used?

I have tested the script when I have written the declaration at the beginning of the function in which where the DBE object where used: I got the same failure!

 

Do you know any other approach to solve the problem?

 

Edit: Obviously, the problem is the variable exportFileSelect. I have now tested the function "void templateChoiceUpdate(DBE xx)"

I have changed the function to this:

 

void templateChoiceUpdate(DBE choicer)
{
    //Debug
    print "Updater\n"
    
    if(get(choicer) == 0)
    {
        //Debug
        print "switch inactive\n"
        
        inactive exportFileSelect
    }
    else
    {
        //Debug
        print "switch active\n"
        
        active exportFileSelect
    }
}

 

The calling statement of this function goes like that: templateChoiceUpdate(templateChoice)

 

If I comment out the inactive ... and active ... statements in the if paths I got no failures! At the time I comment in this two statements I got this failure:

-R-E- DXL: <Line:1231> Nicht zugeordnete Variable (exportFileSelect)
Rückverfolgung:
    <Line:1306>
    <Line:1364>
-I- DXL: Ausführung gestoppt

 

Edit2: Now, I have found the mistake. There was a double declaration of this exportFileSelect available.

 

Thanks!

Re: How to toggle between inactive and active radio buttons?
tobi_mehrl - Wed Oct 07 09:25:31 EDT 2015

Now, I have a second question.

 

How can I read the path, which I have chosen with the file selector?