Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help me!
#21
Quote: What mango wrote really helped me....While im at it, thanks mango for posting, it really helped.

You are welcome. Glad to have a new programmer on board...I was afraid you were a kid with an attitude. AFAIKT, this (qbasicnews.com) is the *best* resource on the net for QB proggers. I'm sorry to say, that, after many years of using QB for recreational programming, I'm on my way out...but...It's a pleasure to program DOS in QB compared with the alternatives. I just found the site circa 6 months ago...ironically, just as I was getting ready leave QB 8~{ but I have a feeling...like moneo...I never really will.

Ciao
Reply
#22
Forgive me if someone suggested this before, but your program would look cleaner and operate more efficiently with some SELECT...CASE as a logic statement.

Code:
SELECT CASE variable
CASE 1
    'blah
    'more blah
CASE 2, 4, 6
   'blah blah blah
CASE 9 TO 15
   'blah
   'blah blah
   'blah blah blah
CASE IS < 15, "aaron" to "zxylum"
   'blah blah blah
CASE ELSE
   'bloopity blah blah blah
END SELECT

Also, since you're spaghetti coding different assignments based on value, try this:


Code:
DIM artists (1 to numberofartists)
DIM albums(1 to numberofalbums)

FOR x = 1 to numberofartists
  READ artists(x)
NEXT x

FOR x = 1 to numberofalbums
  READ albums(x)
NEXT x

INPUT "Make a selection", indexvalue
artist$ = artists(indexvalue)
album$ = albums(indexvalue)

DATA "artist", "artist1", "artist2"
DATA "album", "album1", "album2"

It'll make the code itself a whole lot less confusing if you only hardcode what you need to.
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#23
Quote:Forgive me if someone suggested this before

true..actually i found out how to do this, but still thanks for helping.

Quote:I'm on my way out...

i suggest you stay cuz still there are many people out there who use QBASIC and sure..stuff like C++ or even VB may have advanced options,BUT qb is like, the mother of all programming languages. (i could have said father, but somehow, mother sounds better)
well, in the end its your decision so wish you luck in whatever you do!!!
Reply
#24
Quote:...
P.S :uhm..moneo..i think you misunderstood me!
Janesh, Sorry if I got off on the wrong foot with you. It's not that I "misunderstood" you, it's more like I "didn't understand" what you wanted. I'll try harder next time, ok? Big Grin
*****
Reply
#25
Quote:what are you doing that requires so many ifs? There may be an easier way.

That is the very question I often ask myself... And every time, my answer usually helps me make my program coding a LOT more efficient and smooth.
earn.
Reply
#26
I want to give you a little program I made over the past few days to help my transition from CD back to audio casette (car stereo).

"cdtimer.bas"
Code:
DECLARE FUNCTION GetFilesOld$ ()
DECLARE FUNCTION numtrim$ (num AS INTEGER)
DECLARE FUNCTION Get.TapeSize% ()
DECLARE FUNCTION GetFiles$ ()

DEFINT A-Z

SCREEN 0
WIDTH 80, 25

StartProg:

COLOR , 0
CLS
COLOR 15, 1

tapesize% = 0
fulllen% = 0
flipped% = 0
i = 0

tapesize% = Get.TapeSize%

COLOR , 0
CLS
COLOR 15, 1

cdfile$ = GetFiles$

COLOR , 0
CLS

COLOR 2, 0

tapelen% = tapesize% * 60
halftape% = tapelen% / 2
info$ = " " + CHR$(34) + cdfile$ + CHR$(34) + " @ " + numtrim$(tapelen% \ 60) + " minutes long" + " "

LOCATE 1, 40 - (LEN(info$) \ 2)
PRINT info$
PRINT

OPEN "cds.txt" FOR INPUT AS #1

DO
    LINE INPUT #1, lines$
LOOP UNTIL lines$ = "START CD " + cdfile$

DO
    LINE INPUT #1, length$
    IF length$ = "END CD" THEN EXIT DO

    IF LEFT$(length$, 1) <> "'" THEN
        mins% = VAL(MID$(length$, 2, 2))
        secs% = VAL(MID$(length$, 5, 2))

        songlen% = (mins% * 60) + secs%

        fulllen% = fulllen% + songlen%
        IF fulllen% >= halftape% THEN
            IF flipped% = 0 THEN
                COLOR 14, 4
                PRINT "             Flip tape             ": flipped% = 1
            END IF
        END IF

        i = i + 1
        COLOR 14, 0
        PRINT "Song "; numtrim$(i); ": ";
        COLOR 11
        PRINT numtrim$(songlen% \ 60); ":"; numtrim$(songlen% MOD 60);
        LOCATE CSRLIN, 18
        COLOR 14
        PRINT "Tape so far: ";
        COLOR 11
        PRINT numtrim$(fulllen% \ 60); ":"; numtrim$(fulllen% MOD 60)
    END IF
LOOP
CLOSE #1

COLOR 15

PRINT
PRINT "TapeLength: "; numtrim$(fulllen% \ 60); ":"; numtrim$(fulllen% MOD 60)
PRINT

