Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QBJS - Fun Facts!
#11
(04-14-2023, 03:04 AM)mnrvovrfc Wrote:
(04-13-2023, 11:48 AM)dbox Wrote:
Code: (Select All)
Dim colors() As _Unsigned Long

colors("brick red") = &HFFC62D42
colors("electric lime") = &HFFCCFF00
colors("metalic sunburst") = &HFF9C7C38

Cls , 15
Line (10, 10)-(100, 100), colors("electric lime"), BF
Line (200, 200)-(300, 300), colors("brick red"), BF
Circle (200, 100), 50, colors("metalic sunburst")

This could be faked as function, and on 64-bit it's faster than any "dictionary" implementation:

Code: (Select All)
FUNCTION colors~& (mycolor$)
    DIM iret AS _UNSIGNED LONG
    IF mycolor$ = "brick red" THEN
        iret = &HFFC62D42
    ELSEIF mycolor$ = "electric lime" THEN
        iret = &HFFCCFF00
    ELSEIF mycolor$ = "metallic sunburst" THEN
        iret = &HFF9C7C38
    ELSE
        iret = 0
    END IF
    colors~& = iret
END FUNCTION

Sure, but the "dictionary" code is way easier to read, and much better for filling the dictionary with values coming from DATA statements or from files.  The data source, as-is, works as documentation.

If speed is critical, then pick the speedy one.  If flexibility and readability are critical, then go for the dictionary.
Reply


Messages In This Thread
QBJS - Fun Facts! - by dbox - 04-10-2023, 08:46 PM
RE: QBJS - Fun Facts! - by mnrvovrfc - 04-10-2023, 09:48 PM
RE: QBJS - Fun Facts! - by Sprezzo - 04-10-2023, 10:23 PM
RE: QBJS - Fun Facts! - by mnrvovrfc - 04-11-2023, 06:11 AM
RE: QBJS - Fun Facts! - by dbox - 04-11-2023, 08:55 PM
RE: QBJS - Fun Facts! - by dbox - 04-11-2023, 09:20 PM
RE: QBJS - Fun Facts! - by vince - 04-11-2023, 10:03 PM
RE: QBJS - Fun Facts! - by dbox - 04-13-2023, 11:48 AM
RE: QBJS - Fun Facts! - by mnrvovrfc - 04-14-2023, 03:04 AM
RE: QBJS - Fun Facts! - by CharlieJV - 04-14-2023, 04:00 AM
RE: QBJS - Fun Facts! - by bplus - 04-13-2023, 01:45 PM
RE: QBJS - Fun Facts! - by SMcNeill - 04-14-2023, 11:38 AM
RE: QBJS - Fun Facts! - by dbox - 04-14-2023, 01:31 PM
RE: QBJS - Fun Facts! - by vince - 04-14-2023, 11:55 AM
RE: QBJS - Fun Facts! - by mnrvovrfc - 04-14-2023, 02:53 PM
RE: QBJS - Fun Facts! - by dbox - 04-14-2023, 03:55 PM
RE: QBJS - Fun Facts! - by dbox - 04-21-2023, 02:04 PM
RE: QBJS - Fun Facts! - by dbox - 01-31-2024, 03:53 PM



Users browsing this thread: 7 Guest(s)