![]() |
|
#1
|
|||
|
|||
Problems returning to main and closing the current boxIm creating a program to display a graph from the values inputted by the user(after various calculations), the thing is i want to be able to return to the original input screen after displaying the graph if the users likes. So basically I need to go back to "main" and close the previous box.
Iv created a button "Refresh" and this causes the box currently open to close but I have no idea how to return to "main". [c] #pragma windows 300000,500000,"cwp_ico.rc" //means dosbox is not displayed #include<stdio.h> #include<math.h> #include<clib.h> #include<windows.h> #include<dbos\graphics.h> #include<stdlib.h> int help_switch=1; float u=0, g, p, s, t, x0=0, y0=0, np=1; int b4=0, b3=0, b2=0, b1=1, x1, x2, x3, x4, y1, y2, y3, y4, w1, w2, w3, w4, xmax=0, xmin=800, ymax=0, ymin=600, hand=0, ctrl, c=0, n=2, col=0, wid=2, Draw(), Random(), Clear(), Refresh(), Close(), x2max, x2min, y2max, y2min; short int x[100],y[100];//array with a maximum of 100 values int main() { { char hlp[]="Will input random values";//text displayed in help bubble winio("%bg%ca[Data Input Screen]&",RGB(100,255,100)); winio("%fn[Arial]%tsEnter in 4 values for the x coordinates: \t%rd\t%rd\t%rd\t%rd\n&",1.2, &x1, &x2, &x3, &x4); winio("Enter in 4 values for the y coordinates: \t%rd\t%rd\t%rd\t%rd\n&",&y1, &y2, &y3, &y4); winio("Enter in 4 values for the weighting: \t%rd\t%rd\t%rd\t%rd\n&",&w1, &w2, &w3, &w4); winio("Enter in the number of points to be on the line:\t\t\t\t\t\t%rd\n&",&n); winio("Please choose a colour:\t\t\t%4`ga%rb[Red]\t\t%rb[Blue]\t\t%rb[Green]\t%rb[Purple]\n\n&",&b1,&b2,&b3,&b4,&b1,&b2,&b3,&b4);//4 radial buttons return boolean answers only one can be "on" char* width[]={"Thin","Medium","Thick",NULL};//drop down menu names// winio("Please Select a Thickness: %`7.3ls&",width,&wid);//drop down menu width 6, 3 selections// winio("\n\n\t\t\t%bc[yellow]%^?bt[ Random ]@%bh&",Random,hlp,&help_switch);//button with help bubble winio("\t%bc[red]%^bt[ Clear ]&",Clear); winio("\t%bc[grey]%^bt[ Draw ]",Draw); np=(float)n;//converts num into a float { do//while statement simply to find min and max values of x,y { p = (pow(1 - u, 3));//=(1-u)(1-u)(1-u),to the power of g = (3 * (pow(1-u,2) * u)); s = (3 * pow((1-u)*u, 2)); t = pow(u, 3); x0 = ((p*w1*x1) + (g*w2*x2) + (s*w3*x3) + (t*w4*x4)) / ((p*w1) + (g*w2) + (s*w3) + (t*w4));// starting x coordinate for the line y0 = ((p*w1*y1) + (g*w2*y2) + (s*w3*y3) + (t*w4*y4)) / ((p*w1) + (g*w2) + (s*w3) + (t*w4));// starting y coordinate for the line if (x0>xmax) {xmax=x0;} else {xmax=xmax;} if (x0<xmin) {xmin=x0;} else {xmin=xmin;} if (y0>ymax) {ymax=y0;} else {ymax=ymax;} if (y0<ymin) {ymin=y0;} else {ymin=ymin;} u=u+(1/(np-1)); c++; } while (c<np);//only continues when the number of times the formula has been pasted is equal to that of the number of points x2max = xmax;//save new values as base values change x2min = xmin; y2max = ymax; y2min = ymin; y1 = y1-ymin+5;//minus' y min so y values start as close to y=0 as possible y2 = y2-ymin+5; y3 = y3-ymin+5; y4 = y4-ymin+5; x1 = x1-xmin+5; x2 = x2-xmin+5; x3 = x3-xmin+5; x4 = x4-xmin+5; u=0;//resets u value c=0; do { p = (pow(1 - u, 3));//=(1-u)(1-u)(1-u),to the power of g = (3 * (pow(1 - u, 2) * u)); s = (3 * pow((1 - u) * u, 2)); t = pow(u, 3); x0 = ((p * w1 * x1) + (g * w2 * x2) + (s * w3 * x3) + (t * w4 * x4)) / ((p * w1) + (g * w2) + (s * w3) + (t * w4));// starting x coordinate for the line y0 = ((p * w1 * y1) + (g * w2 * y2) + (s * w3 * y3) + (t * w4 * y4)) / ((p * w1) + (g * w2) + (s * w3) + (t * w4));// starting y coordinate for the line u=u+(1/(np-1));//calculates the value of u x[c]=x0; y CPP / C++ / C Code:
|
|||
|
#2
|
|||
|
|||
|
Iv decided to gut my program and start pretty much from stratch which should make it easier. But now im getting the error "floating point subscript is not permitted" on lines 37,38 and I have no idea what that means or how to fix it. Im open to any answers, suggestions...
[c] #pragma windows 300000,500000,"cwp_ico.rc" //means dosbox is not displayed #include<stdio.h> #include<math.h> #include<windows.h> #include<dbos\graphics.h> #include<stdlib.h> double u=0, g, p, s, t, np=99; double y0, x0, b4=0, b3=0, b2=0, b1=1, x1=1, x2=1, x3=1, x4=100, y1=1, y2=1, y3=1, y4=100, w1=1, w2=1, w3=1, w4=1, c=0, n=2, col=0, wid=2; short int x[100],y[100];//array with a maximum of 100 values int main() { winio("%bg%ca[Data Input Screen]&",RGB(100,255,100)); winio("%fn[Arial]%tsEnter in 4 values for the x coordinates: \t%rd\t%rd\t%rd\t%rd\n&",1.2, &x1, &x2, &x3, &x4); winio("Enter in 4 values for the y coordinates: \t%rd\t%rd\t%rd\t%rd\n&",&y1, &y2, &y3, &y4); winio("Enter in 4 values for the weighting: \t%rd\t%rd\t%rd\t%rd\n&",&w1, &w2, &w3, &w4); winio("\n\n%gr[grey]&",600,400); polyline(x,y,np,col);//displays a polygon of np points, colour=col, x,y taken from array winio("\n\n%bc[green]%^bt[ Draw ]\n&"); winio("\n\n%bc[gray]%^bt[ Close ]"); } int Draw() { c=0; do { p = (pow(1 - u, 3));//=(1-u)(1-u)(1-u),to the power of g = (3 * (pow(1 - u, 2) * u)); s = (3 * pow((1 - u) * u, 2)); t = pow(u, 3); x0 = ((p * w1 * x1) + (g * w2 * x2) + (s * w3 * x3) + (t * w4 * x4)) / ((p * w1) + (g * w2) + (s * w3) + (t * w4));// starting x coordinate for the line y0 = ((p * w1 * y1) + (g * w2 * y2) + (s * w3 * y3) + (t * w4 * y4)) / ((p * w1) + (g * w2) + (s * w3) + (t * w4));// starting y coordinate for the line u=u+(1/(np-1));//calculates the value of u /*line 37*/ x[c]=x0;//given number on array,c, is equal to that of x0,y0 y CPP / C++ / C Code:
|
|
#3
|
||||
|
||||
|
Hi warny.
I think that you are trying to shove a double into a short. You define x[] as a short and y[] as a short here: CPP / C++ / C Code:
And then you are trying to place a double into it here. [c] /*line 37*/ x[c]=x0;//given number on array,c, is equal to that of x0,y0 y CPP / C++ / C Code:
|
|
#4
|
|||
|
|||
|
Quote:
[c] x[c]=(int)x0; y CPP / C++ / C Code:
I was also wondering if anyone knows how to use: CPP / C++ / C Code:
Last edited by warny_maelstrom : 28-Apr-2004 at 12:41.
|
|
#5
|
||||
|
||||
|
Quote:
__________________
During the election they said Obama could only be elected when pigs fly. Well, we currently have an epidemic of Swine Flu. Coincidence? |
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The