Skip to main content

Posts

Showing posts from November, 2024

Significant Re-write of how Gnocl Handle Commands

offset idx to accommodate point at which options occur  idx = objc no options gnocl::device  idx = 1 no subcommand but with options gnocl::device -option AAA -option AAA...  idx = 2 subcommand with options gnocl::device cmdName -option AAA -option AAA...  idx = 3 gnocl::device cmdName string -option AAA -option AAA...    gnoclParseCommandOptions   /** \brief    Command Template. **/ int gnoclTemplateCmd ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) {     static const char *description = "description";     static GnoclCommand commands[] = {         { "cmdName", "args", "description", "default" },         { NULL }     };     static GnoclOption options[] = {         /* command/widget specfic options */     ...

Remove Stray Repeated Spaces from a String

      #!/bin/sh # the next line restarts using tclsh \ exec tclsh "$0" "$@" package require -exact Gnocl 3.24 set str "\tAbc  def  ghi   klm    a. \tYes!   " ## reduce multiple spaces within a string but retain \t, trim all external spaces. # args: str        string to modify # returns:        updated string # proc removeSpaces { str } {     while 1 {         if { [string first "  " $str] == -1 } { break }         set str [string map [list "  " " "] $str]     }     return [string trim $str " "] } puts >[removeSpaces $str]<