• Passing a lot of parameters to procedure

    From snosniv@21:1/5 to All on Sun Feb 19 03:15:50 2023
    I have the following code which works fine to generate 10 rows of entries/checkboxes, so I get 50 parameters.

    I have to pass all these params to a procedure, is there a better way than listing ALL 50 in the call/proc?

    Generate code is:-

    ##----------------------------------------------------------------------------- ## Labels & Entry for MultiBlock Rows 1 to 10 ##----------------------------------------------------------------------------- ## Grid placement for all the rows ##----------------------------------------------------------------------------- for {set xxx 0} {$xxx < 10} {incr xxx} {

    label $f4a.lb_TIM_$xxx -text "Time" -font {Arial 8 bold} -background white -foreground black
    label $f4a.lb_SPC_$xxx -text " " -font {Arial 8 bold}
    entry $f4a.enMINS_$xxx -textvar MB_mins_$xxx -width 2 -validate all -vcmd {ValidInt %P}
    entry $f4a.enSECS_$xxx -textvar MB_secs_$xxx -width 2 -validate all -vcmd {ValidInt %P}
    entry $f4a.enPWR_$xxx -textvar MB_power_$xxx -width 3 -validate all -vcmd {ValidInt %P}
    entry $f4a.enCAD_$xxx -textvar MB_cad_$xxx -width 3 -validate all -vcmd {ValidInt %P}
    checkbutton $f4a.cbSEL_$xxx -var MB_sel_$xxx -background white -foreground red


    grid $f4a.lb_TIM_$xxx -row [expr $xxx + 1] -column 0
    grid $f4a.enMINS_$xxx -row [expr $xxx + 1] -column 1
    grid $f4a.lb_SPC_$xxx -row [expr $xxx + 1] -column 2
    grid $f4a.enSECS_$xxx -row [expr $xxx + 1] -column 3
    grid $f4a.enPWR_$xxx -row [expr $xxx + 1] -column 4
    grid $f4a.enCAD_$xxx -row [expr $xxx + 1] -column 5
    grid $f4a.cbSEL_$xxx -row [expr $xxx + 1] -column 6
    }

    Any help much appreciated.
    Kev P.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert Heller@21:1/5 to snosniv on Sun Feb 19 13:23:29 2023
    At Sun, 19 Feb 2023 03:15:50 -0800 (PST) snosniv <[email protected]> wrote:


    I have the following code which works fine to generate 10 rows of entries/checkboxes, so I get 50 parameters.

    I have to pass all these params to a procedure, is there a better way than listing ALL 50 in the call/proc?

    Generate code is:-

    ##-----------------------------------------------------------------------------
    ## Labels & Entry for MultiBlock Rows 1 to 10 ##-----------------------------------------------------------------------------
    ## Grid placement for all the rows ##-----------------------------------------------------------------------------
    for {set xxx 0} {$xxx < 10} {incr xxx} {

    label $f4a.lb_TIM_$xxx -text "Time" -font {Arial 8 bold} -background white -foreground black
    label $f4a.lb_SPC_$xxx -text " " -font {Arial 8 bold}
    entry $f4a.enMINS_$xxx -textvar MB_mins_$xxx -width 2 -validate all -vcmd {ValidInt %P}
    entry $f4a.enSECS_$xxx -textvar MB_secs_$xxx -width 2 -validate all -vcmd {ValidInt %P}
    entry $f4a.enPWR_$xxx -textvar MB_power_$xxx -width 3 -validate all -vcmd {ValidInt %P}
    entry $f4a.enCAD_$xxx -textvar MB_cad_$xxx -width 3 -validate all -vcmd {ValidInt %P}
    checkbutton $f4a.cbSEL_$xxx -var MB_sel_$xxx -background white -foreground red


    grid $f4a.lb_TIM_$xxx -row [expr $xxx + 1] -column 0
    grid $f4a.enMINS_$xxx -row [expr $xxx + 1] -column 1
    grid $f4a.lb_SPC_$xxx -row [expr $xxx + 1] -column 2
    grid $f4a.enSECS_$xxx -row [expr $xxx + 1] -column 3
    grid $f4a.enPWR_$xxx -row [expr $xxx + 1] -column 4
    grid $f4a.enCAD_$xxx -row [expr $xxx + 1] -column 5
    grid $f4a.cbSEL_$xxx -row [expr $xxx + 1] -column 6
    }

    Any help much appreciated.
    Kev P.

    Why did you repost this?

    Rich suggested bundling the parameters into a list or lists or into a matrix.

    I suggested that since the params are all in globals, you don't have to pass them at all, just reference the globals. Alternitivly, you can replace the individual globals with a single global array variable.




    --
    Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
    Deepwoods Software -- Custom Software Services
    http://www.deepsoft.com/ -- Linux Administration Services
    [email protected] -- Webhosting Services

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Robert Heller on Sun Feb 19 14:59:23 2023
    Robert Heller <[email protected]> wrote:
    At Sun, 19 Feb 2023 03:15:50 -0800 (PST) snosniv <[email protected]> wrote:
    I have the following code which works fine to generate 10 rows of
    entries/checkboxes, so I get 50 parameters.
    [many lines of repost elided]

    Why did you repost this?

    I thought the same.

    To the OP: go read our responses on your first post of this duplicate.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From snosniv@21:1/5 to Rich on Sun Feb 19 08:03:21 2023
    On Sunday, 19 February 2023 at 14:59:27 UTC, Rich wrote:
    Robert Heller <[email protected]> wrote:
    At Sun, 19 Feb 2023 03:15:50 -0800 (PST) snosniv <[email protected]> wrote:
    I have the following code which works fine to generate 10 rows of
    entries/checkboxes, so I get 50 parameters.
    [many lines of repost elided]
    Why did you repost this?
    I thought the same.

    To the OP: go read our responses on your first post of this duplicate.

    I found I'd posted on vhdl website & deleted it, but accidently deleted from tcl too,
    sorry for any confusion.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to snosniv on Sun Feb 19 17:59:20 2023
    snosniv <[email protected]> wrote:
    On Sunday, 19 February 2023 at 14:59:27 UTC, Rich wrote:
    Robert Heller <[email protected]> wrote:
    At Sun, 19 Feb 2023 03:15:50 -0800 (PST) snosniv <[email protected]> wrote:
    I have the following code which works fine to generate 10 rows of
    entries/checkboxes, so I get 50 parameters.
    [many lines of repost elided]
    Why did you repost this?
    I thought the same.

    To the OP: go read our responses on your first post of this
    duplicate.

    I found I'd posted on vhdl website & deleted it, but accidently
    deleted from tcl too, sorry for any confusion.

    This is Usenet, you can't delete the post from Usenet once it has been
    posted.

    You might have managed to delete it from google groups, but that is
    just local to google, not to the broader Usenet world.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)