Skip to main content.
IBAN   NL79 ABNA 0477 3565 08
EU-VAT NL170160656B01
Chamber of Commerce 32041148
http://www.compuphase.com
Eerste Industriestraat 19-21
1401VL  Bussum
tel. +31 35 693 9261
info@compuphase.com
CompuPhase

The Small language forum - message archive for 2003 (up to August 2003)

 

[604] check bounds bug?

Posted By chop on January 06, 2003 at 02:41:50:

Hi.

I found a bug in runtime checking of bounds.

For example,

> main()
> {
> new b[100];
> new a[100];
> for( new i=0 ; i<1000 ; i++ )
> {
> printf( "change a[%d]^n", i );
> a[i] = i;
> }
> }

this script raise runtime error when the loop runs 101 times.
log is this.

change a[0]
change a[1]
change a[2]
change a[3]
change a[4]
change a[5]
:
:
:
change a[92]
change a[93]
change a[94]
change a[95]
change a[96]
change a[97]
change a[98]
change a[99]
change a[100]
change a[101]
Run time error 4 on line 10

Run time: 0.00 seconds

I think, this error should be raised when loop runs 100 times.
Is this a bug?

Thanx.


[605] Scope Error at compile

Posted By liveikis on January 06, 2003 at 16:55:10:

This compiles:
UTestVar()
{
new flang;
}

UTestOutOfScope()
{
flang = 4;
}

The small docs clearly state that a variable declared with new has its scope within a compound statement only, in this case...the functions itself. Why does this compile??

Thanks
-el


[606] Re: check bounds bug?

Posted By Thiadmer Riemersma on January 07, 2003 at 03:04:02:

In Reply to: check bounds bug? posted by chop on January 06, 2003 at 02:41:50:

: I think, this error should be raised when loop runs 100 times.
: Is this a bug?

Probably. I will look into it. Thank you for the report.
Thiadmer


[607] Re: Scope Error at compile

Posted By Thiadmer Riemersma on January 07, 2003 at 03:26:05:

In Reply to: Scope Error at compile posted by liveikis on January 06, 2003 at 16:55:10:

Indeed this compiles with only warnings about unused symbols. The compiler determines that none of the two functions is used and it skips them in the compilation. As a side effect, many errors in those functions are waved.

For instance, if you compile the tine script that you gave with:

sc -a utest

(or whatever the script filename is, the important option is -a) and look at the resulting assembler file, it looks like:
;program exit point
halt 0

STKSIZE 1000

Apart from the halt instruction (which the compiler always generates), there is no code in this script. This is the result of both the functions UTestVar() and UTestOutOfScope() being skipped in the compilation. (The compiler skips functions as a form of "smart linking"; the implementation of stock functions depends on it).

No, if you would add a "main()" function to your script with:

main()
{
UTestVar();
UTestOutOfScope();
}

you will see the compiler flag error 17 (undefined symbol) at the line:
        flang = 4;

in function UTestOutOfScope().

Thiadmer


[608] Re: compiler bug?

Posted By chop on January 07, 2003 at 05:13:34:

In Reply to: Re: compiler bug? posted by chop on December 16, 2002 at 06:28:54:

How about this topic ?
Would you reply?


[609] Public string variables

Posted By Nacho on January 07, 2003 at 09:44:49:

I have several public variables that change in the host application and I use in Small scripts. But when I define a array variable (for a string), I can "see" the variable in host application.

In Small:
public const test1
public const stringtest[32]

In my host application:
amx_FindPubVar(pAMX,"test1",&cellAddr); // Works OK
amx_FindPubVar(pAMX,"stringtest",&cellAddr); // ¡¡NOT FOUND!!

¿What do I make wrong?
Nacho



[610] Re: Public string variables

Posted By Nacho on January 07, 2003 at 10:19:05:

In Reply to: Public string variables posted by Nacho on January 07, 2003 at 09:44:49:

oooohh.
I see in Archives that it's impossible.

Nacho



[611] Re: check bounds bug?

Posted By chop on January 07, 2003 at 10:54:06:

In Reply to: Re: check bounds bug? posted by Thiadmer Riemersma on January 07, 2003 at 03:04:02:

: Probably. I will look into it. Thank you for the report.
: Thiadmer

Thanx.
If possible, I hope you to teach me where I should modify to
fix the bug, simply.


[612] Re: Scope Error at compile

Posted By liveikis on January 07, 2003 at 19:00:37:

In Reply to: Re: Scope Error at compile posted by Thiadmer Riemersma on January 07, 2003 at 03:26:05:

Interesting, thanks! Here is something else that compiles, and in this case I think it's strictly a bug:

main()
{
new temp = 0;
if (temp == 1) new blah;
blah = 5;
}

This same code does NOT compile (with error:undefined symbol "blah") if "new blah;" is surrounded by brackets as in

...
if (temp == 1) {new blah;}
...

Any organization of the bracketless version will not compile i.e.:

...
if (temp == 1)
new blah;
...

and any organization of the bracketed version will compile i.e:
...
if (temp == 1)
{
new blah;
}
...

So this seems just like a parser bug not an unaccounted situation.
-liveikis


[613] Re: Public string variables

Posted By liveikis on January 07, 2003 at 19:03:13:

In Reply to: Re: Public string variables posted by Nacho on January 07, 2003 at 10:19:05:

I declare my public string arrays like so:

public STRING_HAHA[] = "Haha";


[614] Re: Public string variables

Posted By Nacho on January 08, 2003 at 04:00:51:

In Reply to: Re: Public string variables posted by liveikis on January 07, 2003 at 19:03:13:

: public STRING_HAHA[] = "Haha";

But, can yo access it from host application?

Nacho


[615] Proposal for some changes

Posted By Jeppe Oland on January 09, 2003 at 15:15:08:

Alrigth I have some proposals for changes to the implementation of the language, and I'm wondering how to go about it.

Specifically the 19 character native function name limit (and the static array) implementation is really holding me back.
Aside from that there are also the extensions I've mentioned earlier, as well as a wish for the VM to be able to execute older versions of the file format.

How does one go about making these changes while keeping the codebase shared? Is there a CVS repository? Should I just do it and then mail Thiadmer Riemersma the final files?

Thanks,
-Jeppe


[616] Re: Public string variables

Posted By Peter on January 11, 2003 at 21:25:48:

In Reply to: Re: Public string variables posted by Nacho on January 08, 2003 at 04:00:51:

p.22 of smalldoc.pdf:

"Global "simple" variables (no arrays) may be declared "public"..."

The compiler checks if the variable is an array when it creates the exported symbol table for public vars and doesn't insert the name in it if it is. So you cannot access arrays via amx_FindPubVar or amx_GetPubVar.


[617] Serious issues with multi-dimensional arrays

Posted By Stephane Denis on January 14, 2003 at 06:53:51:

In Reply to: Re: sizeof error with multi-dimensional arrays posted by Peter on December 07, 2002 at 17:13:00:

Yes; I also found some other issues

Try this piece of code (copy paste into a .SMA file and compile)

/// Begin code
#include <core>
new  b[4][5] = {
{ 1, 2, 1, 55, 5 },
{ 3, 4, 1, 24, 6 },
{ 5, 6, 1, 55, 7 },
{ 5, 6, 1, 55, 8}
}
// End code

will produce an Assertion failed: litidx == 0 in sc4.c, line 51

Changing into

/// Begin code
#include <core>
new  b[4][5] = {
{ 1, 2, 1, 55, 5 },
{ 3, 4, 1, 24, 6 },
{ 5, 6, 1, 55, 7 },
{ 5, 6, 1, 55, 8}
}
public tmp()
{
}
// End code

Fix the crash .. (instead of displaying "error 055: start of function body without function header)

2nd error : using large arrays:

// BEGIN CODE ////////////////
#include <float>
#include <common>
new Float:values[2][8] =
{
{-2454.0, 4786.0, 2921.0,        305.0, -771.0, 389.0,        64.0,        206.0},
{-2417.0, 4774.0, 2922.0,        313.0, -797.0, 389.0,        64.0,        206.0}
};
public tmp()
{
}
// END CODE

Will compiles.

now, change new Float:values[2][8] into new Float:values[4][8].
It will still compiles.

changes new Float:values[2][8] into new Float:values[5][8] appears a warning (??): "expected token ";" but found "-identifier"

changes new Float:values[2][8] into new Float:values[6][8] : The warning has dissappeared (?) but compiler asserts in line 51, sc4.c (litidx==)

Basically with more that 7 rows in an array, the compiler crashes.

(tested with SC 2.1.0)


[618] Re: Proposal for some changes

Posted By Stephane Denis on January 14, 2003 at 07:29:58:

In Reply to: Proposal for some changes posted by Jeppe Oland on January 09, 2003 at 15:15:08:

: Specifically the 19 character native function name limit (and the static array) implementation is really holding me back.
: Aside from that there are also the extensions I've mentioned earlier, as well as a wish for the VM to be able to execute older versions of the file format.

Easy to do: change in amx.h, line 110,
#define sEXPMAX 19
into
#define sEXPMAX 63

Hopefully, script compiled with still be backwards compatible.
For older version of script, just.. recompile the SMA files ?!




[619] Re: Serious issues with multi-dimensional arrays

Posted By Stephane Denis on January 14, 2003 at 10:05:01:

In Reply to: Serious issues with multi-dimensional arrays posted by Stephane Denis on January 14, 2003 at 06:53:51:

in previous mail (due to a limitation of this web form), the #include are

1st compiler error
#include 'LESSTHANCHARACTER'core'GREATERTHANCHARACTER'

2nd compiler error
#include 'LESSTHANCHARACTER'core'GREATERTHANCHARACTER'
#include 'LESSTHANCHARACTER'float'GREATERTHANCHARACTER'

By the way, using large array with default compression 'asserts' in amx.c

static void expand(unsigned char *code, long codesize, long memsize)

the SPARESIZE = 32 seems to be too small.
assert(scI had to add a new pragma '#pragma compression 0' in order to disable the code compression (sc_compress in sc4.c)


[620] Re: Proposal for some changes

Posted By Jeppe Oland on January 15, 2003 at 14:08:42:

In Reply to: Re: Proposal for some changes posted by Stephane Denis on January 14, 2003 at 07:29:58:

: : Specifically the 19 character native function name limit (and the static array) implementation is really holding me back.
: : Aside from that there are also the extensions I've mentioned earlier, as well as a wish for the VM to be able to execute older versions of the file format.

: Easy to do: change in amx.h, line 110,
: #define sEXPMAX 19
: into
: #define sEXPMAX 63

: Hopefully, script compiled with still be backwards compatible.
: For older version of script, just.. recompile the SMA files ?!

Well see thats exactly the problem - one of them :-)
First of all - the latest AMX core can only run code from that version. I have some old compiled code that I would still like to run. As far as I can tell the main problem is that the header is different - but it should be possible to mangle data around so that the new AMX core can still execute it.

Also - when you change sEXPMAX it becomes completely incompatible with anything. Everuthing inside the AMX core references the array of functions directly - so you have to match on the compiler/VM sizes. (Also - the larget the size the more inefficient the memory usage. I was somewhat surprised to see that a language called "Small" expands every < 1byte opcode to a 4byte integer)

So thus the question.
Say I was going to re-implement a ton of stuff in the AMX engine/compiler ... how would I get that stuff merged in with the normal releases?

-Jeppe


[621] Re: Proposal for some changes

Posted By chop on January 16, 2003 at 21:24:17:

In Reply to: Re: Proposal for some changes posted by Jeppe Oland on January 15, 2003 at 14:08:42:

: : : Aside from that there are also the extensions I've mentioned earlier, as well as a wish for the VM to be able to execute older versions of the file format.

I'v tried this. but it was difficult.
First, amx file header format have been changed, so I wrote
a converter that convert a older amx header to new. this
is possible.

Second, [function return] opecode's behavior have been changed,
so it was impossible to write a converter. The only one way is,
modify the behavior of [function return] opecode, to fit
older version, or link two version of amx engine ( fortunately,
amx engine is small enough. )



[622] Re: Proposal for some changes

Posted By Jeppe Oland on January 17, 2003 at 13:55:59:

In Reply to: Re: Proposal for some changes posted by chop on January 16, 2003 at 21:24:17:

: I'v tried this. but it was difficult.
: First, amx file header format have been changed, so I wrote
: a converter that convert a older amx header to new. this
: is possible.

Yes that was my first plan ... and now that I see somebody else has done it I would much rather not do it but get a new version from somewhere :-)

