Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coding Efficiency
#5
I still work with INKEY$, so Steve and I share the same idea of using SELECT CASE in a multi-conditional manner when it comes to efficiency. For instance, INKEY$ returns one or two bit string lengths, so I'll set up my SELECT CASE as a nested routine where I first select if the key pressed is one or two bits in length, and then I make two nested cases to get the key code.

Example:

Code: (Select All)
Do
    _Limit 30
    b$ = InKey$
    Select Case Len(b$)
        Case 1
            Select Case b$
                Case "a"
                    Print b$
                Case Chr$(27)
                    System
            End Select
        Case 2
            Select Case Mid$(b$, 2, 1)
                Case ";"
                    Print "F1"
            End Select
    End Select
Loop

For word processing, and other office related apps, I find QB64 to be plenty fast without being overly concerned with efficiency. However, if you intend on using graphics, changing font sizes, links, colors, etc. well then you are either checking character by character for attributes or at least groupings. This can slow things down a bit too much, but the efficient work around is to use string editing rather than constantly creating and replacing strings. In other words, add to the middle of an existing string. Now the strings don't have to be DEFINED as fixed length strings to accomplish this. I just create a string like a$ and then do something like a$ = STRING$(100, CHR$(0)). Now we have a 100-character non-fixed string and we can manipulate it by adding whatever we need into that string like mid$(a$, 1, 17) = "Steve is Amazing!" Oh dammit, I've been coming here so long that now I'm brainwashed, too!

Anyway, (watch Steve quote this post before I come to my senses and edit it...) Other things I like to do are what Terry described, including using defining variables to use less memory such as bits and integers.

Oh, I also like to make sure, as best I can, the program flow is broken up in parts so certain routines, that don't need the 100 or so lines that are coming and won't get sucked into any of those conditions, get directly routed to the part of the program they are needed in. Using EXIT in LOOPs or even _CONTINUE are two examples other than how the program flow is designed in the first place.

Neat topic! +1

Pete
Fake News + Phony Politicians = Real Problems

Reply


Messages In This Thread
Coding Efficiency - by SMcNeill - 08-11-2024, 12:16 AM
RE: Coding Efficiency - by TerryRitchie - 08-11-2024, 01:21 AM
RE: Coding Efficiency - by SMcNeill - 08-11-2024, 03:25 AM
RE: Coding Efficiency - by CharlieJV - 08-11-2024, 01:29 AM
RE: Coding Efficiency - by Pete - 08-11-2024, 07:22 PM
RE: Coding Efficiency - by Dimster - 08-12-2024, 06:34 PM
RE: Coding Efficiency - by Pete - 08-13-2024, 09:46 PM
RE: Coding Efficiency - by SMcNeill - 08-13-2024, 11:11 PM
RE: Coding Efficiency - by Pete - 08-13-2024, 11:23 PM
RE: Coding Efficiency - by SMcNeill - 08-13-2024, 11:28 PM
RE: Coding Efficiency - by TerryRitchie - 08-14-2024, 01:21 AM
RE: Coding Efficiency - by Pete - 08-13-2024, 11:53 PM
RE: Coding Efficiency - by Pete - 08-14-2024, 03:38 PM
RE: Coding Efficiency - by SMcNeill - 08-14-2024, 04:26 PM
RE: Coding Efficiency - by mdijkens - 08-15-2024, 11:29 AM
RE: Coding Efficiency - by Pete - 08-15-2024, 03:20 PM
RE: Coding Efficiency - by Kernelpanic - 08-15-2024, 05:57 PM
RE: Coding Efficiency - by justsomeguy - 08-15-2024, 06:06 PM
RE: Coding Efficiency - by TerryRitchie - 08-16-2024, 03:21 AM
RE: Coding Efficiency - by justsomeguy - 08-16-2024, 07:09 AM
RE: Coding Efficiency - by Pete - 08-15-2024, 11:14 PM
RE: Coding Efficiency - by dano - 08-16-2024, 12:33 AM
RE: Coding Efficiency - by Pete - 08-16-2024, 12:35 AM
RE: Coding Efficiency - by SMcNeill - 09-11-2024, 01:55 AM
RE: Coding Efficiency - by Pete - 09-11-2024, 06:45 AM
RE: Coding Efficiency - by SMcNeill - 09-11-2024, 07:59 AM
RE: Coding Efficiency - by bplus - 09-11-2024, 01:51 PM
RE: Coding Efficiency - by SMcNeill - 09-11-2024, 02:01 PM
RE: Coding Efficiency - by bplus - 09-11-2024, 02:39 PM
RE: Coding Efficiency - by Pete - 09-11-2024, 02:48 PM
RE: Coding Efficiency - by dano - 09-12-2024, 01:41 PM
RE: Coding Efficiency - by Jack - 09-12-2024, 04:01 PM
RE: Coding Efficiency - by Kernelpanic - 09-12-2024, 08:13 PM
RE: Coding Efficiency - by Pete - 09-13-2024, 06:56 PM



Users browsing this thread: 24 Guest(s)