Squares

General FreeBASIC programming questions.
dodicat
Posts: 6390
Joined: Jan 10, 2006 20:30
Location: Scotland

Postby dodicat » Oct 28, 2011 23:03

Hi Rollie~

When things are looking too rosy, keep a weather eye out, and look for impending gloom.

But I hope you don't find any.

You might have to go back to the old gas station for a nightshift job, to help your funding.

During part of my course, years ago, I got a job as a taxi driver in Stirling.

Sometimes I drove right through the night, picked up at the seedy honky tonks, drove the avenues and alleyways of that old town, came to know every cobble in the back wynds, came to rather like the black of a Winter night in my Fiat Mirafiori.
Richard
Posts: 2999
Joined: Jan 15, 2007 20:44
Location: Australia

Postby Richard » Oct 29, 2011 5:32

@Rolliebollocks, @dodicat & @Albert.
I have never doubted your abilities.
You all seem to be having lots of productive fun while re-dimensioning your FreeBASIC horizons.

I've been dragged backwards into a couple of black holes so it is very busy here just now. I'm writing lots of FB code but as expected, the code can't escape the event horizon. I write nicely structured code just inside the event horizon, then the black hole stretches it until it looks like spaghetti. Well that's my excuse for the style.

Meanwhile I cruise around the forum during my tea breaks, reading almost every word written on the pretext of searching out spam. Being busy certainly breaks the monotony.
dafhi
Posts: 1335
Joined: Jun 04, 2005 9:51

Postby dafhi » Oct 29, 2011 9:06

@Richard

Fun read. It feels about the same for me. Probably not as in-depth and well-thought out as what you've got, but stuff I'm proud of nonetheless.
albert
Posts: 5635
Joined: Sep 28, 2006 2:41
Location: California, USA

Postby albert » Oct 29, 2011 20:39

@Richard

Heres the earth going into a time-warp.

Code: Select all


dim as integer xres,yres
screen 19
screeninfo xres,yres
screenres xres,yres

dim as double c1,c2,s1,s2
dim as double x1,x2,y1,y2
dim as double rad=atn(1)/45
dim as double xctr,yctr,radius=150
dim as double deg1,deg2,span

xctr=xres/2
yctr=yres/2

for deg1 = 0 to 360 step 1
   
    c1=cos(deg1*rad)
    s1=sin(deg1*rad)
   
    for deg2 = 0 to 360 step 3
       
        c2 = cos(deg2*rad)
        s2 = sin(deg2*rad)
       
        x1=radius*c1*c1*s1*log(deg2*s1*s1*s1*rad*rad)/log(s2*s2*s2*c1*s1*deg2/c2/s1*rad)/1.5
        x2=radius*c2+tan(s1-s2)/50/50*tan(deg1*deg2*rad*c2*c1/rad)
       
        y1=radius*s1*c1*s1+((c2+s2)/(c1+s1))
        y2=radius*s2*1.5       
       
        pset(xctr+x1+x2,yctr+y1+y2),9
       
    next
next

sleep



I havent yet come up with a formula for a Black-Hole.
albert
Posts: 5635
Joined: Sep 28, 2006 2:41
Location: California, USA

Postby albert » Oct 29, 2011 21:13

I think I got a sort of Black-Hole.

Code: Select all

dim as integer xres,yres
screen 19
screeninfo xres,yres
screenres xres,yres

dim as double c1,c2,s1,s2
dim as double x1,x2,y1,y2

dim as double rad=atn(1)/45

dim as double xctr,yctr,radius=150
dim as double deg1,deg2,span

xctr=xres/2
yctr=yres/1.5

for deg1 = 0 to 360 step 1
   
    c1=cos(deg1*rad)
    s1=sin(deg1*rad)
   
    x1=radius*c1*c1*log(s1)*2
    y1=radius*s1*c1*log(c1)*7
       
    for deg2 = 0 to 360 step 1
       
        c2 = cos(deg2*rad)
        s2 = sin(deg2*rad)
       
        x2=radius*c2*log(c1)/atn(c1*deg1)/2
       
        y2=radius*s2*log(c1)/atn(c1*deg1)/10
       
        pset(xctr+x1+x2,yctr+y1+y2),deg1
       
    next

next

sleep

fxm
Posts: 9559
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Postby fxm » Oct 29, 2011 22:00

It is better then:

Code: Select all

dim as integer xres,yres
'screen 19
screeninfo xres,yres
screenres xres,yres, , , 1

dim as double c1,c2,s1,s2
dim as double x1,x2,y1,y2

dim as double rad=atn(1)/45

dim as double xctr,yctr,radius=150
dim as double deg1,deg2,span

xctr=xres/2
yctr=yres/1.5

