April 20, 2024, 03:35:03 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Bugs

Started by Zen, November 10, 2005, 02:27:49 AM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Zen


global sub main()
{

int name;

writeln("Name:");
name = readln();

writeln("Hello "+name);

while GetKey() = "";

return;

}


Crashed the parser app once i changed "string name" to "int name" and tried to re-compile. I know this is not right anyway but i just tried it to see what kind of errors i got back. Turns out a crash  :o

Lewis

Zen

Not a bug as such but the default Version Info resource needs needs to be change :)

Lewis

Ionic Wind Support Team

Thanks.

Fixed for next update.

Ionic Wind Support Team

Zen

No problem. Thats what we are all here for ;)

I did something else to crash the parser too, cant remember how i did it though. i will try do it again.

Lewis

Zen

Parser crashed again whilst i was trying to figure out how to use #include. i tried it with "filename.src"; without "" and also tried it as (filename.src) this crashed the parser.

I still dont know how to use it either. lol.

Lewis

Ionic Wind Support Team

Compiler preprocessor commands, the ones that start with #, don't need a semicolon terminator.

The #include statement looks in the 'include' directory if a full path isn't specified.

#include "test.inc"

All include files should have the extension '.inc'

Paul.
Ionic Wind Support Team

Zen

November 10, 2005, 02:21:19 PM #6 Last Edit: November 10, 2005, 02:24:49 PM by Lewis
This is my code...


#include "Include.inc"

//#################\\
// Main Subroutine \\
//#################\\

global sub main()
{

Test myClass;

writeln("Hello World\n\n");

myClass.SetData("Test Data");

writeln(myClass.GetData());

while getkey() = "";

return 0;

}


When i try to compile i get...

Quote
Compiling...
Test
File: C:\Program Files\Aurora\projects\Test.src (1) syntax error - }

File: C:\Program Files\Aurora\projects\Test.src (14) undefined variable - myClass
File: C:\Program Files\Aurora\projects\Test.src (14) syntax error
File: C:\Program Files\Aurora\projects\Test.src (16) undefined variable - myClass
File: C:\Program Files\Aurora\projects\Test.src (16) syntax error
File: C:\Program Files\Aurora\projects\Test.src (16) variable expected
File: C:\Program Files\Aurora\projects\Test.src (16) no appropriate conversion exists
File: C:\Program Files\Aurora\projects\Test.src (20) RETURN outside of subroutine
File: C:\Program Files\Aurora\projects\Test.src (23) { } mismatch - }

Error(s) in compiling "C:\Program Files\Aurora\projects\Test.src"
Include

Dont know why?

Lewis

GWS

Yippee! .. I got mine .. :)

Installation runs fine on Win98SE.ÂÃ,  Got problems with setting the Editor Options though.

Comments, Keywords and Window color seem OK.
Definitions I wanted Red, but get Blue.
Text color I wanted pale cyan, but it stays black.
Constants I tried for purple, but I get a dark cyan
Punctuation is a sort of brownish shade.

All I've got to do now is figure out what to do with it .. :)

best wishes,

Graham

Tomorrow may be too late ..

Zen

Me too graham. Ive only ever used IBasic before. So moving to somehing like this should be a fun learning curve.

But i want to expand my programming skills, so better way than something Paul made :D

Lewis

Ionic Wind Support Team

Lewis,
Is you class named 'test' or 'myclass'?

What is the contents of your inlcude file?

test MyClass

Will look for a class definition of 'test'

class test
{
...
}

MyClass test

Will look for a class definition of 'myclass'

class MyClass
{
...
}


And your variable name would be 'test' then.

test.SetData

A class is just a glorified UDT (struct) which includes member functions as well as variables. 

Paul.
Ionic Wind Support Team

Ionic Wind Support Team

Your also getting a syntax error on line 1.  Which could mean you have an error in your include file.
Ionic Wind Support Team

Ionic Wind Support Team

Quote from: GWS on November 10, 2005, 02:23:50 PM
Yippee! .. I got mine .. :)

Installation runs fine on Win98SE.  Got problems with setting the Editor Options though.

Comments, Keywords and Window color seem OK.
Definitions I wanted Red, but get Blue.
Text color I wanted pale cyan, but it stays black.
Constants I tried for purple, but I get a dark cyan
Punctuation is a sort of brownish shade.

All I've got to do now is figure out what to do with it .. :)

best wishes,

Graham



The editor options are not fully 'wired' in yet.  Scintilla doesn't distiguish between keywords and variable type colors.  It does have colors for strings and numeric constants though.

Paul.
Ionic Wind Support Team

Parker

The problem with Lewis's include file was it had a variable named 'input' which is a pre-defined function. It gave a whole lot of weird errors, which is expectable by the alpha, but it might be something to look into.

There was a line in the class "Test" that said
declare SetData(string input);
changed to
declare SetData(string _input);
one line said
Test :: SetData(string input)
changed to
Test :: SetData(string _input)
the last one said
data = input;
changed to
data = _input;

