1. Code readability suggestions

If you found you'd written this, what would you change it to?
To be honest, I am not all that sure it looked much better before loss
of syntax colouring and linewrap kicked in...
if id = MF_sm
     or (msg = WM_CHAR and wParam=15) then
-- Ctrl O (Site Manager)
        SiteManager()
    elsif id = MFexit then
        closeWindow(Main)
    elsif id = MV_rfl
     or (msg = WM_CHAR and wParam = 12 and rlOK)
-- Ctrl L (Refresh Local)
     or (id = M_Crfr and msg = WM_COMMAND and M_Context = LOCAL) then
        loadDir(0,lpath,0)
    elsif id = MV_rfr
     or (msg = WM_CHAR and wParam = 18 and rrOK)
-- Ctrl R (Refresh Remote)
     or (id = M_Crfr and msg = WM_COMMAND and M_Context = REMOTE) then
        loadDir(1,rpath,"")
    elsif (id = M_Cdel and msg=WM_COMMAND)
-- Delete
     or (msg = WM_KEYDOWN and wParam = VK_DELETE and
         (id = LVL or id = LVR)) then
        confirmdelete(id)   -- just opens a window
    elsif (id = CDOK and msg = WM_COMMAND) then
        delete()
    elsif (id = CDcncl and msg = WM_COMMAND)
      or (msg = WM_CHAR and wParam = VK_ESCAPE and
          (id = CD or id = CDOK or id = CDcncl)) then
        closeWindow(CD)
    elsif (id = M_Crn and msg=WM_COMMAND)
-- Rename (F2)
     or (msg = WM_KEYDOWN and wParam = VK_F2 and
         (id = LVL or id = LVR)) then
        openRN(id,1)    -- just opens a window
    elsif (id = RNOK and msg = WM_COMMAND)
       or (msg = WM_CHAR and wParam = VK_RETURN and id = RNas) then
        rencd()
    elsif (id = RNcncl and msg = WM_COMMAND)
      or (msg = WM_CHAR and wParam = VK_ESCAPE and
          (id = RN or id = RNas or id=RNOK or id = RNcncl)) then
        closeWindow(RN)


