Results 1 to 9 of 9

Thread: help me port this code....

  1. #1
    Guest

    Arrow

    Hi, I need to translate this QBasic code manually into standard DOS C++ (i use DJGPP / RHIDE compiler)...

    Code:
    DIM i AS INTEGER
    DIM level AS SINGLE
    DIM max AS SINGLE
    DIM average AS SINGLE
    DIM population AS INTEGER
    DIM divergence AS INTEGER
    DIM sample AS INTEGER
    DIM capture AS INTEGER
    DIM shift AS INTEGER
    RANDOMIZE TIMER
    CLS
    SCREEN 12
    POP:
    INPUT "Population: ", population
    IF population = 0 THEN GOTO POP
    SAMP:
    INPUT "Number of samples: ", sample
    IF sample = 0 THEN GOTO SAMP
    DIVE:
    INPUT "Divergence: ", divergence
    IF divergence = 0 THEN GOTO DIVE
    DIM mean(1 TO sample) AS SINGLE
    DIM stats(1 TO population) AS SINGLE
    capture = CINT(population / sample)
    shift = CINT(capture / 2)
    CLS
    max = 0
    level = 200
    FOR i = 1 TO population
        level = level + (divergence - ((divergence * 2) * RND))
        stats(i) = level
        IF level > max THEN max = level
        PSET ((640 / population) * i, stats(i)), (100 * (level / max)) MOD 15
        'line of best fit, sampling...
        average = (average + stats(i))
        IF ((i MOD capture) = 0) AND (CINT(i / capture) <= sample) THEN
            mean(CINT(i / capture)) = (average / capture)
            average = 0
        END IF
    NEXT i
    'drawing...
    FOR i = 2 TO sample
        LINE ((640 / population) * (((i - 1) * capture) - (shift)), mean(i - 1))-((640 / population) * (((i * capture) - (shift))), mean(i)), 15
    NEXT i
    The problem is that i don't know the first thing about graphical stuff in C++, can you guys help?

    if you want to try this code out for yourself in Qbasic run it, and type 1000 for the Population, 50 for the samples and 6 for Divergence, you should see a nice graph come up.

    I just need it in C++, thats all. Don't worry about the lack of error trapping, I'll have to sort that out later. Feel free to put some in though, as i don't know how to trap errors either, I'm still new to C++.

    Thanks.

    Adam.



  2. #2
    Guest

    Unhappy Please help!

    C'mon guys, it can't be that hard surely.

    Someone must know how to do this, help a guy out huh?

    I don't beg often y'know

  3. #3
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    Its because

    Its because its kindof a large request and most people don't have enough time on the boards to answer it
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  4. #4
    Guest
    Hope you don't mind me saying, but thats a bit glib.

    You see endless lines of code on some of these posts, that describes far more complex things than simply drawing lines and dots on the screen. Is it too much to ask? Maybe I'll just stick to QBasic, its much faster than C++ anyway, hehehe

  5. #5
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    Well..

    Well usually the long code is a code paste deal. Also barely anyone asks to convert between languages. that can take a long time, especially from basic to C++
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  6. #6
    Guest
    C'mon guys i need a hand here. Look, I'll give you my firstborn if you gimme a hint! :0

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    How old, and is it female?

    (just checking you're not going to give me a 5month old baby )
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8
    Guest
    I don't think that code can be converted to ANSI C++.

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    All except the graphics could go pretty much line for line. The line drawing would need to use VBE or similar. How about MGL from http://www.scitechsoft.com ?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width