User Tools

Site Tools


useful_programs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
useful_programs [2020/01/13 10:17] – [Debug printing] emozolyakuseful_programs [2020/02/21 13:46] – [Debug printing] emozolyak
Line 142: Line 142:
 function DBG(...) function DBG(...)
 local tc = tabToStr local tc = tabToStr
- +  
-local function align2s(s1, s2) -- appends space to smaller string  +function align2s(s1, s2) -- appends space to smaller string  
-    local d, s = (#s1 - #s2), ' '  +    local d, s = (#s1 - #s2), ' ' ; local ad = math.abs(d) 
-    if (d ~= 0) then return (((d > 0) and {s1, s2 .. s:rep(d)}) or ({s1 .. s:rep(math.abs(d)), s2}))+     
 +    if (d ~= 0) then  
 +         
 +        local Lp, Rp = 0, 0 
 +         
 +        if ((ad % 2) == 0) then  
 +            Lp = ad / 2 ; Rp = Lp ; INFO("even parts, L R = " .. Lp .. s .. Rp) 
 +        else  
 +            Lp = math.floor(ad / 2) ; Rp = Lp + 1 ; INFO("not even L R " .. Lp .. s .. s .. Rp) 
 +        end  
 +        return (((d > 0) and {s1, s:rep(Lp) .. s2 .. s:rep(Rp)})  
 +                        or 
 +             ({s:rep(Lp) .. s1 .. s:rep(Rp), s2}))
     else      else 
         return {s1, s2}         return {s1, s2}
Line 154: Line 166:
         local arg_str = tc(arg)         local arg_str = tc(arg)
         local t_s_pos = string.find(arg_str, "|"         local t_s_pos = string.find(arg_str, "|"
-    + 
         if not t_s_pos then          if not t_s_pos then 
             INFO(arg_str)  -- Just printing single line              INFO(arg_str)  -- Just printing single line 
Line 167: Line 179:
                 v_row[#v_row + 1] = tostring(arg[i])                 v_row[#v_row + 1] = tostring(arg[i])
             end              end 
-            + 
             if (#h_row ~= #v_row) then              if (#h_row ~= #v_row) then 
                 ERROR("Inconsistent header and value rows in DBGnew!")                 ERROR("Inconsistent header and value rows in DBGnew!")
 +                INFO("h_row:" .. tc(h_row)) ; INFO("v_row" .. tc("v_row"))
                 return                  return 
             else              else 
Line 180: Line 193:
     end      end 
 end   end  
 + 
 function tabToStr(t)  -- glue all and add spaces, use tostring to protect from nil and bool argument  function tabToStr(t)  -- glue all and add spaces, use tostring to protect from nil and bool argument 
     local s = ""                 local s = ""            
useful_programs.txt · Last modified: 2024/03/19 09:39 by emozolyak

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki