Author Topic: Can't get my console class to work  (Read 17582 times)

0 Members and 4 Guests are viewing this topic.

JRS

  • Guest
Re: Can't get my console class to work
« Reply #15 on: July 06, 2011, 01:51:03 PM »
Quote
It narrows the gap between compiling and scripting Basic.

I'm glad one of the Basic compiler authors get it. I'm spoiled using SB and would have a hard time going back to defining and declaring everything before use.

Nice job Charles and looking forward to OxygenBasic maturing as time goes on.

« Last Edit: July 06, 2011, 09:05:45 PM by JRS »

Charles Pegge

  • Guest
Re: Can't get my console class to work
« Reply #16 on: July 06, 2011, 10:06:04 PM »
Hi Kent,

Got your console working!

There wasn't much wrong with it :)

missing * for passing byref

the RetValue was not assigned to - I've done it direct.

The other corrections were to remove the str from c.print procedures

You don't need $ or % suffixes. I try to ensure these are stripped from all symbols  internally.

Code: OxygenBasic
  1.  
  2.         method GetSBI( CONSOLE_SCREEN_BUFFER_INFO *aSBI ) as sys
  3.             return GetConsoleScreenBufferInfo GetOutputHandle, aSBI
  4.         end method
  5.  
  6.  

I have included your code in the Oxygen projects folder

Charles

Charles Pegge

  • Guest
Re: Can't get my console class to work
« Reply #17 on: July 06, 2011, 10:42:36 PM »

Hi John,

A selection of Hello Worlds in different programming languages. Some have noisier syntax than others.

Charles

Code: [Select]

LISP

"Hello!"

BASIC

print "Hello"


COBOL

000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID.     HELLOWORLD.
000300
000400*
000500 ENVIRONMENT DIVISION.
000600 CONFIGURATION SECTION.
000700 SOURCE-COMPUTER. RM-COBOL.
000800 OBJECT-COMPUTER. RM-COBOL.
000900
001000 DATA DIVISION.
001100 FILE SECTION.
001200
100000 PROCEDURE DIVISION.
100100
100200 MAIN-LOGIC SECTION.
100300 BEGIN.
100400     DISPLAY " " LINE 1 POSITION 1 ERASE EOS.
100500     DISPLAY "Hello world!" LINE 15 POSITION 10.
100600     STOP RUN.
100700 MAIN-LOGIC-EXIT.
100800     EXIT.


FORTRAN

       program hello
          print *, "Hello World!"
       end program hello
 
PASCAL

program Hello;
 
begin
   Write('Hello world');
end.



C++

#include <iostream>
using namespace std;
void main()
{
  cout << "Hello World!" << endl;   cout << "Welcome to C++ Programming" << endl; }

JAVA

class HelloWorldApp {
    public static void main(String[] args) {
        System.out.println("Hello World!"); // Display the string.
    }
}

JAVASCRIPT

<script type="text/javascript">
document.write('<b>Hello World</b>');
</script>


JRS

  • Guest
Re: Can't get my console class to work
« Reply #18 on: July 07, 2011, 12:00:50 AM »
My comfort zone has been with ScriptBasic on the server, JavaScript on the client and jQuery for sex appeal. Runs on all the popular platforms (32/64 bit) and compatible with a broad range of browsers. Mobile computing is driving desktop applications to the web. IMHO

kryton9

  • Guest
Re: Can't get my console class to work
« Reply #19 on: July 07, 2011, 01:48:31 PM »
I had tried that Charles, strange it worked for you and not for me. I will download your version to see. Thanks.

Peter

  • Guest
Re: Can't get my console class to work
« Reply #20 on: July 07, 2011, 02:24:22 PM »
If I see this psycho scrawniness then I am feeling so bad.
Programmers live in another world without reference to the reality.
What they need is a spelling police.  :D

Charles Pegge

  • Guest
Re: Can't get my console class to work
« Reply #21 on: July 07, 2011, 04:21:43 PM »

Bug Alert!

If you downloaded the Oxygen in-progress version within the last 24 hours.
I found a few of my examples not working - due to some of the expressions using floats being mis-compiled. I have just fixed this and reposted.

The moral is: don't assume you understand your own code. The Charles of six months ago was a different programmer!

We are almost ready for release Alpha 036.

Charles

kryton9

  • Guest
Re: Can't get my console class to work
« Reply #22 on: July 07, 2011, 07:38:02 PM »
I really the progress so far Charles. Getting rid of ( ) requirement in so many places really helps the code look nice.

I am finding that putting an m prefix in front of member variables really helps. An a prefix in front of arguements being passed to methods of a class. Using Capital First letters for all Methods and Capitals for all subs and functions, then first letter lowercase for normal variables with camel case really helps solve the problem with naming conflicts. Dummy example code below:
class DummyC
private 'vars
    string mName
    string mOccupation
public 'methods
    method SetData( string aName, aOccupation)
        mName = aName
        mOccupation = aOccupation
    end method
end class

new DummyC d
      sys numDoctors = 11
      d.SetData "Dr Who", "Time Lord"
del d


Charles Pegge

  • Guest
Re: Can't get my console class to work
« Reply #23 on: July 08, 2011, 12:48:45 AM »

This might be of use, Kent.

with this.   .. end with

especially in methods with named params where you want to keep the names simple for the user.

Code: OxygenBasic
  1.   class thing
  2.   '==========
  3.  
  4.   double length,width,depth, u
  5.  
  6.   method SetSize( double length=1, width=1,depth=1, string unit="cm" )
  7.   u=1
  8.   if unit="cm" then
  9.     u=1
  10.   elseif unit="m"
  11.     u=100
  12.   elseif unit="in"
  13.     u=2.54
  14.   end if
  15.   '
  16.  with this.
  17.   length=length*u
  18.   width=width*u
  19.   depth=depth*u
  20.   end with
  21.   '
  22.  end method
  23.  
  24.  
  25.  
  26.  
  27.   end class
  28.  
  29.   'TEST:
  30.  '=====
  31.  
  32.   thing t
  33.   t.SetSize  length=2, unit="in"
  34.  
  35.   print "check length stored: "  t.length
  36.  

Charles

kryton9

  • Guest
Re: Can't get my console class to work
« Reply #24 on: July 08, 2011, 02:09:05 AM »
Nice options, but it might be good for the user, but can get confusing to me. Look at how much trouble I am having with this simple method, yikes.
  
I added to the console class, but it is not working again. I have a few more things I want to add that will make it really cool. But I need to get this working. I am instead of just writing a simple console wrapper wanting to make it easier to use with less code.

Here is the code so far attached. Hopefully you can see why it compiles fine, but goes into lala land when run.

outdated attachments removed to avoid confustion.
« Last Edit: July 10, 2011, 08:07:26 PM by kryton9 »

Charles Pegge

  • Guest
Re: Can't get my console class to work
« Reply #25 on: July 08, 2011, 04:04:25 AM »
Yes Kent,

yes we have a mapping problem with UDTs, particularly when they do not align to 4 bytes. This will be my bug fix of the day!

But you only need to add one word in your case , and everything works.

dim ...

The makes mSBI a static variable of the class. But not part of the class table.

Code: OxygenBasic
  1.         dim CONSOLE_SCREEN_BUFFER_INFO mSBI
  2.  

Charles

Peter

  • Guest
Re: Can't get my console class to work
« Reply #26 on: July 08, 2011, 04:51:06 AM »
Code: [Select]
The Charles of six months ago was a different programmer!
Brainwash ?


efgee

  • Guest
Re: Can't get my console class to work
« Reply #27 on: July 08, 2011, 10:39:46 AM »
...yes we have a mapping problem with UDTs, particularly when they do not align to 4 bytes. This will be my bug fix of the day!

That's why I stopped working on my console or windows classes; too many bugs waste too much of my time.

Suppose that's why it's still called: alpha. ;D

When the next version will be out I will give oxygen another shot.

Take care
efgee

efgee

  • Guest
Re: Can't get my console class to work
« Reply #28 on: July 08, 2011, 11:13:50 AM »
Quote
It narrows the gap between compiling and scripting Basic.

I'm glad one of the Basic compiler authors get it. I'm spoiled using SB and would have a hard time going back to defining and declaring everything before use.

To explicitly declare stuff and write comments next to it to describe for what's used is paramount:
1.) In an environment where collaboration between programmers is needed
2.) If the code needs to be readable after several years even by only one programmer.

Hope oxygen will have/keep the EXPLICIT option :)



Charles Pegge

  • Guest
Re: Can't get my console class to work
« Reply #29 on: July 08, 2011, 01:24:43 PM »

Hi Efgee,

Although Oxygen is small, there are are large number of permutations to test, especially on the OOP side. If you use frequent develop/test cycles and work in small increments, bug detection is much easier.

There are 2 commands for firming up code discipline:

#autodim and #unique

thus:

def strict #autodim off

def stricter #autodim off : #unique on

or even:

def whiplash #autodim off : #unique on : #case sensitive   ;D

Charles