with those modifications it all works.
Another problem I've had is where the subroutine's opening bracket can't be on the same line. For example,
global sub main()
{
works, but global sub main() { doesn't. If this bug doesn't occur in all cases I'll see if I can find the file that was giving the error.

Ionic Wind Support Team

Parker,
Don't worry.  All will be resolved soon.

Paul.
Ionic Wind Support Team

Zen

Nope, that didnt solve it.

Here is my include file

//#################\\
// Main Data Class \\
//#################\\

class Test {

declare GetData(),string;
declare SetData(string indata);

string data;

}

//################################\\
// Class Function To Get The Data \\
//################################\\

Test :: GetData(),string
{

return data;

}

//################################\\
// Class Function To Set The Data \\
//################################\\

Test :: SetData(string indata)
{

data = indata;

return;

}


And here is my main source file

#include "file2.inc"

//#################\\
// Main Subroutine \\
//#################\\

global sub main()
{

Test myClass;

writeln("Hello World\n\n");

myClass.SetData("Test Data");

writeln(myClass.GetData());

while getkey() = "";

return 0;

}


Changed the things Parker said just incase something was conflicting.

Lewis

Parker

Got it. Add a new line to the end of the include file. Don't know why it works, but it does.

Ionic Wind Support Team

Because the lexer treats a right brace followed by a newline as an individual token.  There is always a reason and being an alpha release there are a lot of these little parser gotchas that are just in there to make it compile.

Already fixed for the next update.

Ionic Wind Support Team

Zen

Ok i dont know if this is just my lack of skill with other languages but IBasic or a bug so ill post it anyway.

When i create a class with a constructor in the same file as the main subroutine, the constructor function gets called ok and does its job. However when i place the class in another source file and copy the class declarations into my main source file i get the following compile error:

Compiling...
Main.src
D:\Script Engine\Source Code\CGI\Main.src:12: error: symbol `myclass@myclass' undefined
D:\Script Engine\Source Code\CGI\Main.src:36: error: phase error detected at end of assembly.
Error(s) in assembling "D:\Script Engine\Main.asm"
Class.inc

Lewis

Ionic Wind Support Team

It looks like your trying to add 'class.inc' to the project.  Include files should only be used with the #include statment.

For example suppose you had a class called 'myclass' which is defined, but not implimented, in 'myclass.inc'


//myclass.inc

class myclass
{
declare myclass();
declare function1(),int;
declare function2(),int;
}


Then the implimentation is in 'myclass.src'


//myclass.src
#include "myclass.inc"

myclass::myclass()
{
//perform any construction needed
return;
}

myclass::function1()
{
return;
}

myclass::function2()
{
return;
}



Then finally your main.src file only needs to include 'myclass.inc'


//main.src
#include "myclass.inc"

global sub main()
{
myclass m;
m.function1();
m.function2();
return;
}


Your project would have two source files.  'myclass.src' and 'main.src'

Get it?

Paul.
Ionic Wind Support Team

Zen

Oh ok i understand now. I thought you could use it just like you would with global subroutines. It all worked fine untill i added the constructer to the class definition.

Thanks for the explanation Paul. Just one more thing. Say i have a class method which takes a paramater ( lets say var1 ) and there is a class global variable named the same. How would you define which one you want to use?


class something {

declare somefunction(string var1);

string var1;

}

something :: function1(string var1) {

/* DO SOMETHING */

retrurn;

}


Thanks
Lewis

Zen

Nope, still seem to be getting the same error. I've done exactly what you said but its not working.

Quote
symbol 'myclass@myclass' undefined

Ionic Wind Support Team

OK I will look into it.  Probably some obscure bug that I missed ;)

As for your previous question...you shouldn't be able to define a parameter variable the same name as a class member variable.  Just don't have the error message in there.  In anyevent scope is local->parameter->member->global. 

When designing classes I always use a prefix of 'm_'  for all class member variables.  It helps to identify them and avoids name conflicts. I also use a designator for the type such as:

int m_iCount;
string m_strName;
double m_dValue;

So when I come back to the code years later I know that m_iCount is an integer variable that is a member of a class.

Paul.



Ionic Wind Support Team

Ionic Wind Support Team

Fixed it. New download available shortly.
Ionic Wind Support Team

Zen

Thanks Paul. I was just wondering if it was possible. I still use siimilar coding standards to the ones you described as it does make it a lot easier to find you way around your code.

Ive made plenty of mistakes naming variables silly names.

Lewis

Zen

This code caused a parser/compiler crash. It compiles ok if you remove the if statement.


pointer node;
HEADER_INFO *Item;

for (node = ListGetFirst(HeaderList); node <> 0; node = ListGetNext(node)) {

Item = ListGetData(node);

if *Itemp.value <> "" {

writeln(*Item.key + ": " + *Item.value + "\n");

} else {

writeln(*Item.key + "\n");

}

}

writeln("\n");


Lewis