COLOR 10
PRINT "Do Another?"
DO
    key$ = INKEY$
    SELECT CASE LCASE$(key$)
    CASE "y": GOTO StartProg
    CASE "n": SYSTEM
    CASE CHR$(13): GOTO StartProg
    CASE CHR$(27): SYSTEM
    END SELECT
LOOP

DEFSNG A-Z
FUNCTION Get.TapeSize%
    STATIC opt%
    DIM i%

    PRINT "Tape Length:"
    DO
        key$ = INKEY$
        SELECT CASE key$
        CASE CHR$(0) + CHR$(72)
            IF opt% > 0 THEN opt% = opt% - 1 ELSE opt% = 3
        CASE CHR$(0) + CHR$(80)
            IF opt% < 3 THEN opt% = opt% + 1 ELSE opt% = 0
        CASE CHR$(27)
            COLOR 7, 0
            CLS
            END
        END SELECT

        FOR i% = 0 TO 3
            IF opt% = i% THEN COLOR 10, 4 ELSE COLOR 15, 0
            LOCATE i% + 3: PRINT LTRIM$(RTRIM$(STR$((i% + 1) * 30))) + " minutes"
        NEXT i%
    LOOP UNTIL key$ = CHR$(13)

    Get.TapeSize% = (opt% + 1) * 30

    LOCATE 6
END FUNCTION

FUNCTION GetFiles$
    STATIC opt%
    DIM found%, max%, lines$
    REDIM cdfiles(1 TO 100) AS STRING

    OPEN "cds.txt" FOR INPUT AS #1
    DO UNTIL EOF(1)
        LINE INPUT #1, lines$
        IF INSTR(lines$, "START CD") THEN
            cdfiles(max% + 1) = MID$(lines$, 10)
            max% = max% + 1
        END IF
    LOOP
    CLOSE #1

    REDIM PRESERVE cdfiles(1 TO max%) AS STRING

    PRINT "CD Files:"
    DO
        key$ = INKEY$
        SELECT CASE key$
        CASE CHR$(0) + CHR$(72)
            IF opt% > 0 THEN opt% = opt% - 1 ELSE opt% = max% - 1
        CASE CHR$(0) + CHR$(80)
            IF opt% < max% - 1 THEN opt% = opt% + 1 ELSE opt% = 0
        CASE CHR$(27)
            COLOR 7, 0
            CLS
            END
        END SELECT

        FOR i% = 1 TO max%
            IF (opt% + 1) = i% THEN COLOR 10, 4 ELSE COLOR 15, 0
            LOCATE i% + 2: PRINT cdfiles(i%)
        NEXT i%
    LOOP UNTIL key$ = CHR$(13)

    GetFiles$ = cdfiles(opt% + 1)
END FUNCTION

FUNCTION numtrim$ (num AS INTEGER)
    DIM s$
    s$ = LTRIM$(RTRIM$(STR$(num)))
    IF LEN(s$) = 1 THEN s$ = "0" + s$
    numtrim$ = s$
END FUNCTION

"cds.txt"
Code:
START CD Coldplay - Parachutes
    02:16
    04:59
    05:18
    03:47
    04:29
    04:31
    00:45
    04:14
    04:09
    07:14
END CD

START CD Coldplay - A Rush Of Blood To The Head
    05:18
    03:48
    04:57
    05:09
    05:07
    05:28
    03:43
    05:31
    03:58
    05:51
    05:19
END CD

START CD Marylin Manson - Antichrist Superstar
    04:20
    03:40
    04:17
    04:31
    02:45
    02:46
    04:33
    03:58
    05:06
    03:53
    04:54
    05:16
    04:03
    04:46
    05:38
    13:31
END CD

START CD Staind
    03:16
    04:50
    04:36
    04:09
    04:41
    04:05
    04:59
    04:29
    21:01
END CD

START CD System of a Down - Self titled
    02:34
    02:59
    02:35
    02:46
    03:37
    01:44
    03:28
    02:42
    06:18
    04:06
    01:51
    02:44
    03:37
END CD

START CD System of a Down - Toxicity
    03:21
    03:13
    02:54
    02:06
    01:58
    03:30
    01:54
    04:00
    02:56
    02:42
    01:51
    03:39
    03:46
    06:11
END CD

START CD Rage Against the Machine - Renegade
    05:01
    03:18
    03:11
    04:35
    02:35
    04:56
    02:54
    04:04
    05:38
    03:39
    04:42
    06:54
    04:31
    04:30
END CD

START CD Radiohead
    04:18
    04:06
    04:17
    04:50
    03:08
    03:53
    03:54
    04:36
    03:28
    04:07
    03:42
    04:12
END CD
earn.
Reply
#27
No Linkin Park! Sad

But there is system of a down Wink

Nice proggie, btw. But don't you think you could save yourself a few chars by going DECLARE FUNCTION numtrim$ (num%)?
Reply
#28
Quote:No Linkin Park! Sad

But there is system of a down Wink

Nice proggie, btw. But don't you think you could save yourself a few chars by going DECLARE FUNCTION numtrim$ (num%)?

Yeah.

And thanks for the comment Smile
earn.
Reply
#29
Don't mind me with linkin park. I'm sitting here listening to LP midis while working Smile
Reply
#30
Excuse my ignorance, but what is Linkin Park? Is that the correct spelling, LINKIN?
*****
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)