: Second, [function return] opecode's behavior have been changed,
: so it was impossible to write a converter. The only one way is,
: modify the behavior of [function return] opecode, to fit
: older version, or link two version of amx engine ( fortunately,
: amx engine is small enough. )

Oh I didn't see that ... what version file format behaves differently? Maybe just supporting versions back to there (4/5/6) would be a good starting point.

-Jeppe


[623] are anyone have smallkit ver 1.8.3

Posted By chop on January 18, 2003 at 06:07:49:

Hi.

I need the smallkit 1.8.3, but I've lost.
Are there the files of smallkit 1.8.3 ?
I'm looking for source package and windows binyary package.

Can someone give me those files?
If possible, could you upload those files, Thiadmer ?


[624] Re: Proposal for some changes

Posted By chop on January 18, 2003 at 06:14:00:

In Reply to: Re: Proposal for some changes posted by Jeppe Oland on January 17, 2003 at 13:55:59:

: Yes that was my first plan ... and now that I see somebody else has done it I would much rather not do it but get a new version from somewhere :-)

OK, I'll send you it.
but It'll be Monday. Please wait till then.

: Oh I didn't see that ... what version file format behaves differently? Maybe just supporting versions back to there (4/5/6) would be a good starting point.

See changes.txt, about this modification is written in it.




[625] Re: Serious issues with multi-dimensional arrays

Posted By Joe Hansche on January 20, 2003 at 07:04:35:

In Reply to: Serious issues with multi-dimensional arrays posted by Stephane Denis on January 14, 2003 at 06:53:51:

: Yes; I also found some other issues

: Try this piece of code (copy paste into a .SMA file and compile)
: /// Begin code
: #include

: new b[4][5] = {
: { 1, 2, 1, 55, 5 },
: { 3, 4, 1, 24, 6 },
: { 5, 6, 1, 55, 7 },
: { 5, 6, 1, 55, 8}
: }

: // End code

: will produce an Assertion failed: litidx == 0 in sc4.c, line 51

: Changing into

: /// Begin code
: #include

: new b[4][5] = {
: { 1, 2, 1, 55, 5 },
: { 3, 4, 1, 24, 6 },
: { 5, 6, 1, 55, 7 },
: { 5, 6, 1, 55, 8}
: }

: public tmp()
: {
: }
: // End code

Perhaps the fact that you didn't end your array definition with a semi-colon has something to do with it?


[626] Type conversation operators

Posted By Felix Kollmann on January 20, 2003 at 17:18:19:

Hi,

is it possible to define operators for type conversation?

e.g.

var MyType1:test1;
var MyType2:test2;

native MyType2:Convert (const MyType1:in);

stock MyType2:operator MyType2 (const MyType1:in)
return Convert (in);

test2= test1; // automatically uses MyType2 operator with source type MyType1

Is this supported?

cu
Felix


[627] Re: Type conversation operators

Posted By Thiadmer Riemersma on January 23, 2003 at 10:48:28:

In Reply to: Type conversation operators posted by Felix Kollmann on January 20, 2003 at 17:18:19:

Type conversion operators are not supported. You will need to explicitly convert from one type to another via a function call.

Thiadmer


[628] Re: are anyone have smallkit ver 1.8.3

Posted By Stephane Denis on January 23, 2003 at 15:55:09:

In Reply to: are anyone have smallkit ver 1.8.3 posted by chop on January 18, 2003 at 06:07:49:

: I need the smallkit 1.8.3, but I've lost.
: Are there the files of smallkit 1.8.3 ?
: I'm looking for source package and windows binyary package.

: Can someone give me those files?
: If possible, could you upload those files, Thiadmer ?

Just get the 2.0 version ? why do you want to stay with 1.8.3 ?


[629] Re: are anyone have smallkit ver 1.8.3

Posted By chop on January 23, 2003 at 19:52:46:

In Reply to: Re: are anyone have smallkit ver 1.8.3 posted by Stephane Denis on January 23, 2003 at 15:55:09:

: Just get the 2.0 version ? why do you want to stay with 1.8.3 ?

Because I'm using version 1.8.3, so I want to keep original
packages.


[630] Re: problem registering native functions

Posted By Tony on January 24, 2003 at 04:10:23:

In Reply to: Re: problem registering native functions posted by Matthaeus Schimmerl on June 04, 2002 at 11:11:19:

: after calling amx_Init() and this function returns AMX_ERR_NOTFOUND, you have to register native functions by calling amx_Register() until this function returns AMX_ERR_NONE. Once this function has returned AMX_ERR_NONE, you can call amx_Exec() or amx_Ececv().

: Matthäus Schimmerl


No, reread the question: It is amx_Init() that is generating the error, its not getting past Init() to be able to do anything if custom natives are used. I am having this problem also.


[631] amx_Init() problem

Posted By Tony on January 24, 2003 at 04:13:46:

amx_Init() is returning error 19, AMX_ERR_NOTFOUND, when I make my own include file and call the function I included. Any ideas why this is happening?


[632] Re: are anyone have smallkit ver 1.8.3

Posted By Thiadmer Riemersma on January 24, 2003 at 05:43:27:

In Reply to: are anyone have smallkit ver 1.8.3 posted by chop on January 18, 2003 at 06:07:49:

I have uploaded version 1.8.4, because I happened still to have that version in a ZIP archive. See the link at the end of this message.

To the best of my knowledge, version 1.8.4 is fully compatible with 1.8.3; only minor features and bug fixes were added.

Thiadmer


[633] Re: amx_Init() problem

Posted By Thiadmer Riemersma on January 24, 2003 at 05:55:45:

In Reply to: amx_Init() problem posted by Tony on January 24, 2003 at 04:13:46:

: amx_Init() is returning error 19, AMX_ERR_NOTFOUND, [...]

Only the amx_Init() function in the AMX32.DLL returns this error code, so I assume that you are using the DLL (instead of the source file AMX.C). In the DLL, amx_Init() does more than just initializing the abstract machine: it also registers all native functions that are implemented in the DLL itself. Error 19 means that one or more native functions that are used in the script could not be resolved.

It is likely that in your script, you call a native function that the DLL does not have. So you have to implement it yourself, and pass its address to amx_Register().

Thiadmer


[634] Re: are anyone have smallkit ver 1.8.3

Posted By chop on January 26, 2003 at 11:59:31:

In Reply to: Re: are anyone have smallkit ver 1.8.3 posted by Thiadmer Riemersma on January 24, 2003 at 05:43:27:

: I have uploaded version 1.8.4, because I happened still to have that version in a ZIP archive. See the link at the end of this message.

I downloaded it.
thanks.


[635] getarg() questions

Posted By Chris Jones on January 27, 2003 at 17:34:29:

Given the following function:

foo(arg1, arg2, ...) {
printf("arg1 is %d, arg2 is %d^n", arg1, arg2);
for (new i = 0; i < numargs(); i++)
printf("arg %d is %d^n", i, getarg(i));
}

1. Why don't getarg(0) and getarg(1) return the same value as arg1 and arg2? If getarg() is not supposed to be able to access the "fixed" arguments, then why do I have to pass it '2' to retrieve the first variable argument?

2. Why don't I get the same behavior calling foo() from C code as I do calling foo() from other Small functions? I get the expected values displayed when I call foo() from another Small function. When calling foo() from my C code, arg1 and arg2 are correct, but anything retreived via getarg() is not.

Thanks,
Chris




[636] Public function's parameter count

Posted By Felix Kollmann on January 29, 2003 at 11:28:55:

Hi,

I implemented a system to register actions which will point to public Small Script functions. When registering I give the paremeter types to the registration function and when calling the action, all parameters will be converted in the given types.