Admittedly, loads of extra whitespace (which I usually treat as the
poor man's answer) does help quite a bit here, anything else?

Regards,
Pete

new topic     » topic index » view message » categorize

2. Re: Code readability suggestions

Pete Lomax wrote:
> 
> If you found you'd written this, what would you change it to?
> To be honest, I am not all that sure it looked much better before loss
> of syntax colouring and linewrap kicked in...
> }}}
<eucode>
>     if id = MF_sm
>      or (msg = WM_CHAR and wParam=15) then
> -- Ctrl O (Site Manager)
>         SiteManager()
>     elsif id = MFexit then
>         closeWindow(Main)
>     elsif id = MV_rfl
>      or (msg = WM_CHAR and wParam = 12 and rlOK)
> -- Ctrl L (Refresh Local)
>      or (id = M_Crfr and msg = WM_COMMAND and M_Context = LOCAL) then
>         loadDir(0,lpath,0)
>     elsif id = MV_rfr
>      or (msg = WM_CHAR and wParam = 18 and rrOK)
> -- Ctrl R (Refresh Remote)
>      or (id = M_Crfr and msg = WM_COMMAND and M_Context = REMOTE) then
>         loadDir(1,rpath,"")
>     elsif (id = M_Cdel and msg=WM_COMMAND)
> -- Delete
>      or (msg = WM_KEYDOWN and wParam = VK_DELETE and
>          (id = LVL or id = LVR)) then
>         confirmdelete(id)   -- just opens a window
>     elsif (id = CDOK and msg = WM_COMMAND) then
>         delete()
>     elsif (id = CDcncl and msg = WM_COMMAND)
>       or (msg = WM_CHAR and wParam = VK_ESCAPE and
>           (id = CD or id = CDOK or id = CDcncl)) then
>         closeWindow(CD)
>     elsif (id = M_Crn and msg=WM_COMMAND)
> -- Rename (F2)
>      or (msg = WM_KEYDOWN and wParam = VK_F2 and
>          (id = LVL or id = LVR)) then
>         openRN(id,1)    -- just opens a window
>     elsif (id = RNOK and msg = WM_COMMAND)
>        or (msg = WM_CHAR and wParam = VK_RETURN and id = RNas) then
>         rencd()
>     elsif (id = RNcncl and msg = WM_COMMAND)
>       or (msg = WM_CHAR and wParam = VK_ESCAPE and
>           (id = RN or id = RNas or id=RNOK or id = RNcncl)) then
>         closeWindow(RN)
> </eucode>
{{{

> 
> Admittedly, loads of extra whitespace (which I usually treat as the
> poor man's answer) does help quite a bit here, anything else?
> 
> Regards,
> Pete
> 
> 
Hi
Whoawhatdoyoumeanwhitespacesarethepoormansanswer.InmyminditjustaddstotheEnglishlikereadabiltyofthecode.
Itmakesmoresencetoputaspacebetweenanythingandan=thenjustthe=.
Thatlooksveryreadabletome.

Chris

http://euallegro.wikispaces.com
http://members.aol.com/chriscrylex/euphoria.htm
http://uboard.proboards32.com/
http://members.aol.com/chriscrylex/EUSQLite/eusql.html

new topic     » goto parent     » topic index » view message » categorize

3. Re: Code readability suggestions

This is why I created a generic event library.
Windows coding really benefits from an event system.

WndProc's are always ugly and unmanagable.

If you are interested, I'll send you a copy.

Chris Bensler
~ The difference between ordinary and extraordinary is that little extra ~
http://empire.iwireweb.com - Empire for Euphoria

new topic     » goto parent     » topic index » view message » categorize

4. Re: Code readability suggestions

Chris Burch wrote:
>Whoawhatdoyoumeanwhitespacesarethepoormansanswer.

W     h     o     a     .          I      o     n   
  l     y      m     e  
   a     n     t          t      o     
o     m     u     c     
h      w     h     i  
   t     e     s     p   
 a     c     e    c    a
      n     g     e
     t     s     i     l  
   l     y.

The above nonsense may (badly) mimic excess whitespace causing
premature linebreaks because code no longer fits on screen widthwise,
far worse excess blank lines prevent visual line-up if a construct no
longer fits on screen heightwise, imo often for no good reason.

Or as my Latin teacher used to say:
In appro pria tespa cescan beve rym
islea  ding.

                  R
              e
           g
        a
      r 
   d      e
 s      t
,     e
   P

PS I suspect what triggered my dislike of what I had written is the
number of times I tested for WM_COMMAND, but I don't think there is an
answer to that.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Code readability suggestions

Pete Lomax wrote:
> 
> Chris Burch wrote:
> >Whoawhatdoyoumeanwhitespacesarethepoormansanswer.
> 
> W     h     o     a     .          I      o     n   
>   l     y      m     e  
>    a     n     t          t      o     
> o     m     u     c     
> h      w     h     i  
>    t     e     s     p   
>  a     c     e    c    a
>       n     g     e
>      t     s     i     l  
>    l     y.
> 

LOL. Nice one.

> The above nonsense may (badly) mimic excess whitespace causing
> premature linebreaks because code no longer fits on screen widthwise,
> far worse excess blank lines prevent visual line-up if a construct no
> longer fits on screen heightwise, imo often for no good reason.
> 
> Or as my Latin teacher used to say:
> In appro pria tespa cescan beve rym
> islea  ding.
> 
>                   R
>               e
>            g
>         a
>       r 
>    d      e
>  s      t
> ,     e
>    P
> 
> PS I suspect what triggered my dislike of what I had written is the
> number of times I tested for WM_COMMAND, but I don't think there is an
> answer to that.
> 
>

new topic     » goto parent     » topic index » view message » categorize

6. Re: Code readability suggestions

On Sat, 2006-11-18 at 04:00 +0000, Pete Lomax wrote:
> 
> 
> If you found you'd written this, what would you change it to?
> To be honest, I am not all that sure it looked much better before loss
> of syntax colouring and linewrap kicked in...
> }}}
<eucode>
>     if id = MF_sm
>      or (msg = WM_CHAR and wParam=15) then
> -- Ctrl O (Site Manager)
>         SiteManager()
>     elsif id = MFexit then
>         closeWindow(Main)
>     elsif id = MV_rfl
>      or (msg = WM_CHAR and wParam = 12 and rlOK)
> -- Ctrl L (Refresh Local)
>      or (id = M_Crfr and msg = WM_COMMAND and M_Context = LOCAL) then
>         loadDir(0,lpath,0)
>     elsif id = MV_rfr
>      or (msg = WM_CHAR and wParam = 18 and rrOK)
> -- Ctrl R (Refresh Remote)
>      or (id = M_Crfr and msg = WM_COMMAND and M_Context = REMOTE) then
>         loadDir(1,rpath,"")
>     elsif (id = M_Cdel and msg=WM_COMMAND)
> -- Delete
>      or (msg = WM_KEYDOWN and wParam = VK_DELETE and
>          (id = LVL or id = LVR)) then
>         confirmdelete(id)   -- just opens a window
>     elsif (id = CDOK and msg = WM_COMMAND) then
>         delete()
>     elsif (id = CDcncl and msg = WM_COMMAND)
>       or (msg = WM_CHAR and wParam = VK_ESCAPE and
>           (id = CD or id = CDOK or id = CDcncl)) then
>         closeWindow(CD)
>     elsif (id = M_Crn and msg=WM_COMMAND)
> -- Rename (F2)
>      or (msg = WM_KEYDOWN and wParam = VK_F2 and
>          (id = LVL or id = LVR)) then
>         openRN(id,1)    -- just opens a window
>     elsif (id = RNOK and msg = WM_COMMAND)
>        or (msg = WM_CHAR and wParam = VK_RETURN and id = RNas) then
>         rencd()
>     elsif (id = RNcncl and msg = WM_COMMAND)
>       or (msg = WM_CHAR and wParam = VK_ESCAPE and
>           (id = RN or id = RNas or id=RNOK or id = RNcncl)) then
>         closeWindow(RN)
> </eucode>
{{{

> 
> Admittedly, loads of extra whitespace (which I usually treat as the
> poor man's answer) does help quite a bit here, anything else?
> 
> Regards,
> Pete

Hello Pete,

I dunno if I fully understand the Q? -R-U- looking for a delimiter??
or perhaps a way to subclass keys??

either of which are pretty easy to implement even for sum-1 who hasn't 
programmed m$-winders in a while...

I also have code for the both already written. If either of these are
of interest let me know dude...
 
-- 
Regards,
Euman

Registered Linux User #380358

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu