BasicReaction.org

User projects written in or related to FreeBASIC.
c0rt3x
Posts: 7
Joined: May 15, 2009 21:26

BasicReaction

Postby c0rt3x » May 17, 2009 19:00

Looks allready almost exactly like VB6... :-D

Image

Plugin support is a MUST-HAVE. In that point I absolutely agree with you...

I'm going to try it in other forums, too. (german FB-Forum, Xtreme-VB, VB-forums) And I will publish the source code at source-forge!

This will be my first open source project. :-)

PS: And YES I will write this project completely in VB6 because at the end it should be able to translate it's own VB source code into clean, fast and runnable FreeBASIC code...

@Galeon: http://en.wikipedia.org/wiki/Obfuscated_code

PS: Tomorrow i will post a download link to a version that is able to compile some basic stuff.
McLovin
Posts: 82
Joined: Oct 21, 2008 1:15
Contact:

Postby McLovin » May 17, 2009 23:47

PS: And YES I will write this project completely in VB6 because at the end it should be able to translate it's own VB source code into clean, fast and runnable FreeBASIC code...


I hate to be a kill joy but the above statement will fail. You will not be able to translate VB code FB code. It will extremely difficult to make any type of a one-to-one translation of the code. What you are experiencing is the easy part of the project... building a simple environment interface. Try writing the interface portion of code that allows you draw the controls on the form and move/resize them. Then the code to handle all of the properties related to those controls... and then the generated code to make all of the forms and controls work in conjunction with the user supplied code that gets entered into your code editor. Not an easy task.

Worse of all, writing this in VB is a long term disaster. VB is great at GUI but slow and bloated with everything else. What will happen is that you will hope that FB programmers will join your project but I fear that they won't because VB is not their cup of tea - FB is. Why not try writing your visual designer using FB? At least then you'll learn what is needed to generate the FB source while you're learning the GUI aspects of the code as well.

(I just re-read my comments.... Sorry to sound so negative, but I have seen many projects that start off quick and die an even quicker death because it seems easy to pile together a GUI - the hard stuff will take you many many months to accomplish and I fear that VB, which is a dead language, will be a disservice to you in the long run).

Good luck!!!!

:)
Galeon
Posts: 563
Joined: Apr 08, 2009 5:30
Location: Philippines
Contact:

Postby Galeon » May 18, 2009 7:09

i don't think it can produce a very good translated code, even M$' VS6 to VB.NET are not good enough, i need to tweak the very simple vb dll example of fb just to make it run, and vb have lots of functions, i think its easier to code a c to fb than a c++ or vb to fb translater, fb programmers don't want to use another prog language, they are pampered by fb, they enjoying it. i don't someone can help you inside this forum, many fb users love open source: fbc, mingw32, dev-cpp, gcc, just to name a few not vb6
Galeon
Posts: 563
Joined: Apr 08, 2009 5:30
Location: Philippines
Contact:

Postby Galeon » May 18, 2009 7:23

there are currently 3 types of people you want to help you:
fb coders: they don't like your project, its written in vb
vb coders turned into fb coder: they like it, more people will become fb coders, but can't help you, they hated vb and don't want to go back
vb coders: they don't care. they love vb, don't know fb,
you may:
1. move to fb!
2. tell us why it will help us fb coders (can it gave us more fb developers, which we need?, is this a great project written in fb we can be proud of?)
c0rt3x
Posts: 7
Joined: May 15, 2009 21:26

BasicReaction

Postby c0rt3x » May 18, 2009 13:46

OK I think i have to make something clear:

The main reason why this VB to FB converter is writtten in VB is that developing GUI apps in VB is much less time consuming compared with coding them in FB.

Maybe you did'nt see my statement that I posted yesterday that says that the code of BasicReaction will be convertet into FreeBASIC using BasicReaction itself as soon as possible.

But the most important reason is that I've allready written a VB6 obfuscator (over 20.000 lines of code!) in VB6 with a lot code parsing functions/classes that are not compatible to FreeBASIC. But it was a pure wasting of time not using them...
Galeon
Posts: 563
Joined: Apr 08, 2009 5:30
Location: Philippines
Contact:

Postby Galeon » May 18, 2009 14:27

i thought you would say that:
1. you may continue the gui with vb by making it the main program. (fbedit with gui in asm)
2. the obfuscator's code in a library, (fbedit) or even as a plugin (fbide in c++)
3. other codes in fb (fbedit)
i've included how other ide's made it to work but i think you won't like it.
just answer no.2 in my last post.
justSomeGuy
Posts: 2
Joined: May 19, 2009 19:13
Location: right here
Contact:

So you want VB 6.0 style classes do you

Postby justSomeGuy » May 19, 2009 19:42

I was going to make a separate FB++ project for OOP support, but since you look pretty ambitious and I'm feeling pretty lazy heres some inspiration.

This is a template for partial OOP for FreeBasic, written in FreeBasic ofcourse.

ex.1

Code: Select all

type className_VARS
   objIndex as integer 'for the some future function not yet defined
   objName as string   'for the getID function
   memberName as string
end type

dim shared className_COUNT as integer 'a count should exist for class defined
className_COUNT = 0
redim shared className_VARRAY(1) as className_VARS


enum classes
   className
end enum

enum publicMethods
   className_methodName
end enum

enum publicMembers
   className_memberName
end enum


function getID(fName as string, objectType as classes) as integer
'maps friendly name to [object states] index of given class
   
   dim i as integer
    select case objectType
    'code must be repeated for every unique class type   
        case className      
         
         for i = 1 to className_COUNT
         
            if (className_VARRAY(i).objName = fName) then
               function = i
                    exit function
                else
                    function = -1
            end if

            next
           
   end select
   
   
end function


sub className_Constructor(objectName as string)
'empty constructor
end sub

sub className_METHOD_methodName(objectName as string)
'empty method
end sub

sub className_CREATE(objectName as string)
   'make new record

    className_COUNT = className_COUNT + 1
 
   className_VARRAY(className_COUNT).objIndex =  className_COUNT
   className_VARRAY(className_COUNT).objName = objectName
   className_Constructor(objectName)
end sub



sub createInstance(objectType as classes,objectName as string)
   
    SELECT CASE objectType

   case className
         className_CREATE(objectName)
         className_Constructor(objectName)
    end select
   
end sub

sub runObjectMethod(objectType as classes, objectName as string, methodName as publicMethods)
   
   select case objectType
   
      case className
         'chain through methods, yet another enum
         'notice this is why functions/subs are declared twice
         select case methodName
            case className_methodName
                        className_METHOD_methodName(objectName)
         end select
           
    end select

end sub
   
sub changeObjectVarStr(objectType as classes,objectName as string,varName as publicMembers,value as string)
   
   select case objectType
   
      case className
      
         select case varName
            case className_methodName
                    className_VARRAY(getID(objectName,className)).memberName = value
         end select
         
   end select
   
end sub


Heres another OOP attempt in FreeBasic, this time with some meat

ex.2

Code: Select all

type personVars
   objIndex as integer
   objName as string
   firstName as string
   lastName as string
end type

dim shared person_COUNT as integer
person_COUNT = 0
redim shared personVarArray(1) as personVars


enum classes
   person
end enum

enum publicMethods
   person_printFirstName
end enum

enum publicMembers
   person_firstName
end enum


function getID(fName as string, objectType as classes) as integer
'maps friendly name to [object states] index of given class
'redim preserve personVarArray(person_COUNT)  as personVars   
   dim i as integer
    select case objectType
       
        case person
             for i = 1 to person_COUNT
             
           
            if (personVarArray(i).ObjName = fName) then
               function = i
                    exit function
                else
                    function = -1
            end if
         next
           
   end select
   
   
end function

sub person_Constructor(objID as integer)
'empty constructor
end sub

sub person_METHOD_printFirstName(byval objectName as string)
 
    print personVarArray(getId(objectName,person)).firstName
end sub

sub personExpandArray(objectName as string)
   'make new record
 '   print "Instance of person created: " + objectName
    person_COUNT = person_COUNT + 1
  ' redim preserve personVarArray(1 to person_COUNT)
   
  '  print "Instance count now at: " + str(person_COUNT)

   personVarArray(person_COUNT).objIndex =  person_COUNT
   personVarArray(person_COUNT).objName = objectName
   person_Constructor(person_COUNT)
end sub

sub printPersons()
    dim i as integer
    for i = 1 to person_COUNT
        print personVarArray(i).objName
    next
end sub




sub createInstance(objectType as classes,objectName as string)
   
    SELECT CASE objectType
      
        case person
         personExpandArray(objectName)
   
    end select
      

   
end sub

sub runObjectMethod(objectType as classes, objectName as string, methodName as publicMethods)
   
   select case objectType
   
      case person
         'chain through methods, yet another enum
         'notice this is why functions/subs are declared twice
         select case methodName
            case person_printFirstName
                        person_METHOD_printFirstName(objectName)
         end select
           
    end select
      
   
end sub
   
sub changeObjectVarStr(objectType as classes,objectName as string,varName as publicMembers,value as string)
   redim personVarArray(person_COUNT) as personVars
   select case objectType
   
      case person
      
         select case varName
            case person_firstName
                    personVarArray(getID(objectName,person)).firstName = value
         end select
         
   end select
   
end sub



   
createInstance(person,"Joe")
createInstance(person,"Bob")

print person_COUNT
dim tmp as string
tmp = "Joe Bob"

changeObjectVarStr(person,"Joe",person_firstName,tmp)
runObjectMethod(person,"Joe",person_printFirstName)


And heres what that code would look like if FreeBasic had oop

ex. 3

Code: Select all

class person
   public name as string
   
   public sub printFN()
   print firstName
   end
   public sub person()
   'empty constructor
   end sub
end class

dim a as new person
dim ab as new person
a.name = "Joe Bob"

a.printFN


So basically(<-ha ha), you have the fun task of converting example 3 into something more like example 2. Something freebasic can understand.
Visual Basic 6.0 doesn't have full OOP, so atleast implementation is that much easier.

btw, when I wrote ex.2 I was unaware FBC had support for name spaces.
Something to keep in mind, should you want to implement inheritance.
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Re: So you want VB 6.0 style classes do you

Postby vdecampo » May 19, 2009 20:05

justSomeGuy wrote:And heres what that code would look like if FreeBasic had oop


Actually, this is what it looks like in FreeBASIC because it already has OOP.

Code: Select all

Type person
   Declare Constructor()
   Declare Destructor()
   Declare function printFN() As String
   myname As String
End Type

Constructor person
   'Do constructive stuff here
End Constructor
Destructor person
   'Do destructive stuff here
End Destructor

Function person.printFN() As String
Dim sp As Integer = InStr(1,this.myname," ")
   sp = IIf(sp=0,Len(this.myname),sp)
   Return Left(this.myname,sp)
End Function

Dim a As person
Dim ab As person

a.myname = "Joe Bob"

Print a.printFN()

Sleep


-Vince
marcov
Posts: 3011
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Postby marcov » May 19, 2009 20:13

McLovin wrote:Try writing the interface portion of code that allows you draw the controls on the form and move/resize them. Then the code to handle all of the properties related to those controls... and then the generated code to make all of the forms and controls work in conjunction with the user supplied code that gets entered into your code editor. Not an easy task.


Ah well, that is what they said when Lazarus was started too :-)

I do agree with little room to spare for differences though. Lazarus had the advantage of being _very_ compatible to the language of the original. (and still it took 10 years to become usable with a team of 3-5)
Last edited by marcov on May 21, 2009 8:45, edited 1 time in total.
justSomeGuy
Posts: 2
Joined: May 19, 2009 19:13
Location: right here
Contact:

didn't see that in the manual

Postby justSomeGuy » May 19, 2009 21:39

@vdecampo

well this is embarrassing. Turns out while I was learning freebasic, I was reading an old manual.

That means this whole time... I've been doing extra work.

I feel just awful now.
Galeon
Posts: 563
Joined: Apr 08, 2009 5:30
Location: Philippines
Contact:

Postby Galeon » May 20, 2009 2:53

@c0rt3x: any news?
i think the easiest way to implement those functions for forms' properties would be to create your own windows procedure and add some select case stuff to catch some msgs when the user wants something like button_clicked thing. i was planning to make it a project of mine but i'm busy with 2 projects. i'm also lazy...
angros47
Posts: 1678
Joined: Jun 21, 2005 19:04

Postby angros47 » Aug 21, 2009 10:16

About Visual Basic clones, does anybody recall Envelop Visual Basic? It was a sort of VB4 clone, freeware, with full OOP. It had (if I remember correctly) a core that was an interpreter (and had to be installed on the target machine to run programs), and everything else was written in basic (the IDE itself was written in basic, and you were able to change it)

Programs could be modified even when running (both code and forms could be changed), and were stored as plain text or as tokenized files (for obfuscation). When you started a project, the exe file were created immediately (it was only a loader, to start the interpreter and the real program).

To distribute the final work, there was an install-generator (the install routine will copy the runtime interpreter, the obfuscated program and the loader on target machine).

It's now abandoned, you can find on www.janus-software.com

Maybe it's worth a look... if the IDE could be ported to FB it could be interesing....

Also, a FB-compatible interpreter+IDE/RAD+FB compiler could be a rocking development system...
CaptainFLAM
Posts: 15
Joined: Aug 14, 2009 12:30

Postby CaptainFLAM » Aug 21, 2009 10:55

OK.

I download Envelop and launched it but it doesn't start ("Segmentation Violation" == 0)

But it has some source code of envelop itself to study.

Anyway, i started a project based on eodor GUI Lib, to integrate in FB Edit ...

This is the same thing of your project, but in a different manner.
fsw
Posts: 260
Joined: May 27, 2005 6:02

Postby fsw » Aug 21, 2009 17:46

FYI: Jabaco seems to become a good VB6 replacement.
Uses the Java environment. Free but not open source.

fsw
angros47
Posts: 1678
Joined: Jun 21, 2005 19:04

Postby angros47 » Aug 21, 2009 18:00

Even KBasic(http://kbasic.com) could be a good replacement...

It's open source, and works on windows, linux and mac.

Under linux, it's free, but you can only develop GPL programs.

It uses p-code and a virtual machine. An interesting fact: like FB, it has three dialects: a "full" mode, a VB-compatible mode (oldbasic) and a QB-compatible mode (veryoldbasic)

Return to “Projects”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 5 guests