For debugging, it would be very useful if I could retrieve the parameter count of a public function to ensure that at least that matches the registered function... I think Small Script will crash if I call a public function with the wrong parameter count?!?

cu
Felix


[637] Re: Get C++ help @ www.sacred.dk

Posted By kathy on January 29, 2003 at 14:33:41:

In Reply to: Get C++ help @ www.sacred.dk posted by brian on December 03, 2002 at 11:07:01:

Dear Sir,

I found your email from the C++ help website.

I was just wondering if you could please help me with below programming. I need to write this code using C++. Would you please help me. Thank you so much for your time and help. Your help is greatly appreciated.

Thanks again,

The program is as follows:

A parking garage charges a $2.00 minimum fee to park for up to three hours. the garage charges an additional $0.50 per hour for each hour or part thereof in excess to three hours. the Maximum charge for any given 24-hour period is $10.00. Assume that no car parks for longer than 24 hours at a time. I need to write a program that calculates and prints the parking charges for each of customers who parked their cars in this garage yesterday. You should enter the hours parked for each customer. The program should print the results in a neat tabular format and should calcute and print the total of yesterday's receipts. the prgram should use th function calculateCharges to determine th echarge for each customer.

Car Hours Charges

1 1.5 2.00

2 4.0 2.50

3 24.0 10.00

Total 29.5 14.50


[638] Re: getarg() questions

Posted By Chris Jones on January 29, 2003 at 18:25:16:

In Reply to: getarg() questions posted by Chris Jones on January 27, 2003 at 17:34:29:

OK, nevermind. I understand what is happening now. It appears that variable arguments are being passed by reference between the calling Small function and the called Small function (foo() in my example). However, the default convention for passing arguments from C to Small is by value. Thus getarg() is treating the values I am passing in from C as references, so I get garbage.



[639] compiler bug : error(209)

Posted By chop on February 03, 2003 at 00:58:09:

I found a compiler bug.

in function 'doreturn' in sc1.c,
there is a 'error' call,
> error(209); /* function should return a value */

but error message needs one symbol name,
> 'function "%s" should return a value'

this caused Segmentation Fault in my environment.
The right is this,
> error(209, symname ); /* function should return a value */



[640] compiler bug : for loop deletes labels

Posted By chop on February 03, 2003 at 03:40:30:

Hi,Thiadmer.

Do you remember the bug, follows ?,

> Thank you for your very precise report. This is a bug in the "for" loop, which has the nasty habbit of deleting any label that is declared at a lower scope than the "for" loop itself.
>
> I have just fixed this. If you cannot wait for the next release (it may take a few weeks):
>
> In file SC1.c, function dofor(), at line 3140, it currently reads:
>
>
> delete_symbols(&loctab,ncmp,TRUE,TRUE);
> Change the third parameter into FALSE, so it becomes:
>
>
> delete_symbols(&loctab,ncmp,FALSE,TRUE);
> Thiadmer

When smallkit was ver 1.8.3, I post this bug here,
and it seems to remain even now. Please check it out.

thanx.


[641] Bizzare float behaviour

Posted By Paul Tankard on February 07, 2003 at 07:18:03:

#include

native moveobject(Float:xpos,Float:ypos,Float:zpos) = -1;