for deg1 = 0 to 360 step 1
   
    c1=cos(deg1*rad)
    s1=sin(deg1*rad)
   
    x1=radius*c1*c1*log(s1)*2
    y1=radius*s1*c1*log(c1)*7
       
    for deg2 = 0 to 360 step 1
       
        c2 = cos(deg2*rad)
        s2 = sin(deg2*rad)
       
        x2=radius*c2*log(c1)/atn(c1*deg1)/2
       
        y2=radius*s2*log(c1)/atn(c1*deg1)/10
       
        pset(xctr+x1+x2,yctr+y1+y2),deg1
       
    next

next

sleep
rolliebollocks
Posts: 2655
Joined: Aug 28, 2008 10:54
Location: new york

Postby rolliebollocks » Oct 29, 2011 22:11

@Albert

I think it's a worm hole..

Code: Select all

dim as integer xres,yres
screen 19
screeninfo xres,yres
screenres xres,yres

dim as double c1,c2,s1,s2
dim as double x1,x2,y1,y2

dim as double rad=atn(1)/45

dim as double xctr,yctr,radius=150
dim as double deg1,deg2,span

xctr=xres/2
yctr=yres/1.15

dim as integer cnt=0, switch

Do
   
    cls
   
    screenlock

    for deg1 = 0 to 360 step 1
   
        c1=cos(deg1*rad)
        s1=sin(deg1*rad)
   
        x1=radius*c1*c1*log(s1)*2
        y1=radius*s1*c1*log(c1)*7
       
        for deg2 = 0 to 360 step 1
       
            c2 = cos(deg2*rad)
            s2 = sin(deg2*rad)
       
            x2=radius*c2*log(c1)/atn(c1*deg1)/2
       
            y2=radius*s2*log(c1)/atn(c1*deg1)/100
       
            pset(xctr+x1+x2,yctr+y1+y2*cnt),deg1
       
        next

    next
   
    screenunlock
   
    sleep 1,1
   
    cnt+=switch
    if cnt > 260 then switch=-1
    if cnt < 1 then switch = 1
loop until len(inkey)


albert
Posts: 5635
Joined: Sep 28, 2006 2:41
Location: California, USA

Postby albert » Oct 29, 2011 22:55

COOL ROLLIE!!!

another doodle, I couldn't get to look like i wanted so i made it flashy..

Code: Select all

Dim As Integer xres,yres
Screen 19
screeninfo xres,yres
screenres xres,yres

dim as double c1,c2,s1,s2, rad = Atn(1)/45
dim as double x1,x2,y1,y2
dim as double deg1,deg2

Dim As Double xctr,yctr,radius

xctr = xres/2
yctr = yres/2
radius=300

For deg1 = 0 To 360 Step 2
   
    c1=Cos(deg1*rad)
    s1=Sin(deg1*rad)
   
    for deg2=0 to 360 step .5
       
        c2=cos(deg2*rad)
        s2=sin(deg2*rad)
           
        x1=radius*c1/s1*c2/10
        x2=radius*c2*c1*log(c2*c2)
       
        y1=radius*s1/c1*s2/10
        y2=radius*s2*s1*log(s2*s2)
       
        Pset(xctr+x1+x2,yctr+y1+y2),(deg1 mod 16) * (deg1 mod 16) +deg1
       
    Next
next
   
Sleep

albert
Posts: 5635
Joined: Sep 28, 2006 2:41
Location: California, USA

Postby albert » Oct 30, 2011 0:18

I started going over some of my old ones and fine-tuning them.

This is a morphing Diamond to Square.

Code: Select all

Dim As Integer xres,yres
Screen 19
screeninfo xres,yres
screenres xres,yres

dim as double c,s
dim as double x1,y1,x2,y2
dim as double radius,rad = Atn(1)/45

Dim As integer xctr,yctr

Dim As Double modify_x , modify_y , value1=0 , value2=2000
Dim As Integer toggle=0

xctr = xres/2
yctr = yres/2
radius=75

Do

    If toggle = 0 Then
        value1+=1
        value2-=1
    End If
    If toggle = 1 Then
        value1-=1
        value2+=1
    End If
   
    If value1>3200 Then toggle=1 Else If value1< 400 Then toggle=0
   
    Cls
   
    For deg As Integer = 0 To 360 Step 5
   
        x2=x1
        y2=y1
   
        c=Cos(deg*rad)
        s=Sin(deg*rad)
   
        modify_x = (value1/180-(180-deg)) * ((180-deg)/value1) * (.00001/value1)
        modify_y = (value2/180-(180-deg)) * ((180-deg)/value2) * (.00001/value2)
   
        x1=radius*(c+ modify_x)+(c*value2/15)*s*s*s*s
        y1=radius*(s+ modify_y)+(s*value2/15)*c*c*c*c
   
        line(xctr+x2*2,yctr+y2*2)-(xctr+x1*2,yctr+y1*2),9
        line(xctr,yctr)-(xctr+x1*1.5,yctr+y1*1.5),9
       
    Next
   
    Sleep 1
   
