PDA

Click to See Complete Forum and Search --> : help me port this code....


Dec 10th, 2000, 12:26 PM
Hi, I need to translate this QBasic code manually into standard DOS C++ (i use DJGPP / RHIDE compiler)...


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.

Dec 12th, 2000, 12:16 PM
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 :)

Chris_SE
Dec 12th, 2000, 12:20 PM
Its because its kindof a large request and most people don't have enough time on the boards to answer it

Dec 13th, 2000, 12:10 PM
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 :)

Chris_SE
Dec 13th, 2000, 12:43 PM
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++

Dec 20th, 2000, 12:15 PM
C'mon guys i need a hand here. Look, I'll give you my firstborn if you gimme a hint! :0

parksie
Dec 20th, 2000, 01:05 PM
How old, and is it female?

(just checking you're not going to give me a 5month old baby :()

Dec 20th, 2000, 02:28 PM
I don't think that code can be converted to ANSI C++.

parksie
Dec 20th, 2000, 02:34 PM
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 ?