main()
{
new Float:xposition = 0.0;
new Float:yposition = 0.0;
new Float:zposition = 0.0;

for(


[642] force sleep

Posted By chop on February 12, 2003 at 02:37:23:

Hi.

> 19/08/2002 Native functions can now also force a "sleep", simply by
> returning AMX_ERR_SLEEP.

I think the collect way of 'force sleep' is not to return AMX_ERR_SLEEP, but to amx_RaiseError( amx, AMX_ERR_SLEEP ).
Is this right?

And, opcode 'op_sysreq_pri' is currently like this,
> op_sysreq_pri:
> /* save a few registers */
> amx->cip=(cell)((u_char *)cip-code);
> amx->hea=hea;
> amx->frm=frm;
> amx->stk=stk;
> num=amx->callback(amx,pri,&pri,(cell *)(data+(int)stk));
> if (num!=AMX_ERR_NONE) {
> if (num==AMX_ERR_SLEEP) {
> amx->reset_stk=reset_stk;
> amx->reset_hea=reset_hea;
> return (int)offs;
> } /* if */
> ABORT(amx,num);
> } /* if */
> NEXT(cip);

I guess, the line
> return (int)offs;
should be fixed as this,
> return AMX_ERR_SLEEP;

Is this right?

regards.



[643] HELP : MetaSmall @ Half-Life

Posted By NOW | sh!n on February 12, 2003 at 15:07:18:

hi!
need metasmall 4 counter-strike, but i dunno wheres tha fuggin link ^^
whats the link, the exact link to download the .dll of metasmall i need ??
thX, sh!n


[644] operator []

Posted By AngelOne on February 14, 2003 at 12:49:15:

First of all Id like to congratulate everyone involved in the project; its an amazing language. Im extending my 3D engine with Small. Here's my problem:

I have a 3D Vector class: Vector3. So I added some wrappers and native extensions so I can do this:

new vec3 = Vector3Create(1.0, 1.0, 1.0);

Now the vec3 cell contains a pointer to my Vector3 instanced class. Which is Ok. The problem is how I access the members (variables) of the class. Obviously I cant do: vec3.x and I dont like the idea of having a Vector3GetX() method. So I was thinking about having an operator [] so I can do vec3[0]. Now, my question is: Is this easy to do? I mean to expand the small core to support this operator via native methods? Can anyone point me in the right direction about where should I modify code? Any other ideas or solutions about how to solve the problem?

Thanks a lot
AngelOne


[645] Compiler bug - native function names.

Posted By Jeppe Oland on February 14, 2003 at 22:08:05:

I might have found a bug in the compiler.

When the natives are exported, it seems that some are generated wrong.
Specifically the "numnatives" count is calculated from all "uNATIVE" and "uREAD" functions ... but then when the actual label is exported it skips any that don't have an alias (it doesn't skip the write).

Is this actually the needed behavior?

PS: I'm currently changing the compiler to be able to habdle variable length names - will be sahweet!


[646] Variable length functions

Posted By Jeppe Oland on February 18, 2003 at 21:36:07:

I changed the compiler and VM to support variable (no 19 character limit) length. The fix was pretty easy (although it got a bit messy since the export isn't generic for all the sections.

I also changed the VM to run with the new system (and it's backwards compatible with v6).

Any way I can share this so I don't have to reinvent the wheel when/if a new version is released?


[647] ¿Bug?

Posted By Nacho on February 19, 2003 at 11:28:37:

In line 236 of sc2.c, there is a:
ptr--;
ptr first point to first '\n' in line, and it is decremented in each while loop, but there is no check if ptr is < then line (only it checks before the while). In one moment, compiling one small script, the ptr is < then line.
The small script has a line with only a tab-char and a return line char. that it's the line that fail.

Nacho


[648] Re: Variable length functions

Posted By Felix Kollmann on February 20, 2003 at 10:03:40:

In Reply to: Variable length functions posted by Jeppe Oland on February 18, 2003 at 21:36:07:

Hi,

I would highly prefer to see this new feature included into the main source. We are only allowed to use official code for development so it would be the only way to take advantage of this feature.

cu
Felix


[649] http://sourceforge.net/projects/small/

Posted By Felix Kollmann on February 20, 2003 at 10:07:58:

Hi,

is this an authorized project? I'm wondering because the site does not contain any stuff and it's running under the GPL.

cu
Felix


[650] amx_Clone error?

Posted By Lajos Molnar on February 21, 2003 at 04:46:04:

Hi!

I will clone my VM, but with the first exec on the new vm, exit with error INIT... :(
Is my code correct?

>CompiledScriptPuffer = calloc( ModulSize, 1);
>memset(&VirtualMachine, 0, sizeof(AMX));
>AMX_Error=amx_Clone( &VirtualMachine, SourceVirtualMachine, CompiledScriptPuffer);


AMX_Error is 0!!!


[651] Re: Variable length functions

Posted By Jeppe Oland on February 21, 2003 at 11:32:06:

In Reply to: Re: Variable length functions posted by Felix Kollmann on February 20, 2003 at 10:03:40:

> I would highly prefer to see this new feature included
> into the main source. We are only allowed to use official
> code for development so it would be the only way to take
> advantage of this feature.

I very much agree - thats why I asked. It seems lots of people are reporting bugs/enhancing the compiler, but nobody is making new releases.
Not only can you not use it if it's not an official release (why I don't understand - it's not like it's perfect as it stands), but everybody would have to reapply their patches when a new release eventually comes out.

Does Thiadmer Riemersma plan to release anything?
Did somebody else take over?
Is it going to go SourceForge? (The URL you posted sounds like something else - specifically "object oriented" stands out).
Has it been dropped on the floor?

-Jeppe


[652] AMX to control TagMclaren (Tagtronic)

Posted By Manolo on February 23, 2003 at 07:15:06:

Did anyone have exit to control a tagMclaren AV processos using the TagTronic Bus??


[653] First time programming with small

Posted By Impish_Invader on March 01, 2003 at 09:55:11:

I have done little programming with C++, but I would really like to be able to program with small so that I might make my own plugins for AMX. I think CS is the greatest game ever and I serve games. I would like to be able to impliment new plugins for myself and come up with new inventive ideas. If some one could help me out, 'cause I am really lost. I have tried to look at the codes for some of the other plugins and I am blown away. I use AIM:jennendario007, or you could email me @: whiskerz007@excite.com

Thanx a lot
The Imp


[654] Re: Bizzare float behaviour

Posted By Chad on March 07, 2003 at 16:44:44:

In Reply to: Bizzare float behaviour posted by Paul Tankard on February 07, 2003 at 07:18:03:

: native moveobject(Float:xpos,Float:ypos,Float:zpos) = -1;

Why do you set it equal to -1?


[655] Re: Bizzare float behaviour

Posted By Paul Tankard on March 17, 2003 at 10:20:42:

In Reply to: Re: Bizzare float behaviour posted by Chad on March 07, 2003 at 16:44:44:

Customizing the native function dispatcher <-- read this section in the manual.


: : native moveobject(Float:xpos,Float:ypos,Float:zpos) = -1;

: Why do you set it equal to -1?



[656] Extremely minor amx.h header issue

Posted By James Haley on March 18, 2003 at 22:37:55:

I've posted here before once about my DOOM port, which is now solidly on its way to use of the Small scripting language. About the only issue I have discovered is that when compiling under DJGPP, the amx.h header attempts to use several unrecognized pragmas, including #pragma pack. For my own purposes, I've patched the header file to define AMX_NO_ALIGN when __GNUC__ is defined, added "__attribute__((packed))" to the structures, and defined __attribute__(x) to be nothing when __GNUC__ is not defined. This seems to alleviate the problem. I don't know if GNU C has started recognizing those pragmas, since my version is a bit older, but I still thought I'd let you know about this minor issue. Small rules!



[657] Re: Extremely minor amx.h header issue

Posted By James Haley on March 18, 2003 at 22:41:10:

In Reply to: Extremely minor amx.h header issue posted by James Haley on March 18, 2003 at 22:37:55:

Oops, I see that this has been posted about before, but quite a way down the forums. Sorry!


[658] Small Guide or Tutorial in German ?

Posted By Micha on March 22, 2003 at 15:36:52:

Does anybody know about an Tutorial for Small which was written in German ? I wanna Start writing in Small, but some Questions won't be answered . . .

THX


[659] Re: Compiling Srun with JIT

Posted By Brad Fidler on March 29, 2003 at 18:09:41:

In Reply to: Re: Compiling Srun with JIT posted by Brad Fidler on July 17, 2002 at 00:51:58:

Sorry if this gets confusing or whatever, but my name is Brad Fidler too. Interesting to me...
:
: I have absolutely no idea, but I should inform you that my name is also Brad Fidler.

: Cheers,
: Brad

:
: : Does anyone have tips on getting srun to compile with JIT?

: : When I try to compile with BCC as described in the smallguide with
: : bcc32 -DJIT -Tm2 srun.c amx.c amxcore.c amxcons.c jits.asm
: : it complains that it does not know what VirtualProtect or PAGE_EXECUTE_READWRITE are from amx.c
: : These are defined in winbase.h so I put a include in amx.c and recompiled.
: : It really freaks out with 100+ errors like undefined indentifier DWORD, blah blah blah in winbase.h
: : Tried to compile with MSVC, exact same problems.
: : Instead of including winbase.h I included win.h from LCCWin32 which has all these prototypes.
: : (I had to fix up some lines that refer to LONG LONG as MSVC and BCC don't know what that is)
: : It compiles OK, but linking dies with 4 errors,
: : undefined reference to __assertfail in srun, amx, amxcore and amxcons.obj
: : (I think it was __assertfail or __assertfailed, can't remember right now)
: : I did a search through all the files in the AMX dir but can't find any reference to __assertfail anywhere.
: : Am I missing something?
: : Any help would be appreciated.
: : Thanks.




[660] user defined operator issues

Posted By Chad on April 04, 2003 at 19:25:30:

In the scripts we're dealing with angles where 0 is North, 90 is East, 180 is South, and -90 is West (I'm sure you can figure out the rest of the values and where they point).

So, I wrote a function for the ++ operator. Works great. If I write:

new Angle:angle = 180;
angle++;

then angle will end up being -179. Perfect. Exactly what I want (++ should change the value so as to go in a clockwise fashion). So, I then went about and created a function for the -- operator (counter-clockwise here). Here's where I have a problem. When I call the same code:

new Angle:angle = 180;
angle--;

The code runs the ++ function (the result is -179). Any ideas? I copied the code straight out of float.inc.



[661] Just Making Sure

Posted By Anon on April 11, 2003 at 18:30:53:

I just want to make sure I have this right. I can import a Small function into my C program and execute it whenever I wish


[662] Re: Just Making Sure

Posted By Orfanik on April 11, 2003 at 20:47:50:

In Reply to: Just Making Sure posted by Anon on April 11, 2003 at 18:30:53:

: I just want to make sure I have this right. I can import a Small function into my C program and execute it whenever I wish

Yes. It's true.

You can call "native" functions.

Orfanik


[663] Re: Just Making Sure

Posted By Anon on April 12, 2003 at 15:30:59:

In Reply to: Re: Just Making Sure posted by Orfanik on April 11, 2003 at 20:47:50:

: : I just want to make sure I have this right. I can import a Small function into my C program and execute it whenever I wish

: Yes. It's true.

: You can call "native" functions.

: Orfanik

Can someone point me to an example of this?



[664] Re: Just Making Sure

Posted By stephane denis on April 13, 2003 at 06:33:18:

In Reply to: Re: Just Making Sure posted by Anon on April 12, 2003 at 15:30:59:

look amxcore.c and amx_Register function.



[665] Re: operator []

Posted By Chad on April 15, 2003 at 10:45:21:

In Reply to: operator [] posted by AngelOne on February 14, 2003 at 12:49:15:

What we did is to have our GetVector() function take the script array var as a parameter like this:

//code----

native GetVector( entity, Float:vector[3] );

----code//

Then, to make it a bit more human readable, we defined the script enum VECTOR:

//code----

enum VECTOR
{
X,
Y,
Z
}

----code//


So now scripts can write:

//code----

new Float:v[VECTOR];

GetVector( v );

print( "x%f, y%f, z%f", v[X], v[Y], v[Z] );

----code//


[666] srun_jit doesn't seem to be working properly

Posted By Rui Barbosa Jr. on April 16, 2003 at 01:45:01:

Hi.
I have written a very simple benchmark small program, because I wanted:
1) To compare the performance of srun and srun_jit
2) To compare the performance of both on a P166 and a PIII 847MHz

Well, the good news is that the srun_jit runs about 25 to 26 times faster than srun.
The bad news is that the program gives different results.
I am running srun and srun_jit under a DOS box on both Win95 and WinXP.
By the way, here's the code:

#include

main()
{
printf("Hello World!");
new a = 0;
for(new i = 0; i < 1000000; i++)
{
for(new j = 0; j < 10; j++)
{
a += 1;
}
}
printf("a=%d^n", a);
}

It takes 47S to run on a P166, using srun and gives the right answer.
It takes 1.71S to run on the same P166, using srun_jit, but gives a completely wrong answer.
On the PIII 847MHz, it takes 2.7S, using srun.

What am I doing wrong?

Besides, I have not completely understood how multitasking works in small. How do I launch a thread/task?

Thanks,
/R


[667] Re: srun_jit doesn't seem to be working properly

Posted By Dan Andersson on April 18, 2003 at 20:33:18:

In Reply to: srun_jit doesn't seem to be working properly posted by Rui Barbosa Jr. on April 16, 2003 at 01:45:01:

There is an small error in the jit. The computation is done correctly. But the value shown is probably a pointer value. You can remedy it easily by adding an extra layer of indirection.

: #include

: main()
: {
: printf("Hello World!");
: new a = 0;
: for(new i = 0; i < 1000000; i++)
: {
: for(new j = 0; j < 10; j++)
: {
: a += 1;
: }
: }
: printf("a=%d^n", value(a));
: }

value (a)
{return a
}

MvH Dan Andersson


[668] Thanks --- Re: srun_jit doesn't seem to be working properly

Posted By Rui Barbosa Jr. on April 20, 2003 at 14:35:35:

In Reply to: Re: srun_jit doesn't seem to be working properly posted by Dan Andersson on April 18, 2003 at 20:33:18:

Thanks, Dan.
/R
P.S.: One thing that I have to mention is that under the XP DOS BOX, the jit worked fine.
So, I guess if I use srun_jit under a real 32 bit DOS (Like DR-DOS, for instance), the code should work properly, right?
And... one more thing... how stable is srun_jit?
Can I use it as the basis for commercial development? I mean, can I trust it? It would really help if you could tell me where I can find more info about the srun_jit and probably a list of its known bugs/issues...
Again, thank yhou so much.

: There is an small error in the jit. The computation is done correctly. But the value shown is probably a pointer value. You can remedy it easily by adding an extra layer of indirection.

: : #include

: : main()
: : {
: : printf("Hello World!");
: : new a = 0;
: : for(new i = 0; i < 1000000; i++)
: : {
: : for(new j = 0; j < 10; j++)
: : {
: : a += 1;
: : }
: : }
: : printf("a=%d^n", value(a));
: : }

: value (a)
: {return a
: }

: MvH Dan Andersson



[669] Any improvements in the AMX abstract machine?

Posted By Rui Barbosa Jr. on April 20, 2003 at 18:02:23:

Any new compilers for it?
How stable is it?
Any hadrware implementations availlable?
Who is currently maintaining the abstract machine?
Is it available for MenuetOS?
And DR-DOS?
Thanks,
/R


[670] Re: DLL's?

Posted By monimer on April 28, 2003 at 17:07:49:

In Reply to: Re: DLL's? posted by robert harris on March 25, 2002 at 07:30:53:

: : : I'm wondering if it's possible to link to C++ dll files and use their functionality in the Small language, if so how? Thanks in advance.

: : I have included a general purpose DLL call function in the DLL versions of the abstract machine; the function is called "calldll()". It is not very well documented, and the corresponding loaddll() and freedll() functions are still missing. I made the function mostly because I needed a quick function to call any Win32 API function and the USER, KERNEL and GDI modules are already loaded for a Win32 "windowed" application.

: : If you need to call specific native functions from a specific DLL, the DLL just needs to register its functions to the AMX. The readme.txt file has some information on this.

: : Thiadmer



[671] Compiler does not work

Posted By Dest on April 29, 2003 at 12:18:19:

Hi there im a totaly n00b in this shit. when i open small compiler it says PRESS SPACE TO CONTINUE i prees SPACE and dos program turns off. what do i do ?


[672] How to compile sma file

Posted By Dest on April 29, 2003 at 12:23:40:

So can you give me step by step instructions how can i compile my sma file? thanx


[673] lol

Posted By Dest on April 29, 2003 at 12:24:33:

lol


[674] Is Small development still on-going?

Posted By James Haley on April 30, 2003 at 04:32:23:

Since I haven't seen a post by Thiadmer on these forums since January, which is a very long time in net terms, I'm curious to know if he is still around and working on Small. As mentioned before, I've recently integrated Small with one of my programs and would like to keep up with any bug fixes, but without unnecessarily duplicating a lot of work that might be made obsolete by a future relase :->

I figure he may just be a really busy guy and if so, I can certainly understand that. But if he's decided to not work on Small any more, it would be good to know so that I can feel free to take it in my own direction as much as the need may be. So if anyone has any news, please share it with all of us ^_^


[675] Re: Is Small development still on-going?

Posted By Nacho on April 30, 2003 at 09:14:25:

In Reply to: Is Small development still on-going? posted by James Haley on April 30, 2003 at 04:32:23:

I've integrates Small in one of my projects too. And I want know what will happen with Small development in future (or present).

Nacho


[676] How can I stop script execution and resume it ?

Posted By jpl on May 02, 2003 at 03:38:02:

Hi !

I've integrated the small language in my project, and I need to pause the execution of a script each opcode or chunk of the bytecode, and resume it after, here is the code I wrote and it crashes after the second "resume" :

-------------------------------------------------------------------

#include "dll.h"
#include "amx.h"

#include
#include
#include

size_t memsize;
void *program;
AMX amx;
cell ret = 0;

static cell n_native(AMX *amx,cell *params) {
MessageBox (0, "Hello World from DLL!\n", "Hi", MB_ICONINFORMATION);
amx_RaiseError(amx,AMX_ERR_SLEEP);
return AMX_ERR_SLEEP;
}

AMX_NATIVE_INFO n_natives[] = {
{"myfunc",n_native},
{0,0}
};

size_t srun_ProgramSize(char *filename)
{
FILE *fp;
AMX_HEADER hdr;

if ((fp=fopen(filename,"rb")) == NULL)
return 0;
fread(&hdr, sizeof hdr, 1, fp);
fclose(fp);

amx_Align16(&hdr.magic);
amx_Align32((unsigned long*)&hdr.stp);
return (hdr.magic==AMX_MAGIC) ? (size_t)hdr.stp : 0;
}

int srun_LoadProgram(AMX *amx, char *filename, void *memblock)
{
FILE *fp;
AMX_HEADER hdr;

if ((fp = fopen(filename, "rb")) == NULL )
return AMX_ERR_NOTFOUND;
fread(&hdr, sizeof hdr, 1, fp);
amx_Align32((unsigned long *)&hdr.size);
rewind(fp);
fread(memblock, 1, (size_t)hdr.size, fp);
fclose(fp);

memset(amx, 0, sizeof *amx);
return amx_Init(amx, memblock);
}

DLLIMPORT int _stdcall LoadFile(char *filename) {
extern AMX_NATIVE_INFO console_Natives[];
extern AMX_NATIVE_INFO core_Natives[];
extern AMX_NATIVE_INFO n_natives[];
int err;

memsize = srun_ProgramSize(filename);
program = malloc(memsize);
err = srun_LoadProgram(&amx,filename,program);
//amx_Register(&amx, console_Natives, -1);
//amx_Register(&amx, core_Natives, -1);
amx_Register(&amx,n_natives,-1);
err = amx_Exec(&amx, &ret, AMX_EXEC_MAIN, 0);
if (err != AMX_ERR_NONE)
MessageBox(0,"Run time error","vm",MB_OK);
else if (ret != 0)
printf(0,"returns","vm",MB_OK);

free(program);
return 0;
}

DLLIMPORT void HelloWorld ()
{
MessageBox (0, "Hello World from DLL!\n", "Hi", MB_ICONINFORMATION);
}

DLLIMPORT void _stdcall ResumeFile(void)
{
int err;

err = amx_Exec(&amx, &ret, AMX_EXEC_CONT, 0);
if (err != AMX_ERR_NONE)
MessageBox(0,"Run time error","vm",MB_OK);
else if (ret != 0)
printf(0,"returns","vm",MB_OK);
}
-------------------------------------------------------------------

I first call the LoadFile function to start the execution, then I call a native function in my small script called "myfunc" that pause the execution of the script (using AMX_ERR_SLEEP), the I resume the execution using the "ResumeFile" function. If someone see why it crashes after the second resume ?
And better, instead of pausing the execution with a native function, I'd like to pause it every instruction, and resume it after.

Thanks a lot for your help,
Best Regards,
JPL


[678] Re: How can I stop script execution and resume it ?

Posted By chop on May 13, 2003 at 02:43:14:

In Reply to: How can I stop script execution and resume it ? posted by jpl on May 02, 2003 at 03:38:02:

Hi. i'm a user of Small too.

: I've integrated the small language in my project, and I need to pause the execution of a script each opcode or chunk of the bytecode, and resume it after, here is the code I wrote and it crashes after the second "resume" :


as i posted before,
the ope-code 'op_sysreq_pri' seems to be including a bug.

I guess, the line
> return (int)offs;
should be fixed as this,
> return AMX_ERR_SLEEP;

try this first.

: static cell n_native(AMX *amx,cell *params) {
: MessageBox (0, "Hello World from DLL!\n", "Hi", MB_ICONINFORMATION);
: amx_RaiseError(amx,AMX_ERR_SLEEP);
: return AMX_ERR_SLEEP;
: }

You don't have to return AMX_ERR_SLEEP.
( But this may not be a reason of crash. )


: And better, instead of pausing the execution with a native function, I'd like to pause it every instruction, and resume it after.

If you want to do so, you should modify amx_Exec()
so that this function checks sleep signal between
every opcode.
Or, you can use a thread. this makes your program
platform dependent. In the case of pthread,
pthread_kill( tid, SIGSTOP );
pauses the thread. And,
pthread_kill( tid, SIGCONT );
restarts the thread.



[679] Improving compiler stability

Posted By stephane denis on May 26, 2003 at 07:37:39:

I've noticed that when compiling SC.EXE in debug or in release, I don't have the same results or new errors appears.

In fact, malloc returned uninitialized memory.

I've changed all the 'malloc' into 'sc_malloc' and defined in sc.h
and sc1.c I wrote:

void *sc_malloc(size_t t)
{
void *p = malloc(t);
assert(p);
assert(t);
memset(p, 0, t);
return p;
}

This fixed a lot of issues.


[680] How know param's type?

Posted By Nacho on May 26, 2003 at 11:15:42:

In functions with variable arguments, is it possible know param's type?
For example, I need know if one argument is an array (and its dimension) or if it is an integer.

Thx.
Nacho


[681] Re: How know param's type?

Posted By chop on May 26, 2003 at 14:47:23:

In Reply to: How know param's type? posted by Nacho on May 26, 2003 at 11:15:42:

: In functions with variable arguments, is it possible know param's type?
: For example, I need know if one argument is an array (and its dimension) or if it is an integer.

I suggest that the only way to do so is do as same as printf.
In other words, get a preceding format string.



[682] scripting language?

Posted By anon on May 29, 2003 at 07:19:47:


Can some one tell me what is meant by a scripting language?
I know what is is but i dont know how to explain it on paper.


[683] Re: Small on OSX?

Posted By Porter on June 05, 2003 at 17:24:57:

In Reply to: Small on OSX? posted by squeej on February 05, 2002 at 21:18:17:

Haven't seen much activity on this topic. I had to go through a bit of work to get the source code to compile under OS X v10.2.6 with the 10.2 DevTools. Here's the process I used in very non-technical terms:

--Made sure all source files used unix line endings
--Built scpack (with "make -f makefile.linux scpack") and used to repack sc5.scp and sc7.scp
--Changed line 38 of osdefs.h from "#include " to " #include "/usr/include/ppc/endian.h"" (The compiler can't find this file on it's own it seems.)
--Removed lines 38 and 42 from sclinux.h to make sure __BYTE_ORDER and __*_ENDIAN were defined (PowerPCs are opposite-endian-ed from x86s, fyi)
--Modified CFLAGS in makefile.linux by removing "-Wall" and added "-w -no-cpp-precomp" (There are some warnings about operator && and || precendence in sc1.c)
--Used "make -f makefile.linux" to build successfully

I'm sure this could all be rolled into the distribution without much hassle. I know Apple had an environment definition (like "__WINDOWS__") to identify itself with, but I can't recall what it is. Something along the lines of __APPLE__ or __DARWIN__, but I don't think those are quite right.

Also, I don't have the facilities to properly test the resulting binary for accuracy. It may have compiled fine, but I wouldn't know the first thing about verifying it is working exactly the way it's supposed to. I'll be happy to provide any further information if needed.


[684] Small on Mac OS X?

Posted By Brian Porter on June 05, 2003 at 17:29:42:

I haven't seen any activity on this topic, so I took it upon myself to make it work. I had to go through a bit of work to get the source code to compile under OS X v10.2.6 with the 10.2 DevTools. Here's the process I used in very non-technical terms:

--Made sure all source files used unix line endings
--Built scpack (with "make -f makefile.linux scpack") and used to repack sc5.scp and sc7.scp
--Changed line 38 of osdefs.h from "#include " to " #include "/usr/include/ppc/endian.h"" (The compiler can't find this file on it's own it seems.)
--Removed lines 38 and 42 from sclinux.h to make sure __BYTE_ORDER and __*_ENDIAN were defined (PowerPCs are opposite-endian-ed from x86s, fyi)
--Modified CFLAGS in makefile.linux by removing "-Wall" and added "-w -no-cpp-precomp" (There are some warnings about operator && and || precendence in sc1.c)
--Used "make -f makefile.linux" to build successfully

I'm sure this could all be rolled into the distribution without much hassle. I know Apple had an environment definition (like "__WINDOWS__") to identify itself with, but I can't recall what it is. Something along the lines of __APPLE__ or __DARWIN__, but I don't think those are quite right.

Also, I don't have the facilities to properly test the resulting binary for accuracy. It may have compiled fine, but I wouldn't know the first thing about verifying it is working exactly the way it's supposed to. I'll be happy to provide any further information if needed.


[685] Using CodeWarrior for small scripting

Posted By -=[LS]=-AgentK. on June 05, 2003 at 20:30:36:

Hi,
Is it possible to use CodeWarrior to write Small *.Sma files???


[686] What program do you use to write/edit *.sma ?!?!?!?!

Posted By -=[LS]=-AgentK. on June 06, 2003 at 11:06:52:

What program do you use to write/edit *.sma ?!?!?!?!?!


[687] Re: What program do you use to write/edit *.sma ?!?!?!?!

Posted By Ducky on June 06, 2003 at 12:57:03:

In Reply to: What program do you use to write/edit *.sma ?!?!?!?! posted by -=[LS]=-AgentK. on June 06, 2003 at 11:06:52:

: What program do you use to write/edit *.sma ?!?!?!?!?!

Any text editor is fine. Codewarrior, like you mentioned, works as well as anything else.


[688] enum and string and array

Posted By Adam Kulagowski on June 07, 2003 at 14:37:49:

How can I declare an array with enum which contains a string ?
I want to do sth like this:

enum text { skill, color : 10 char }

static test1[1][text] =
{
{23,"string"}
};

but this does not work.

When I try to call to such array later :
printf ("%s",test1[0][color]);

all I get is

error 018: initialization data exceeds declared size

I have to decalare the content of such array in the begining not with using sprintf.

Best regards


[689] Making a Scope (Zoom) script for counter strike

Posted By -=[LS]=-AgentK. on June 07, 2003 at 16:46:17:

how would I make a zoom script for Counter Strike (like the sniper rifles with scope sprite)?


[690] Re: What program do you use to write/edit *.sma ?!?!?!?!

Posted By -=[LS]=-AgentK. on June 07, 2003 at 17:42:58:

In Reply to: Re: What program do you use to write/edit *.sma ?!?!?!?! posted by Ducky on June 06, 2003 at 12:57:03:

ya, well when I go to compile the new .sma, The compiler says ,
"assertion failed: size>=litidx, file sc1.c, line 1224
ABNORMAL TERMINATION"


[691] problem ! ! ! ! !

Posted By -=[LS]=-AgentK. on June 07, 2003 at 18:45:12:

When I go to compile the new .sma I built with CodeWarrior, The compiler says ,

"assertion failed: size>=litidx, file sc1.c, line 1224
ABNORMAL TERMINATION"

What the heck does that mean ?!?!?!?!?!?!


[692] Re: enum and string and array

Posted By Adam Kulagowski on June 07, 2003 at 18:50:32:

In Reply to: enum and string and array posted by Adam Kulagowski on June 07, 2003 at 14:37:49:

: How can I declare an array with enum which contains a string ?
: I want to do sth like this:

: enum text :{ :skill, :color : 10 char :}

The correct syntax should be:
enum text { skill, color : 10
}




[693] Div Mod (Modulo division)

Posted By agentk. on June 09, 2003 at 20:13:25:

Can some one explane how to use DivMod ?


[694] Re: Making a Scope (Zoom) script for counter strike

Posted By Florian Zschocke on June 11, 2003 at 03:15:24:

In Reply to: Making a Scope (Zoom) script for counter strike posted by -=[LS]=-AgentK. on June 07, 2003 at 16:46:17:

: how would I make a zoom script for Counter Strike (like the sniper rifles with scope sprite)?

Dude, you're so in the wrong forum for that question.


[695] Print error: smalldoc.pdf, page 18 (?)

Posted By Johnny Got His Gun on June 12, 2003 at 07:17:19:

This is part of a code on page 18 in smalldoc.pdf:

findtargets(source, steps, nextstep[], numpoints = sizeof nextstep)
{
new result = 0
new addedpoints = nextstep[source]
while (steps-- > 0 && result  addedpoints)
{
result = addedpoints
for (new i = 0; i < numpoints; i++)
if (result & 1 << i)
addedpoints |= nextstep[i]
}
return result
}

Note the strange character between result and addedpoints in the while loop. I haven't looked at what this does but I guess that could be some misprint since it won't go through the compile and well I've never seen that character in a while statement before!


[696] Décompilateur et Compilateur

Posted By astro.nomie@caramail.com on June 13, 2003 at 07:49:22:

Peux ton retrouver les chaines par décompilation d'un .amx ?

Existe t il un décompilateur de .AMX ?

Par exemple si je met des chaines dans un source, puis etre sur que le client ne trouvera pas cette chaine par décompilation ?


Exemmple simple, lors que j'edite le fichier .amx avec un editeur hexa les chaines 'bonjour' et 'Hello world' ne sont pas lisible.

Si il existe un décompilateur, peu ton retrouver les chaines initiale ?

#include

main()
{
new str1[]="bonjour";
printf("Hello world^n");
printf("chaine1 = [%s]^n", str1);

}

Le but est planquer des codes d'acces (password) dans des variable et que si l'on decompile ou edite le fichier .AMX, l'on puisse pas retrouver les chaines.

Par avance merci,
A.


[697] Re: returning string from script

Posted By Johnny Got His Gun on June 13, 2003 at 12:34:32:

In Reply to: returning string from script posted by Stephane Denis on November 29, 2002 at 12:54:00:

Ahhh... Maybe this will do the trick, I implemented one new function "copy()" that returns number of characters copied from sourcestring to destinationstring. By the way, you should know that strings are passed as reference, so you make the string some time before in the same function where you make a call to the function that you want to copy your function, and you send it your string that you made, and it will fill it with content! I guess there really is some kind of "pointers" in small, as references sure is a type of pointer!

#include
#include
main()
{
const stringSize = 10
new ourString[stringSize]
new charsCopied = setstring(0,ourString,stringSize - 1)

printf("our string is: %s (%d characters were copied)",ourString,charsCopied)
}

setstring(value,theString[],stringSize) {
new charsCopied
if (value == 0)
charsCopied = copy(theString,stringSize,"zero")
else
charsCopied = copy(theString,stringSize,"not zero")

return charsCopied
}

copy(destinationString[],maxChars,sourceString[]) {
new sourceLength = strlen(sourceString)
new i
for(i = 0;i < maxChars && i < sourceLength;i++) {
destinationString[i] = sourceString[i]
}

return i
}


[698] Re: returning string from script

Posted By Johnny Got His Gun on June 13, 2003 at 12:39:13:

In Reply to: Re: returning string from script posted by Johnny Got His Gun on June 13, 2003 at 12:34:32:

I forgot to add, that this is for returning strings. But indeed as someone already noted, if you have the strings in a global multidimensional array like you have in your example, you would be able to directly access that like he described.

new weekdays[7][] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"} // Note that you don't need to specify the size of the last dimension, hence "[]". The size of that dimension will be automatically set.

Then just access those like this:

printf("I drink beer only on %ss, %ss, %ss, %ss, %ss, %ss and %ss!",weekdays[0],weekdays[1],weekdays[2],weekdays[3],weekdays[4],weekdays[5],weekdays[6])



[699] Re: returning string from script

Posted By Johnny Got His Gun on June 13, 2003 at 13:08:21:

In Reply to: Re: returning string from script posted by Johnny Got His Gun on June 13, 2003 at 12:34:32:

Sorry, I forgot one thing, to add a terminator last thing done in copy() function. If the string you send in to copy is already something, those characters at the end will still be there if you don't put a terminate character (^0) after the real characters. Repost of code:

#include
#include
main()
{
const stringSize = 21
new ourString[stringSize] = "12345678901234567890"
new charsCopied = setstring(0,ourString,stringSize)

printf("our string is: %s (%d characters were copied)",ourString,charsCopied)
}

setstring(value,theString[],stringSize) {
new charsCopied
if (value == 0)
charsCopied = copy(theString,stringSize - 1,"zero")
else
charsCopied = copy(theString,stringSize - 1,"not zero")

return charsCopied
}

copy(destinationString[],maxChars,sourceString[]) {
new sourceLength = strlen(sourceString)
new i
for(i = 0;i < maxChars && i < sourceLength;i++) {
destinationString[i] = sourceString[i]
}
destinationString[i] = '^0'

return i
}


[700] Re: Serious issues with multi-dimensional arrays

Posted By Johnny Got His Gun on June 13, 2003 at 16:33:45:

In Reply to: Re: Serious issues with multi-dimensional arrays posted by Joe Hansche on January 20, 2003 at 07:04:35:

Semicolons aren't necessary AFAIK. Actually I don't think yuo are supposed to use them at all.


[701] Re: Warning only appears when using a switch statement

Posted By Johnny Got His Gun on June 13, 2003 at 16:41:32:

In Reply to: Re: Warning only appears when using a switch statement posted by Peter on December 02, 2002 at 21:21:38:

: Your sample looks kind of suspicious because you can't have case labels that are variable names (unless "param" is a constant, but then switching on a constant is pointless):

: switch ( param )
: {
: case param :
: DoSomething();
: default:
: DoSomethingElse();
: }

: Why don't you just paste the whole file?


Yes, in this example I guess DoSomething() will always be carried out, since param will always be param! :-D



[702] Restoring AMX data after save

Posted By Akari on June 16, 2003 at 12:57:43:

I need to save and then restore the static and global variables contained in the data segment.

I can save the data by using:
char *data = amx.base + (int)amx.base->dat;
for the start of the segment, and
amx_MemInfo() to determine the length of the data segment so I can write it out to disk.

But what would the steps be to restore the data segment?

I imagine I still need to do amx_Init() first, but what do I do after that to restore the data segment?

Thanks for any help you can provide on this.

-Akari


[703] Decompilation

Posted By Johnny Got His Gun on June 19, 2003 at 23:40:49:

Is there something to decompile amx files? Or how would I go about trying to do that?


[704] Re: srun_jit doesn't seem to be working properly

Posted By Marc Peter on June 20, 2003 at 17:23:33:

In Reply to: srun_jit doesn't seem to be working properly posted by Rui Barbosa Jr. on April 16, 2003 at 01:45:01:

Hi Rui,

sorry for the delay, but I stop by the Small home page only now and
then, to check for AMX updates.

This JIT problem is easily fixed.

In the AMX structure definition in jitr.asm and jits.asm, between the
following two lines,

_hea DD ?
_stk DD ?,

the declaration for the member hlw is missing. It must have slipped
through Thiadmers regression tests when he updated the AMX structure.

Just insert it like so:

_hea DD ?
_hlw DD ? ; <- was missing before
_stk DD ?

and everything will be working again. I mailed this to Thiadmer, so
there should be an update happening shortly.

Best regards
Marc




[705] how to find srun?

Posted By Rui on June 23, 2003 at 11:19:52:

Hello. I am new for Java. I am wondering where i can get srun.exe? I downloaded and installed the JSDK. But I could not find srun. Can anyone help me? Thanks in advance!


[706] Re: how to find srun?

Posted By Florian Zschocke on June 25, 2003 at 16:59:02:

In Reply to: how to find srun? posted by Rui on June 23, 2003 at 11:19:52:

This is the forum for the Small language. I am not sure what makes you think this is in any way related to Java?


[707] Re: amx_Clone error?

Posted By shiftless on June 25, 2003 at 17:52:26:

In Reply to: amx_Clone error? posted by Lajos Molnar on February 21, 2003 at 04:46:04:

I'm experiencing this error as well. The AMX crashes with error 22 (AMX not initialized). This is on FreeBSD with the GCC compiler and no optimizations. I would give a code sample but I'm on Windows now and don't have access to my code. If you could shoot me an email about this I would greatly appreciate it.

: Hi!

: I will clone my VM, but with the first exec on the new vm, exit with error INIT... :(
: Is my code correct?

: >CompiledScriptPuffer = calloc( ModulSize, 1);
: >memset(&VirtualMachine, 0, sizeof(AMX));
: >AMX_Error=amx_Clone( &VirtualMachine, SourceVirtualMachine, CompiledScriptPuffer);

:
: AMX_Error is 0!!!



[708] Book

Posted By Mike on July 11, 2003 at 19:07:05:

Are there any books on this language?
If yes then where can i buy them!


[709] Re: Book

Posted By Florian Zschocke on July 13, 2003 at 16:34:14:

In Reply to: Book posted by Mike on July 11, 2003 at 19:07:05:

No, there are none. What would come closest would be a book on the C language. But there is a very good manual on the Small language available for download from the Small homepage. Have you read that?


[710] Bug fixes to AMX and compiler

Posted By James Haley on July 18, 2003 at 21:05:31:

Since Small development seems totally stalled out, I've gone through all the messages on this forum from the last year and tried to round up reliable-looking bug reports. Of those so far, I have applied four fixes, three to the compiler and one to the AMX. I will release these changes soon, so that other people using Small can improve the stability/functionality of their compilers and virtual machines.

Please don't mail me with spurious questions or feature requests, though. This is not official and I'm not trying to "take over" Small development. It'll just be a sort of community service. Hopefully we can keep things alive around here.


[711] Fixes now @ http://www.doomworld.com/eternity/engine/smallfixes.txt

Posted By James Haley on July 19, 2003 at 14:46:20:

You can view my current list of Small VM and compiler bug fixes at http://www.doomworld.com/eternity/engine/smallfixes.txt


[712] Re: amx_Clone error?

Posted By Lajos Molnar on July 22, 2003 at 16:26:27:

In Reply to: Re: amx_Clone error? posted by shiftless on June 25, 2003 at 17:52:26:

Hi!

My e-mail is: orfanikkt@axelero.hu

I use Win2K + VC6 (SP5) + PPack

Thanks:
Lexx



[713] Need advice on whether or not to fix a possible bug

Posted By James Haley on July 23, 2003 at 23:57:34:

After investigating some of the complaints about multidimensional arrays in Small, I've discovered that the parser doesn't allow a comma after the last item in one- or two-dimensional arrays. I've discovered how to fix this, but I'm not entirely sure what Thiadmer's intent was toward this. However, the following things make me think that this is a bug and not intentional:

1. The last item in an enumeration can have a comma after it. This makes disallowing of commas after the last item in an array non-orthogonal, and thus undesirable.

2. This difference from C is not listed anywhere in the documentation, including most importantly, the "pitfalls" section.

3. The compiler generates non-sensical error messages which differ wildly depending on the context in which the array is in. For instance, one particular example program I have made generates this set of errors:

bigarray.sma(19) : error 001: expected token: "}", but found ","
bigarray.sma(29) : warning 203: symbol is never used: ""

The first error is correct, but the second is nonsense.

I believe that a comma should be allowed (and ignored) after the last element of arrays, but I'm open to outside opinions.


[714] Post increment bug

Posted By John on July 24, 2003 at 18:52:50:

#include
main()
{
new pos = 0
printf("%d Hello world^n", pos++ )
}

Output is "1 Hello world" which is wrong... Here is a simple work around...


#include

value( i )
return i

main()
{
new pos = 0
printf("%d: hello world^n", value(pos++) )
}

Well, it seems that to fix it compiler will have to push non array values on stack to reconcile C and Small rules...



[715] Re: Fixes now @ http://www.doomworld.com/eternity/engine/smallfixes.txt

Posted By Felix Kollmann on July 30, 2003 at 14:27:41:

In Reply to: Fixes now @ http://www.doomworld.com/eternity/engine/smallfixes.txt posted by James Haley on July 19, 2003 at 14:46:20:

Thank you very much!!! We don't have the time to make such fixes ourselves.


[716] Re: Fixes now @ http://www.doomworld.com/eternity/engine/smallfixes.txt

Posted By Nacho on July 31, 2003 at 03:41:31:

In Reply to: Fixes now @ http://www.doomworld.com/eternity/engine/smallfixes.txt posted by James Haley on July 19, 2003 at 14:46:20:

Thank you for the fixes.
Where is Thiadmer? Soon is the birdthday of the last release but no news about Small maintenance. Is it possible create a comunity to develop Small?


[717] Re: DLL entry point not found

Posted By mikle camu on August 01, 2003 at 03:55:48:

In Reply to: DLL entry point not found posted by Matthaeus Schimmerl on May 28, 2002 at 08:15:10:


hi,
wen i start all the EA games(all played in mah cd rom) i cant start it and i recieved an error (the procedure entry point_binksetvolume@12 could not be located in the dynamic link library binkw32.dll)can u pls tell it to me also wer i can find in my computer the dynamic link library so that i can copy the binkw32.dll on it or pls help me the best way i can do bout this problem. Os=windows xp
thank u very nuch.

mikle



[718] Small fix list updated

Posted By James Haley on August 02, 2003 at 17:31:14:

Marc Peter, who wrote the JIT, sent me a small fix that was posted on this forum earlier. I've added it to a new section for JIT fixes in smallfixes.txt.


[719] Re: Post increment bug

Posted By James Haley on August 02, 2003 at 17:33:22:

In Reply to: Post increment bug posted by John on July 24, 2003 at 18:52:50:

: #include
: main()
: {
: new pos = 0
: printf("%d Hello world^n", pos++ )
: }

: Output is "1 Hello world" which is wrong... Here is a simple work around...

:
: #include

: value( i )
: return i

: main()
: {
: new pos = 0
: printf("%d: hello world^n", value(pos++) )
: }

: Well, it seems that to fix it compiler will have to push non array values on stack to reconcile C and Small rules...

I'll look into this. I'm not certain if it should be considered a bug, or just a misfeature. It would probably be pretty hard to fix, knowing as little as I do about how the Small compiler works. Also, there's always issues with changing the way things work -- some people have probably relied on that behavior in the past.


[720] Re: Fixes now @ http://www.doomworld.com/eternity/engine/smallfixes.txt

Posted By James Haley on August 02, 2003 at 17:35:16:

In Reply to: Re: Fixes now @ http://www.doomworld.com/eternity/engine/smallfixes.txt posted by Felix Kollmann on July 30, 2003 at 14:27:41:

: Thank you very much!!! We don't have the time to make such fixes ourselves.

No problem. I need the fixes for my own project, so everyone else may as well benefit from them too ^_^

Let me know if you find any other problems.


[721] copy strings

Posted By Manny on August 03, 2003 at 22:08:12:

Hi, i would like to know the command to copy one string to another.

for example:
temp[]="test"
string1[]="hello"

i would want to copy temp[] to string1[]

how would i go about doing this??

thanks


[722] send/receive struct in socket with c++

Posted By Monica David on August 04, 2003 at 16:59:59:

In Reply to: Get C++ help @ www.sacred.dk posted by brian on December 03, 2002 at 11:07:01:

Hi,

I want to send struct qs{int MesgID; std::string key; int Mesgsize;}
through a socket by
send ( m_sock , buf, MAXRECV, 0);
recv ( m_sock, buf, MAXRECV, 0 );
in a socket class with methods
bool Socket::send (const qs* s) const;
int Socket::recv (qs* s) cons;

Can you tell me how to do it? Thank you.

Mon


[723] Re: Small fix list updated

Posted By Akari on August 04, 2003 at 19:21:22:

In Reply to: Small fix list updated posted by James Haley on August 02, 2003 at 17:31:14:

: Marc Peter, who wrote the JIT, sent me a small fix that was posted on this forum earlier. I've added it to a new section for JIT fixes in smallfixes.txt.

I noticed your effort to fix many of the lingering Small issues. The following are various fixes I've made to Small and the lines of code that need to be tweaked accordingly. If the format gets messed up too bad to be useful, let me know and I'll email you a text file of the changes instead sometime.

-Akari

; ---------------------------------------------------------------------------------------------------------------------------------------

NAME AND DATE:
RTaylor on 6/3/03
Description
Fixed a crasher in the compiler when it goes to report attempts at using an array in an equation. Example: somefunc( "string" + 5 )

CHANGE:
FILE AND LINE
sc3.c on lines 541
ORIGINAL CODE
char *ptr=(lval1->sym->name!=NULL) ? lval1->sym->name : "-unknown-";
NEW CODE
char *ptr=(lval1->sym != NULL) ? lval1->sym->name : "-unknown-";

CHANGE:
FILE AND LINE
sc3.c on line 544
ORIGINAL CODE
char *ptr=(lval2->sym->name!=NULL) ? lval2->sym->name : "-unknown-";
NEW CODE
char *ptr=(lval2->sym != NULL) ? lval2->sym->name : "-unknown-";

; ---------------------------------------------------------------------------------------------------------------------------------------
NAME AND DATE:
Rtaylor on 7/9/03
DESCRIPTION
Made it so that local static variables are passed to the debug hook. Before
only global vars were being passed, though the debug 'docs' indicated that
both should be.
CHANGE:
FILE AND LINE:
amx.c on line 538
ORIGINAL CODE:
last_sym_global = (amx->dbgparam >> 8)==0;
NEW CODE:
last_sym_global = (amx->dbgparam >> 8)==0 || (amx->dbgparam >> 8) == 2;

; ---------------------------------------------------------------------------------------------------------------------------------------
NAME AND DATE:
Rtaylor on 7/9/03
DESCRIPTION:
Fixed a number of minor errors with how the AMX was handling the SLEEP/RESUME support.
It was documented as working, but there were several small problems with checks missing
to handle saving the state correctly so that it could resume from where it left off.
CHANGE:
FILE AND LINE:
amx.c on line 1955
ORIGINAL CODE:
return (int)offs;
NEW CODE:
return AMX_ERR_SLEEP;

CHANGE:
FILE AND LINE
amx.c on line 2893
ORIGINAL CODE:
return (int)offs;
NEW CODE:
return AMX_ERR_SLEEP;

CHANGE:
FILE AND LINE:
amx.c starting on line 2908
ORIGINAL CODE:
if ( num != AMX_ERR_NONE )
NEW CODE:
if ( num == AMX_ERR_SLEEP ) {//Need to handle SLEEP different than other errors. - rtaylor
amx->reset_stk = reset_stk;
amx->reset_hea = reset_hea;
return AMX_ERR_SLEEP;
} else if (num!=AMX_ERR_NONE)

CHANGE:
FILE AND LINE:
amx.c starting on line 2923 (line number after the previous CHANGE that inserted a few lines )
ORIGINAL CODE:
if ( num != AMX_ERR_NONE )
NEW CODE:
if ( num == AMX_ERR_SLEEP ) {//Need to handle SLEEP different than other errors. - rtaylor
amx->reset_stk = reset_stk;
amx->reset_hea = reset_hea;
return AMX_ERR_SLEEP;
} else if (num!=AMX_ERR_NONE)

CHANGE:
FILE AND LINE:
amx.c inserted a line at 2940 (line number AFTER the new lines of code inserted in previous 2 changes
NEW CODE:
amx->cip=(cell)((u_char *)cip - code );

CHANGE:
FILE AND LINE:
amx.c stating at 2946 (line # after all the previous inserts listed above)
NEW CODE:
if ( num == AMX_ERR_SLEEP ) {
amx->reset_stk = reset_stk;
amx->reset_hea = reset_hea;
return AMX_ERR_SLEEP;
}


[724] Re: packed strings little endian

Posted By sara on August 04, 2003 at 20:26:37:

In Reply to: Re: packed strings little endian posted by Thiadmer Riemersma on October 29, 2002 at 05:13:29:

: : Before I go trying to modify the small C compiler so that packed strings are in a nicer memory layout on a little endian machine, is there anything non-obvious I should watch out for that depends on the old memory layout?

: The reason I did this was that I needed a way to distinguish packed strings from unpacked strings. If Small stored the first character in the lowest 8 bits of a cell, one could not determine for a string with a length of 1 character whether it was packed or unpacked. This would be a serious problem, because in that case a (native) function would not know whether to check for a zero character to mark the end of the string or a zero cell.

: C solves a simlar problem (with "wide" characters versus normal characters) with its type system. Small could do the same with tagnames. The type system, however, often leads to duplication of code. An example of this is the Microsoft Windows API:
:

CreateWindowA   CreateWindowW

: The reason why Windows needs two functions is because the CreateWindow() function has two string arguments. C++ can hide this via function overloading, C can hide it (somewhat) via macros, but the type system by itself does not allow you to hide this split personality. In Small, it is fairly easy to create a function that accepts both kinds of strings and that even accepts a mix of packed and unpacked strings.

: Thiadmer



[725] Re: Small fix list updated

Posted By James Haley on August 08, 2003 at 03:39:50:

In Reply to: Re: Small fix list updated posted by Akari on August 04, 2003 at 19:21:22:

Thanks for posting this. Although, on trying to find the locations for fixes to the sleep/resume code, it appears that most of those fixes are either already applied, or your solutions are more round-about than necessary. In one case where you change the return of (int)offs to that of AMX_ERR_SLEEP, the values are equal because the error code is being tested from offs. In two or three of the cases, there are already if's inside the test for "num != AMX_ERR_NONE" that check if num == AMX_ERR_SLEEP, then if so, set the two fields from your code and return (int)offs -- although perhaps they do need to return AMX_ERR_SLEEP in those cases, because it doesn't look like num is equal to (int)offs there. If you can send me any additional information, I'd be happy to check it out because I might just be confused. More context surrounding the changed lines would be particularly useful, because our line numbers are off by about 10 or 15.


[727] modifying small

Posted By fathom on August 13, 2003 at 23:51:13:

believe it or not, small is just not small enough for me. i'm just now settling in on a scripting/expression language and i think small is the closest thing to what i need, but i'm wondering if it's possible (read "easy") to adjust small to better suit my needs.

basically, i'm looking to do a few things.

1. i'd like to take an expression as typed by the user of my application and run it a bunch of times (like thousands. each iteration i would adjust variables based on the application data. it seems like i'd need to turn this simple expression into a simple program by appending the appropriate includes and program syntax before passing it onto the compiler. is that a reasonable approach? essentially, i'd end up running a small compiled program that does something trivial like add 10 to a variable. only i'd run it thousands of times.

2. i'd like to allow my users to write their own functions for these expressions. generally, they'd be simple math functions -- no strings, no I/O, no windows. just math, flow control, and custom functions related to my app. as such, i'd like to simplify the code. as such, things like global variables, defining types, over-loading operators, etc. don't make a lot of sense. can they be "turned off" in an easy manner?

3. i've seen reference to a vector library. is that standard or is it available somewhere else?

thanks!


[737] Re: Small fix list updated

Posted By Jeppe Oland on August 22, 2003 at 01:32:13:

In Reply to: Small fix list updated posted by James Haley on August 02, 2003 at 17:31:14:

I just had another crash bug in the compiler.

File: sc2.c
Function: static int command(void)

tag is not initialized when compiling
#if defined _Bleh_inc
#endinput
#endif
#define _Bleh_inc

And the compiler will *sometimes* crash.

Initializing 'tag' to 0 at the top of the function seemed to fix it - but I'm not sure what 'tag' really is. Anybody?

-Jeppe


[738] Re: Small fix list updated

Posted By Jeppe Oland on August 23, 2003 at 21:54:40:

In Reply to: Re: Small fix list updated posted by Jeppe Oland on August 22, 2003 at 01:32:13:

>: Initializing 'tag' to 0 at the top of the
>function seemed to fix it - but I'm not sure
>what 'tag' really is. Anybody?

Well ... it ran for a day or so but now it's crashing again.
Damned crappy compiler :(

-Jeppe


[741] When did this turn into a spam board? I hope you idiots get sued for abusing a corporate website.

Posted By James Haley on August 24, 2003 at 23:49:23:

I hope Thiadmer comes back and sues you freaks for using his corporate website to advertise your rip-off crap.


[743] Re: compiler bug?

Posted By Jeppe Oland on August 25, 2003 at 19:28:30:

In Reply to: Re: compiler bug? posted by Thiadmer Riemersma on December 16, 2002 at 05:18:58:

>> But, before calling 'refer_symbol', sym->numrefers is modified
>> in the function 'operatoradjust', as this,

>>> sym->numrefers=oldsym->numrefers;

>> I guess, without realloc of sym->refer, this line causes
>> invalid memory access, and adding unknown refers.
>> Is this right ?

> The "numrefers" field is part of the symbol structure. It
> is not part of the memory block that is reallocated. The
> loop in operatoradjust() avoids adding "NULL" as referrer
> and refer_symbol() avoids adding duplicates.

> In my opinion, the code is correct. Did you experience a crash?

I just spent a while looking for a nasty crash related to this exact problem. Chop was right - the code is broken - and pretty badly too!

See post in thread "Small fix list updated".

-Jeppe


[744] Re: Small fix list updated

Posted By Jeppe Oland on August 25, 2003 at 19:50:42:

In Reply to: Re: Small fix list updated posted by Jeppe Oland on August 22, 2003 at 01:32:13:

: I just had another crash bug in the compiler.
: And the compiler will *sometimes* crash.

Ok ... I spent a full day tracking this problem after my hack the other day didnt' work.

The problem is exactly what "Chop" was talking about last year.

The assignment of sym->numrefers from oldsym->numrefers is invalid because oldsym can have more entries than sym, and therefore the array is too small. But the real problem is that the loop is done on sym->numentries ... I had a case where sym->numentries was 1, and oldsym->numentries was 2. The assignment makes sym->num 2, and the loop starts. The first "refer_symbol" call wants to add an entry to the symlist, so now the count goes to 4 - and now there will be 2 bogus calls to refer_symbol using bogus pointers from oldsym!

Fix is as follows: replace between the two /* if */ around line 1872 in sc1.c

} /* if */
sym->usage|=oldsym->usage; /* copy flags from the previous definition */
/* JOland: Changed it so that it does not reassign sym->numreferrers.
Looks like he wants to add all the old sym's referrers to the new one,
But looping around on sym->numreferrers is not safe since refer_symbol changes the count! */
for (i=0; inumrefers; i++)
if (oldsym->refer[i]!=NULL)
refer_symbol(sym,oldsym->refer[i]);
delete_symbol(&glbtab,oldsym);
} /* if */

-Jeppe


[766] Re: When did this turn into a spam board? I hope you idiots get sued for abusing a corporate website.

Posted By Florian Zschocke on August 27, 2003 at 13:35:16:

In Reply to: When did this turn into a spam board? I hope you idiots get sued for abusing a corporate website. posted by James Haley on August 24, 2003 at 23:49:23:

The bad thing is that nobody is left to take care of this kind of shit. Sad.