Loop Until inkey<>""

Sleep
END


albert
Posts: 5635
Joined: Sep 28, 2006 2:41
Location: California, USA

Postby albert » Oct 30, 2011 8:07

I've been looking for a way to allow user input of math functions.

I need a token / formula parser.

I found a GWBASIC clone with some new stuff added in called BLASSIC

http://www.blassic.org

It allows you to add code from a file into the running program like the old Microsoft GWBASIC.
You have to down the older version or docs to get docs the latest version docs are largely undocumented.

Heres what i wanted it to look like in FB

Code: Select all

'===============================================================================
'===============================================================================
'Trigonometry-Designer Version 1  AUG/2011
'
'By: Albert Redditt
'Contact: albert_redditt@yahoo.com
'
'Written in FreeBasic for windows: http://freebasic.net
'===============================================================================
'===============================================================================
#define WIN_INCLUDEALL
#Include "windows.bi"
#include "fbeval.bi"

declare sub Parser()

'===============================================================================
'===============================================================================
'===============================================================================
'===============================================================================
dim as string helptxt1
dim as string helptxt2
helptxt1 = "Enter the values for degree start."        + chr(13)+chr(10)
helptxt1+= "Enter the values for degree end.  "        + chr(13)+chr(10)
helptxt1+= "Enter the values for degree incrementing." + chr(13)+chr(10)
helptxt1+= "Enter radius value  (1 to ???)."           + chr(13)+chr(10)
helptxt1+= "Enter radians value (atn(1)/??)."          + chr(13)+chr(10)
helptxt1+= "Enter formula for x1 , x2 and y1 , y2."    + chr(13)+chr(10)
helptxt1+= "Internal values:    [__SCROLL DOWNWARD__]."+ chr(13)+chr(10)
helptxt1+=                                               chr(13)+chr(10)
helptxt1+= "d1   = degree  1"                          + chr(13)+chr(10)
helptxt1+= "d2   = degree  2"                          + chr(13)+chr(10)
helptxt1+=                                               chr(13)+chr(10)
helptxt1+= "r1   = radians 1"                          + chr(13)+chr(10)
helptxt1+= "r2   = radians 2"                          + chr(13)+chr(10)
helptxt1+=                                               chr(13)+chr(10)
helptxt1+= "c1   = cosine  1"                          + chr(13)+chr(10)
helptxt1+= "c2   = cosine  2"                          + chr(13)+chr(10)
helptxt1+=                                               chr(13)+chr(10)
helptxt1+= "s1   = sine    1"                          + chr(13)+chr(10)
helptxt1+= "s2   = sine    2"                          + chr(13)+chr(10)
helptxt1+=                                               chr(13)+chr(10)
helptxt1+= "Trigonometry-Designer Version 1  AUG/2011" + chr(13)+chr(10)
helptxt1+= "By: Albert Redditt                       " + chr(13)+chr(10)
helptxt1+= "Contact: albert_redditt@yahoo.com        " + chr(13)+chr(10)
helptxt1+=                                               chr(13)+chr(10)
helptxt1+= "Written in FreeBasic for windows"          + chr(13)+chr(10)
helptxt1+= "http://www.freebasic.net"                  + chr(13)+chr(10)
helptxt1+=                                               chr(13)+chr(10)
helptxt1+= "'--------------------------------------------------   ' " + chr(13)+chr(10)
helptxt1+= " '                                                    ' " + chr(13)+chr(10)
helptxt1+= " '  Title   :  Simple Expression Evaluator            ' " + chr(13)+chr(10)
helptxt1+= " '  Version :  1.1                                    ' " + chr(13)+chr(10)
helptxt1+= " '  Author  :  Aleksandar Ruzicic (admin@krcko.net)   ' " + chr(13)+chr(10) 
helptxt1+= " '  File    :  fbeval.bas                             ' " + chr(13)+chr(10)
helptxt1+= " '                                                    ' " + chr(13)+chr(10)
helptxt1+= " '                                                    ' " + chr(13)+chr(10)
helptxt1+= " ' BIG thanks goes to Jack W. Crenshaw for his        ' " + chr(13)+chr(10)
helptxt1+= " ' 'LET'S BUILD A COMPILER!' text series.             ' " + chr(13)+chr(10)
helptxt1+= " '                                                    ' " + chr(13)+chr(10)
helptxt1+= " ' You're free to use this in any way you find it     ' " + chr(13)+chr(10)
helptxt1+= " ' useful, just 'give credit where credit is due':)   ' " + chr(13)+chr(10)
helptxt1+= " '                                                    ' " + chr(13)+chr(10)
helptxt1+= " ' -------------------------------------------------- ' " + chr(13)+chr(10)
helptxt1+= " ' Version 1.2 : Modified for FBMath by Jean Debord   ' " + chr(13)+chr(10)
helptxt1+= " ' -------------------------------------------------- ' " + chr(13)+chr(10)
'===============================================================================
'===============================================================================


'===============================================================================
'===============================================================================
helptxt2 = "EXAMPLE 1: [Moses's Staff]"                + chr(13)+chr(10)
helptxt2+=                                                                            chr(13)+chr(10)
helptxt2+= "rad1 = atn(1) / 45    (one degree) "                                    + chr(13)+chr(10)
helptxt2+= "rad2 = atn(1) / 45    (one degrees)"                                    + chr(13)+chr(10)
helptxt2+=                                                                            chr(13)+chr(10)
helptxt2+= "x1=r1   * c1"                                                           + chr(13)+chr(10)
helptxt2+= "x2=r2   * c1*cos(cos(d2*r1)*s2/c1)*cos(d2*r1*(c1*c2)/s1)/s1*c2"         + chr(13)+chr(10)
helptxt2+=                                                                            chr(13)+chr(10)
helptxt2+= "y1=r1   * s1"                                                           + chr(13)+chr(10)
helptxt2+= "y2=r2   * s1*sin(sin(d2*r1)*c2/s1)*sin(d2*r1*(s1*s2)/c1)/c1*s2"         + chr(13)+chr(10)
helptxt2+=                                                                            chr(13)+chr(10)
helptxt2+=                                                                            chr(13)+chr(10)
helptxt2+= "EXAMPLE 2: [Galactic Chicken]."            + chr(13)+chr(10)
helptxt2+=                                                                            chr(13)+chr(10)
helptxt2+= "atn(1) / 45   (one degree) "                                            + chr(13)+chr(10)
helptxt2+= "atn(1) / 22.5 (two degrees)"                                            + chr(13)+chr(10)
helptxt2+=                                                                            chr(13)+chr(10)
helptxt2+= "x1=r1 * c1"                                                             + chr(13)+chr(10)
helptxt2+= "x2=r2 * s2*log(d2*r1*s2)*atn(d2*r1*s2/s1)*atn(d2*r2*c1*s1*c2)*sin(d2/(s1*c1*s1*c1)*r1*r1)" + chr(13)+chr(10)
helptxt2+=                                                                            chr(13)+chr(10)
helptxt2+= "y1=r1 * s1"                                                             + chr(13)+chr(10)
helptxt2+= "y2=r2 * c2*log(d2*r1*c2)*atn(d2*r1*c2/c1)*atn(d2*r2*c1*s1*c2)*sin(d2/(s1*c1*s1*c1)*r1*r1)" + chr(13)+chr(10)
'===============================================================================
'===============================================================================

Dim As MSG msg
Dim shared As HWND hWnd, degree1_S , degree1_E , step1 , radians1 _
                       , degree2_S , degree2_E , step2 , radians2 _
                       , Deg1_S    , Deg1_E    , Stp1  , Radi1    _
                       , Deg2_S    , Deg2_E    , Stp2  , Radi2    _
                       , x_1 , x_2 , formula_x1, formula_x2 , radius1 , radius_1 _
                       , y_1 , y_2 , formula_y1, formula_y2 , radius2 , radius_2 _
                       , plotF, saveF , saveD, loadF, help_text1 , help_text2

' Create window
hWnd = CreateWindowEx( 0, "#32770", "Trigonometry-Designer_V1 8/2011 FreeBasic for windows.", WS_OVERLAPPEDWINDOW Or WS_VISIBLE, 100, 100, 640, 550, 0, 0, 0, 0 )

' Create top buttons and edits
degree1_S = CreateWindowEx( 0, "EDIT", "degree 1 start" , WS_VISIBLE Or WS_CHILD or WS_BORDER or ES_READONLY, 10, 10 ,100, 20, hWnd, 0, 0, 0 )
degree1_E = CreateWindowEx( 0, "EDIT", "degree 1 end"   , WS_VISIBLE Or WS_CHILD or WS_BORDER or ES_READONLY, 10, 40 ,100, 20, hWnd, 0, 0, 0 )
step1     = CreateWindowEx( 0, "EDIT", "step 1"         , WS_VISIBLE Or WS_CHILD or WS_BORDER or ES_READONLY, 10, 70 ,100, 20, hWnd, 0, 0, 0 )
radius1   = CreateWindowEx( 0, "EDIT", "radius 1"       , WS_VISIBLE Or WS_CHILD or WS_BORDER or ES_READONLY, 10,100 ,100, 20, hWnd, 0, 0, 0 )
radians1  = CreateWindowEx( 0, "EDIT", "atn(1)/??"      , WS_VISIBLE Or WS_CHILD or WS_BORDER or ES_READONLY, 10,130 ,100, 20, hWnd, 0, 0, 0 )
deg1_S    = CreateWindowEx( 0, "EDIT", ""               , WS_VISIBLE Or WS_CHILD or WS_BORDER               ,115, 10 ,100, 20, hWnd, 0, 0, 0 )
deg1_E    = CreateWindowEx( 0, "EDIT", ""               , WS_VISIBLE Or WS_CHILD or WS_BORDER               ,115, 40 ,100, 20, hWnd, 0, 0, 0 )
stp1      = CreateWindowEx( 0, "EDIT", ""               , WS_VISIBLE Or WS_CHILD or WS_BORDER               ,115, 70 ,100, 20, hWnd, 0, 0, 0 )
radi1     = CreateWindowEx( 0, "EDIT", ""               , WS_VISIBLE Or WS_CHILD or WS_BORDER               ,115,100 ,100, 20, hWnd, 0, 0, 0 )
radius_1  = CreateWindowEx( 0, "EDIT", ""               , WS_VISIBLE Or WS_CHILD or WS_BORDER               ,115,130 ,100, 20, hWnd, 0, 0, 0 )
x_1       = CreateWindowEx( 0, "EDIT", "x1=r1 *"        , WS_VISIBLE Or WS_CHILD or WS_BORDER or ES_READONLY, 10,160 ,100, 20, hWnd, 0, 0, 0 )
formula_x1= CreateWindowEx( 0, "EDIT", ""               , WS_VISIBLE Or WS_CHILD or WS_BORDER               ,115,160 ,490, 20, hWnd, 0, 0, 0 )
x_2       = CreateWindowEx( 0, "EDIT", "x2=r2 *"        , WS_VISIBLE Or WS_CHILD or WS_BORDER or ES_READONLY, 10,190 ,100, 20, hWnd, 0, 0, 0 )
formula_x2= CreateWindowEx( 0, "EDIT", ""               , WS_VISIBLE Or WS_CHILD or WS_BORDER               ,115,190 ,490, 20, hWnd, 0, 0, 0 )

' Create bottom buttons and edits
degree2_S = CreateWindowEx( 0, "EDIT", "degree 2 start" , WS_VISIBLE Or WS_CHILD or WS_BORDER or ES_READONLY, 10,230 ,100, 20, hWnd, 0, 0, 0 )
degree2_E = CreateWindowEx( 0, "EDIT", "degree 2 end"   , WS_VISIBLE Or WS_CHILD or WS_BORDER or ES_READONLY, 10,260 ,100, 20, hWnd, 0, 0, 0 )
step2     = CreateWindowEx( 0, "EDIT", "step 2"         , WS_VISIBLE Or WS_CHILD or WS_BORDER or ES_READONLY, 10,290 ,100, 20, hWnd, 0, 0, 0 )
radius2   = CreateWindowEx( 0, "EDIT", "radius 2"       , WS_VISIBLE Or WS_CHILD or WS_BORDER or ES_READONLY, 10,320 ,100, 20, hWnd, 0, 0, 0 )
radians2  = CreateWindowEx( 0, "EDIT", "atn(1)/??"      , WS_VISIBLE Or WS_CHILD or WS_BORDER or ES_READONLY, 10,350 ,100, 20, hWnd, 0, 0, 0 )
deg2_S    = CreateWindowEx( 0, "EDIT", ""               , WS_VISIBLE Or WS_CHILD or WS_BORDER               ,115,230 ,100, 20, hWnd, 0, 0, 0 )
deg2_E    = CreateWindowEx( 0, "EDIT", ""               , WS_VISIBLE Or WS_CHILD or WS_BORDER               ,115,260 ,100, 20, hWnd, 0, 0, 0 )
stp2      = CreateWindowEx( 0, "EDIT", ""               , WS_VISIBLE Or WS_CHILD or WS_BORDER               ,115,290 ,100, 20, hWnd, 0, 0, 0 )
radi2     = CreateWindowEx( 0, "EDIT", ""               , WS_VISIBLE Or WS_CHILD or WS_BORDER               ,115,320 ,100, 20, hWnd, 0, 0, 0 )
radius_2  = CreateWindowEx( 0, "EDIT", ""               , WS_VISIBLE Or WS_CHILD or WS_BORDER               ,115,350 ,100, 20, hWnd, 0, 0, 0 )
y_1       = CreateWindowEx( 0, "EDIT", "y1=r1 *"        , WS_VISIBLE Or WS_CHILD or WS_BORDER or ES_READONLY, 10,380 ,100, 20, hWnd, 0, 0, 0 )
formula_y1= CreateWindowEx( 0, "EDIT", ""               , WS_VISIBLE Or WS_CHILD or WS_BORDER               ,115,380 ,490, 20, hWnd, 0, 0, 0 )
y_2       = CreateWindowEx( 0, "EDIT", "y2=r2 *"        , WS_VISIBLE Or WS_CHILD or WS_BORDER or ES_READONLY, 10,411 ,100, 20, hWnd, 0, 0, 0 )
formula_y2= CreateWindowEx( 0, "EDIT", ""               , WS_VISIBLE Or WS_CHILD or WS_BORDER               ,115,411 ,490, 20, hWnd, 0, 0, 0 )

'create help texts
help_text1= CreateWindowEx( 0, "EDIT", helptxt1         , WS_VISIBLE Or WS_CHILD or WS_BORDER or ES_READONLY or WS_HSCROLL or WS_VSCROLL or ES_MULTILINE,230, 10,375,140, hWnd, 0, 0, 0 )
help_text2= CreateWindowEx( 0, "EDIT", helptxt2         , WS_VISIBLE Or WS_CHILD or WS_BORDER or ES_READONLY or WS_HSCROLL or WS_VSCROLL or ES_MULTILINE,230,230,375,140, hWnd, 0, 0, 0 )

'draw and load and save buttons
loadF     = CreateWindowEx( 0, "BUTTON", "LOAD FORMULA" , WS_VISIBLE Or WS_CHILD, 20,450,120,30, hWnd, 0, 0, 0 )
saveF     = CreateWindowEx( 0, "BUTTON", "SAVE FORMULA" , WS_VISIBLE Or WS_CHILD,160,450,120,30, hWnd, 0, 0, 0 )
plotF     = CreateWindowEx( 0, "BUTTON", "PLOT FORMULA" , WS_VISIBLE Or WS_CHILD,310,450,120,30, hWnd, 0, 0, 0 )
saveD     = CreateWindowEx( 0, "BUTTON", "SAVE DRAWING" , WS_VISIBLE Or WS_CHILD,450,450,120,30, hWnd, 0, 0, 0 )
'===============================================================================
'===============================================================================
'===============================================================================
'===============================================================================
While GetMessage( @msg, 0, 0, 0 )
   
    TranslateMessage( @msg )
    DispatchMessage( @msg )
 
    Select Case msg.hWnd
        Case hWnd
        Select Case msg.message
            Case 273
            End
        End Select
       
   
        Case plotF
        select case msg.message 
            Case WM_LBUTTONDOWN
                parser()
                'ploter()
        end select

    end select
   
