Re: Structured Programming: QB IS STRUCTURED!!!

new topic     » goto parent     » topic index » view thread      » older message » newer message

Lynn Kilroy wrote:
> 
> >Hi
> >
> >Ah ha - the goto / gosub/return argument again.
> >
> >Short answer no - look through the mailing list archives for all the pro 
> >and con arguments. Assume there are no subroutines - in the qbasic sense. 
> >When you get used to euphoria, its far prettier and easier to read.
> >
> >As with most things euphoria, there are work arounds
> >
> >functions - return a value
> >procedures - do not return a value
> >
> >both need to to be found in your program (in the way the program is read), 
> >before you actually call them (can use routine_ids, but keep it simple for 
> >now)
> >
> >The 'preferred' method is to only use local variables to your 
> >functions/procedured, as this leads to prettier, more re usable code, eg
> >
> >}}}
<eucode>
> >function foo(integer x)
> >integer y
> >y = x * 2
> >return y
> >end function
> >
> >integer z
> >z = foo(2)
> ></eucode>
{{{

> >
> >now if you used untidy global variables (bad programming practice (hands up 
> >those who NEVER do it))
> >
> >}}}
<eucode>
> >integer y, z
> >
> >procedure foo(integer x)
> >y = x * 2
> >end procedure
> >
> >foo(4)
> >z = y
> ></eucode>
{{{

> >
> >yeuch, horrible.
> >
> >Is this what you meant.
> >
> >Also say goodbye to on x gosub/goto, and switch/case statements (are these 
> >in qbasic?)
> >
> >Chris
> 
> 
> Tried it.  Didn't work.  Now, since you're so smart, mebbe you can tell me 
> if you can find a single goto / gosub / return in this program which is just

Whoa - this is setting the tone.
> 
> full of subroutines.  And by the way, I insist you read through the whole 
> thing.   I have the buggery that prompted this whole mess in the first place
> 
> copied neatly in the code.  Before you ask, yes, it is in the graphics.e 
> file.  I looked.  Yes, the include statement is in the beginning of the 
> file, before the call to the included file's subroutine.  But I get this 
> error.  Mebbe you, who knoweth I do not understandith structured 
> programming, could explain to me what the proper structureth be-ith so I can
> 
> codeth in the correcteth structureth?
> 
> Your ignorance of the structured nature of QB astounds me.  

Why? I haven't used QBASIC for 20 years. So much for trying to help poeple. Why
bother.

The only thing 
> that could possibly astound me more is the fact that QB - written probably 
> close to twenty years ago - parses all the subroutines in to their own 
> little windows, so you can edit them individually without having to search 
> through the code to find them, and Ed does not.  So much for readability.
> 
> Love & Friendship & Blessed Be!

Thats an oxymoron isn't it.


> Lynn Erika Kilroy
> 
> <!-------------------BEGIN QBASIC SOURCE------------------->
> DECLARE SUB ColorLocateInputJustAboutAnything (FGC AS INTEGER, BGC AS 
> INTEGER, CTFGC AS INTEGER, CTBGC AS INTEGER, Row AS INTEGER, Col AS INTEGER,
> 
> Text AS STRING, VWidth AS INTEGER)
> DECLARE SUB ColorLocatePrint (FGC AS INTEGER, BGC AS INTEGER, Row AS 
> INTEGER, Col AS INTEGER, Text AS STRING)
> DECLARE SUB EndProgram ()
> DECLARE SUB Initialize ()
> DECLARE SUB Inkey (a AS STRING)
> DECLARE SUB MasterControlProgram ()
> DECLARE SUB Prekey (a AS STRING)
> DECLARE SUB WaitKey (a AS STRING)
> 
> DIM SHARED LastRow AS INTEGER
> 
> Initialize
> MasterControlProgram
> EndProgram
> 
> SUB ColorLocateInputJustAboutAnything (FGC AS INTEGER, BGC AS INTEGER, CTFGC
> 
> AS INTEGER, CTBGC AS INTEGER, Row AS INTEGER, Col AS INTEGER, Text AS 
> STRING, VWidth AS INTEGER)
> 
> : REM FGC = ForeGroundColor
> : REM BGC = BackGroundColor
> :
> : REM CTFGC = CursorTextForeGroundColor
> : REM CTFGC = CursorTextBackGroundColor
> :
> : REM Row = The Row we Print it on
> : REM Col = The Column we Print It on
> :
> : REM Text = The Text We're Editing.  Yes.  Editing.  What'd you think?  
> This
> : REM        was going to be like INPUT?
> :
> : REM VWidgth = ViewWidth, in Characters.
> :
> DIM CursorPosition AS INTEGER
> :
> DIM VTextStart AS INTEGER
> :
> DIM InputMode AS STRING
> :
> DIM a AS STRING
> 
> CursorPosition = LEN(a) + 1
> VTextStart = CursorPosition - VWidth
> 
> InputMode = "OverWrite"
> 
> WHILE a <> CHR$(13)
> 
>   IF CursorPosition < VTextStart THEN
>    VTextStart = CursorPosition
>   ELSEIF CursorPosition - VWidth > VTextStart THEN
>    VTextStart = CursorPosition - VWidth
>   END IF
> 
>   IF VTextStart < 1 THEN
>    VTextStart = 1
>   END IF
> 
>   ColorLocatePrint FGC, BGC, Row, Col, SPACE$(VWidth)
>   ColorLocatePrint CTFGC, CTBGC, Row, Col + VWidth, MID$(InputMode, 1, 1)
>   :
>   IF LEN(Text) > VWidth THEN
>    ColorLocatePrint FGC, BGC, Row, Col, MID$(Text, VTextStart, VWidth)
>   ELSE
>    ColorLocatePrint FGC, BGC, Row, Col, Text
>   END IF
>   :
>   ColorLocatePrint CTFGC, CTBGC, Row, Col + CursorPosition - VTextStart, 
> MID$(Text + CHR$(176), CursorPosition, 1)
> 
>   WaitKey a
> 
>   IF LEN(a) = 1 THEN
>    :
>    IF a = CHR$(8) THEN
>     :
>     IF CursorPosition > LEN(Text) THEN
>      Text = MID$(Text, 1, CursorPosition - 2)
>     ELSE
>      Text = MID$(Text, 1, CursorPosition - 2) + MID$(Text, CursorPosition,
> 
> LEN(Text) - CursorPostion)
>     END IF
>     :
>     CursorPosition = CursorPosition - 1
>     :
>    ELSEIF a = CHR$(27) THEN
>     :
>     Text = ""
>     CursorPosition = 1
>     :
>    ELSEIF a > CHR$(31) THEN
>     :
>     IF CursorPosition > LEN(Text) THEN
>      Text = Text + a
>     ELSE
>      IF InputMode = "OverWrite" THEN
>       MID$(Text, CursorPosition, 1) = a
>      ELSEIF InputMode = "Insert" THEN
>       Text = MID$(Text, 1, CursorPosition - 1) + a + MID$(Text, 
> CursorPosition, LEN(Text) - CursorPosition)
>      END IF
>     END IF
>     :
>     CursorPosition = CursorPosition + 1
>     :
>    ELSEIF a <> CHR$(13) THEN
>     :
>     BEEP
>     :
>    END IF
<snip>


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 thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu