Search found 20 matches

by t3rt3l
May 22, 2013 2:35
Forum: General
Topic: Can't get width and height from bmp
Replies: 11
Views: 1417

Re: Can't get width and heigth from bmp

Append "field = 1" to this line and it's all fine. :) /wiki/KeyPgfield

Code: Select all

TYPE Win4BitInfoHeader FIELD = 1
by t3rt3l
May 10, 2013 9:33
Forum: General
Topic: Cannot Cast to Type Alias
Replies: 12
Views: 1132

Re: Cannot Cast to Type Alias

fxm wrote:- About the non-member operator 'cast' declaration, I think that:
'declare operator cast (f as foo, b as bar) as foo'
must be corrected as:
'declare operator cast (b as bar) as foo'

Thank you, I updated the ticket.
by t3rt3l
May 06, 2013 19:54
Forum: General
Topic: Cannot Cast to Type Alias
Replies: 12
Views: 1132

Re: Cannot Cast to Type Alias

fxm wrote:You can simply use an overloaded function (for example named '_cast()' or otherwise):

That is exactly my point. I'm sure you can agree that "cast" is cleaner than "_cast".
by t3rt3l
May 06, 2013 17:27
Forum: General
Topic: Cannot Cast to Type Alias
Replies: 12
Views: 1132

Re: Cannot Cast to Type Alias

Wishful code: type velocity as double speed, direction end type type vector2d as double x, y end type operator cast (vel as velocity) as vector2d return type<vector2d>(cos(vel.direction)*speed, -sin(vel.direction)*speed) end operator operator cast (vec as vector2d) as velocity return type<velocity>(...
by t3rt3l
May 06, 2013 9:51
Forum: General
Topic: Cannot Cast to Type Alias
Replies: 12
Views: 1132

Re: Cannot Cast to Type Alias

You misunderstand. I'm wondering if it's likely in the future to allow cast overloading from outside type declarations, to match the current syntax for overloading arithmetic operators. As of now these are allowed: type foo declare operator cast as bar end type declare operator + (f as foo, b as bar...
by t3rt3l
May 06, 2013 1:57
Forum: General
Topic: Cannot Cast to Type Alias
Replies: 12
Views: 1132

Re: Cannot Cast to Type Alias

type foo declare operator cast as bar 'Requires bar to be a complete type declare operator + (b as bar) as foo 'Compiler says this is planned end type operator cast (f as foo) as bar 'Not allowed end operator operator + (f as foo, b as bar) as foo end operator If arithmetic operator overloading is ...
by t3rt3l
May 05, 2013 19:27
Forum: General
Topic: Cannot Cast to Type Alias
Replies: 12
Views: 1132

Cannot Cast to Type Alias

I want to be able to cast one UDT to another and vice versa.

Here is my attempt:

Code: Select all

type __bar as bar

type foo
    declare operator cast as __bar 'Incomplete type error
    as integer a
end type

type bar
    declare operator cast as foo
    as integer a
end type
by t3rt3l
Apr 15, 2013 9:09
Forum: Community Discussion
Topic: Member Procedures - Why so verbose?
Replies: 5
Views: 691

Member Procedures - Why so verbose?

Why disallow this syntax:

Code: Select all

type foo
    as integer a
   
    sub doit
        print a
    end sub
end type

And require this longer syntax?:

Code: Select all

type foo
    declare sub doit
   
    as integer a
end type

sub foo.doit
    print a
end sub
by t3rt3l
Dec 22, 2012 20:59
Forum: General
Topic: Delete vs. Delete[]
Replies: 20
Views: 2979

Delete vs. Delete[]

Is there any consequence to using delete[] to deallocate memory previously allocated by new?

Code: Select all

dim as integer ptr a = new integer
delete[] a

The documentation mentions not to mix the two operators but does not discuss why.
by t3rt3l
Dec 22, 2012 14:36
Forum: General
Topic: Problems with FRE
Replies: 11
Views: 464

Re: Problems with FRE

To be honest, I'm surprised the program above doesn't crash, because 4MB should be exceeding the stack size. I hadn't tested the code. I just wrote it for example, under the knowledge that something similar wouldn't work. Better example: print fre dim as integer ptr foo = new integer [1000000] prin...
by t3rt3l
Dec 22, 2012 6:49
Forum: General
Topic: Problems with FRE
Replies: 11
Views: 464

Problems with FRE

In the past I've tried using FRE with no luck since it never seemed to change. print fre 'outputs 4294967295 dim as integer foo(1000000) print fre 'erroneously outputs 4294967295 again I later realized 4294967295 bytes = 4 GB, which means even the first use of FRE in the code above didn't work right...
by t3rt3l
Nov 01, 2012 7:01
Forum: Tips and Tricks
Topic: Smooth and Smoother Step Interpolation
Replies: 3
Views: 2319

Smooth and Smoother Step Interpolation

I stumbled upon some interpolation functions on Wikipedia and decided to port them to FB. I also include my own (slowish) function which models the curve of a sinusoidal function. All of these functions take a number from 0 to 1 and returns a number from 0 to 1. Smooth Step: function smoothStep (x a...
by t3rt3l
Oct 03, 2012 11:05
Forum: Projects
Topic: Easy GL2D
Replies: 154
Views: 31234

Re: Easy GL2D

@VANYA
To fix your problem, paste the following line into "FBGL2D7.bi" underneath the other #includes.

Code: Select all

#include once "gl/glext.bi"


I believe this has to do with different versions of OpenGL.
Edit: Great library by the way, rel.
by t3rt3l
Sep 29, 2012 1:32
Forum: General
Topic: Function returning an array
Replies: 11
Views: 1050

Re: Function returning an array

You could make a sub that takes an array and writes to it.

Code: Select all

sub fill (array() as integer)
    for i as integer = 0 to ubound(array)
        array(i) = i
    next
end sub

Go to advanced search