Wend
'===============================================================================
'===============================================================================
sub parser()
    Dim Result As EvalResult
   
    dim as integer xres,yres
    screen 19
    screeninfo xres,yres
    screenres xres,yres

    dim as double xctr=xres/2
    dim as double yctr=yres/2
   
    'get upper values from edit boxes
    dim txt0 as string * 20
    dim txt1 as string * 20
    dim txt2 as string * 20
    dim txt3 as string * 20
    dim txt4 as string * 20
   
    dim text1 as string * 256
    dim text2 as string * 256
   
    'get lower values from edit boxes
    dim txt5 as string * 20
    dim txt6 as string * 20
    dim txt7 as string * 20
    dim txt8 as string * 20
    dim txt9 as string * 20
   
    dim text3 as string * 256
    dim text4 as string * 256
   
    GetWindowText(deg1_S  , txt0 , sizeof(txt0))
    GetWindowText(deg1_E  , txt1 , sizeof(txt1))
    GetWindowText(stp1    , txt2 , sizeof(txt2))
    GetWindowText(radi1   , txt3 , sizeof(txt3))
    GetWindowText(radius_1, txt4 , sizeof(txt4))
   
    GetWindowText(formula_x1, text1 , sizeof(text1))
    GetWindowText(formula_x2, text2 , sizeof(text2))
   
    GetWindowText(deg2_S  , txt5 , sizeof(txt5))
    GetWindowText(deg2_E  , txt6 , sizeof(txt6))
    GetWindowText(stp2    , txt7 , sizeof(txt7))
    GetWindowText(radi2   , txt8 , sizeof(txt8))
    GetWindowText(radius_2, txt9 , sizeof(txt9))
   
    GetWindowText(formula_y1, text3 , sizeof(text3))
    GetWindowText(formula_y2, text4 , sizeof(text4))

    dim as double deg1_s=val(txt0)
    dim as double deg1_e=val(txt1)
    dim as double deg1
    dim as double stp1  =val(txt2)
    dim as double radi1 =atn(1)/val(txt3)
    dim as double cos1
    dim as double sin1
    dim as double radius_1=val(txt4)
    dim as string inputs_x1=text1
    dim as string inputs_y1=text2
    dim as double out_x1
    dim as double out_y1

    dim as double deg2_s=val(txt5)
    dim as double deg2_e=val(txt6)
    dim as double deg2
    dim as double stp2=val(txt7)
    dim as double radi2=atn(1)/val(txt8)
    dim as double cos2
    dim as double sin2
    dim as double radius_2=val(txt9)
    dim as string inputs_x2=text3
    dim as string inputs_y2=text4
    dim as double out_x2
    dim as double out_y2
   
    setvariable("r1",radi1)
    setvariable("r2",radi2)
   
    for deg1 = deg1_s to deg1_e step stp1
       
        setvariable("d1", deg1)
       
        cos1=cos(deg1*rad1)
        sin1=sin(deg1*rad1)
       
        for deg2 = deg2_s to deg2_e step stp2
       
            setvariable("d2", deg2)
           
            cos2=cos(deg2*rad2)
            sin2=sin(deg2*rad2)
           
            setvariable("c1", cos1)
            setvariable("s1", sin1)
            setvariable("c2", cos2)
            setvariable("s2", sin2)
           
            result = eval(inputs_x1) : out_x1 = result.value
            result = eval(inputs_x2) : out_x2 = result.value
            result = eval(inputs_y1) : out_y1 = result.value
            result = eval(inputs_y2) : out_y2 = result.value
           
            if instr(1,str(out_x1),"e") > 0 then out_x1=0
            if instr(1,str(out_x2),"e") > 0 then out_x2=0
            if instr(1,str(out_y1),"e") > 0 then out_y1=0
            if instr(1,str(out_y2),"e") > 0 then out_y2=0
           
            out_x1=radius_1*out_x1
            out_x2=radius_2*out_x2
            out_y1=radius_1*out_y1
            out_y2=radius_2*out_y2
           
            pset(xctr + out_x1 + out_x2 , yctr + out_y1 + out_y2 ) ,9
        next
    next

end sub

'===============================================================================
'===============================================================================

albert
Posts: 5635
Joined: Sep 28, 2006 2:41
Location: California, USA

Trigonometry-Designer-Windows_V1

Postby albert » Nov 01, 2011 18:58

!!~~Hi Everyone~~!!

I got the Trigonometry-Designer-Windows_V1 done...

Its on the PROJECTS BOARD
albert
Posts: 5635
Joined: Sep 28, 2006 2:41
Location: California, USA

Postby albert » Nov 03, 2011 0:32

Does anyone know where to get an executable (*.exe) file viewer ???

My Windows 7 doesnt have any such thing and Write and Notepad replace the ascii with font chars or blanks..

Do I got to write one myself or has anybody put one on the forum???
I tried a forum "SEARCH" for "exe viewer" with no luck!!!
TJF
Posts: 3546
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Postby TJF » Nov 03, 2011 6:25

albert wrote:I tried a forum "SEARCH" for "exe viewer" with no luck!!!

Try "editor hex[adecimal]".
dodicat
Posts: 6390
Joined: Jan 10, 2006 20:30
Location: Scotland

Postby dodicat » Nov 03, 2011 11:00

albert wrote:Does anyone know where to get an executable (*.exe) file viewer ???

My Windows 7 doesnt have any such thing and Write and Notepad replace the ascii with font chars or blanks..

Do I got to write one myself or has anybody put one on the forum???
I tried a forum "SEARCH" for "exe viewer" with no luck!!!

Hi Albert
The ide for lcc (the C compiler for bcx) can open exe files.
There are loads of hex editors:

http://en.wikipedia.org/wiki/Comparison_of_hex_editors

I dont know if Win 7 still uses EDIT:

Code: Select all

shell("edit")


If you open a file you've got the choice on the bottom right to open binary.
In the above code you can open fbidetemp.exe, because EDIT is focused in your fbide folder in this instance.
albert
Posts: 5635
Joined: Sep 28, 2006 2:41
Location: California, USA

Postby albert » Nov 03, 2011 22:18

@Dodicat

I wanted an (*.EXE) viewer to display the MS-DOS ASCII (0 to 255).

I can use the font thingys I or you did to display the characters..
But I'll have to write some windowing and scroller routines.
Which is what i wanted to avoid. Since Windows Edit-Controls won't display all CHR(0 to 255) 's

===============================================
I revamped PodVornyak's OpenGl code..

I'm going to make " Trigonometry-Designer-Windows_V2 " with selectable (OpenGL 3D) / (Normal 2D) modes to plot in..

Heres the redoo , The little console window has the instructions on it..

Code: Select all

#include once "GL/gl.bi"
#include once "GL/glu.bi"

'console printed instructioins.
print "Press Esc to EXIT"
print "-----------------------------------------"
print
print "Press Space-bar to stop all motion       "
print
print "-----------------------------------------"
print "Left , Right Arrows to rotate on X - Axis"
print
print "  Up ,  Down Arrows to rotate on Y - Axis"
print
print " R_Shft to reset U/D , L/R rotate values "
print "-----------------------------------------"
print
print " (+) , (-) , (Enter) to control spin     "
print
print " (Q) , (W) , (E) to control zoom level   "
print
print " (A) , (S) , (D) to control U/D shift    "
print
print " (Z) , (X) , (C) to control L/R shift    "
print "-----------------------------------------"

'setup graphics screen
dim as integer xres, yres
screen 19
screeninfo xres, yres
Screenres xres, yres, 32, 1, 2
       
        windowtitle "Open-Gl"
        glMatrixMode GL_PROJECTION
        glLoadIdentity
        gluPerspective 90, (xres/yres), .1, 500
        glMatrixMode GL_MODELVIEW

        glLoadIdentity
        glblendfunc GL_SRC_ALPHA, GL_ONE
        glpointsize 3
        glenable gl_blend

'-----------------------------------------------------------------------
'for OpenGl transition,rotation variables
dim as double xt, yt, zt=-15
dim as double xr, yr, zr
dim as double xrs=1, yrs=1, zrs=1' transitions of camera


'for general trig looping and values
dim as double rad = atn(1)/22.5
dim as double deg1 , deg2
dim as double c1,c2
dim as double s1,s2

dim as byte status = 1 'start / end toggle
do while status=1

        glclear GL_DEPTH_BUFFER_BIT or GL_COLOR_BUFFER_BIT
        glloadidentity
        gltranslatef xt, yt, zt
        glrotatef xr, 1, 0, 0
        glrotatef yr, 0, 1, 0
        glrotatef zr, 0, 0, 1       

        glbegin gl_points
           
            for deg1 = 0 to 360 step 1
                   
                c1=cos(deg1*rad)
                s1=sin(deg1*rad)
                   
                for deg2 = 0  to 360 step 1
                   
                    c2=cos(deg2*rad)
                    s2=sin(deg2*rad)
                       
                    glcolor3ub cos(c2*s2)/1.5, cos(c2*s2)/.35 , cos(c2*s2)/.25
                       
                    glvertex3f atan2( tan(c2+c2) , tan(c1+c1)/2 )*2 , atan2( tan(s2+s2) , tan(s1+s1)/2 )*2 ,  (cos(c1+s1)*5)
                   
                next
            next
        glend

        screensync
        flip
        glflush

        if multikey(&h01) then status = 0 ' esc key to quit
       
        xrs = xrs + (multikey(&h50)/5) - (multikey(&h48)/5) 'left & right arrows
        yrs = yrs + (multikey(&h4D)/5) - (multikey(&h4B)/5) 'up & down arrows
        zrs = zrs + (multikey(&h0C)/5) - (multikey(&h4E)/5) 'plus & minus on the keypad
       
        if multikey(&h36) then 'r_shft to reset x,y rotation values
            xrs=0:yrs=0
            xr =0:yr =0
        end if
       
        xr = xr - xrs
        yr = yr - yrs
        zr = zr - zrs
       
        xt = xt + (multikey(&h2C)/2) - (multikey(&h2D)/2) ' l,r arrows to cause l,r rotation
        yt = yt + (multikey(&h1E)/2) - (multikey(&h1F)/2) ' u,d arrows to cause u,d rotation
        zt = zt + (multikey(&h10)/2) - (multikey(&h11)/2) ' -,+ keys to cause spin
       
        if multikey(&h39) then xrs=0 : yrs=0 : zrs=0   ' SPACE-BAR = stop all transitions
       
        if multikey(&h12) then zt=-15        ' "E key" reset zoom level
        if multikey(&h20) then yt= 0         ' "D key" reset UP/DOWN    position to center
        if multikey(&h2E) then xt =0         ' "C key" reset Left/Right position to center
        if multikey(&h1C) then xr=0:yr=0:zr=0' "Enter Key" reset spin to zero

loop
END
Last edited by albert on Nov 03, 2011 23:30, edited 1 time in total.

Return to “General”

Who is online

Users browsing this forum: No registered users and 3 guests