From ben at versaccounting.com Fri Aug 5 14:48:58 2005 From: ben at versaccounting.com (Ben Duncan) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] SLAG update and information. Message-ID: <42F3B49A.6040007@versaccounting.com> Ok, first kudo's for Paul for writing the tdb interface. Unfortunately I have discovered a severe limit in tdb in that it allows only one open for each file per process ID. Accounting programs usually can and do have the files open multiple times (And A/R aging routine is a prime example). For news, The "versaccounting" group I belong to has decided NOT to renew it's Appgen VAR status. I have a contract with the Mississippi Department of Wildlife, Fisheries and Parks for support of the AppGen system they have in their central distribution center (handles all in bound and out bound inventory and stores). It WAS scheduled to expire in October and since I am no longer a "official" VAR of Appgen was NOT going to be renewed. However, they have renewed it thru June of 2006 with the condition that SLAG and it's applications be ready to replace it as of June 2006. Now all I have to do is come up with a embedded database engine for SLAG. I am looking at possible adapting GDBM to a Multi Value environment and use my own locking semaphore routines. Any suggestions, ideas' and other notes of interest are will always be appreciated! Thanks ... -- Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From p.boekholt at hetnet.nl Sat Aug 6 05:51:39 2005 From: p.boekholt at hetnet.nl (Paul Boekholt) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] SLAG update and information. In-Reply-To: <42F3B49A.6040007@versaccounting.com> Message-ID: <1E1LL9-03d-00@earth.cosmos.com> On Fri, 05 Aug 2005 13:48:58 -0500, Ben Duncan said: > Ok, first kudo's for Paul for writing the tdb interface. > Unfortunately I have discovered a severe limit in tdb in that it allows > only one open for each file per process ID. You can open and close a file multiple times, but you can't open it, keep it open and then open the same file again, that's right. GDBM can't do that either - actually it can on Linux, but I think it's a bug. It's probably OK to open a GDBM file multiple times read-only though. > Accounting programs usually can and do have the files open multiple > times (And A/R aging routine is a prime example). Can you expand on this? Does A/R aging open a file multiple times read-only, or read/write? > Now all I have to do is come up with a embedded database engine for SLAG. > I am looking at possible adapting GDBM to a Multi Value environment and use my > own locking semaphore routines. What OS does the Department of Wildlife use? If they use windows, you probably can't use tdb. If you need to open a file multiple times read-only in one process, then if you don't need concurrency, use GDBM. Otherwise, ask the tdb maintainers to fix it (maybe it's already fixed in the Samba version?). If you need to open a file multiple times read-write in one process, you should look for some other database. If you don't need to open a file multiple times read-write in one process, but you do need concurrency, then try to get the Department of Wildlife to switch to Linux, or try to get someone to port tdb to Windows. From ben at versaccounting.com Sat Aug 6 12:42:47 2005 From: ben at versaccounting.com (Ben Duncan) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] SLAG update and information. In-Reply-To: <1E1LL9-03d-00@earth.cosmos.com> References: <1E1LL9-03d-00@earth.cosmos.com> Message-ID: <42F4E887.4030304@versaccounting.com> That's the beauty. It IS linux based. SLAG and any work I do thereof is going to have a reverse Bill Gates Attitude - *NIX only for the Server side ;-> (I'll use some sort of thin client for Winsnot machines). Paul Boekholt wrote: >>Accounting programs usually can and do have the files open multiple >>times (And A/R aging routine is a prime example). > > Can you expand on this? Does A/R aging open a file multiple times > read-only, or read/write? > It depends. Lets say you are applying a payment on accounts in real time. First, the Payment would get posted to the file (write to file and held open in a buffer). Then you would read the AR documents it applied to as another open to the AR Open file. If it was a "receivable", apply the amount to the AR document write it out, reduce the amount available on the Payment RECORD, read the NEXT document it applied to, apply any amounts and continue this cycle until no more monies were left on the PAYMENT side and then write it back out. So in the case it would be 2 or more opens in Read Write mode, but not an exclusive FILE locking, but a Record/Row lock. ONLY exclusive file locking gets implemented in the case of BATCH updated. Say you needed to have an across the BOARD price increase in your inventory items. Then you would do an exclusive LOCK at the file level, read each and every item and update it's price, then release the FILE lock. Other times such as cross referencing (Doing a customer Lookup), the Lookup files maybe the customer file opened as read only (for starts and read next's), but the primary file is for the "UPDATE". > > >>Now all I have to do is come up with a embedded database engine for SLAG. >>I am looking at possible adapting GDBM to a Multi Value environment and use my >>own locking semaphore routines. > > What OS does the Department of Wildlife use? If they use windows, > you probably can't use tdb. If you need to open a file multiple times > read-only in one process, then if you don't need concurrency, use GDBM. > Otherwise, ask the tdb maintainers to fix it (maybe it's already fixed > in the Samba version?). If you need to open a file multiple times > read-write in one process, you should look for some other database. If > you don't need to open a file multiple times read-write in one process, > but you do need concurrency, then try to get the Department of Wildlife > to switch to Linux, or try to get someone to port tdb to Windows. > > _______________________________________________ > To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html > -- Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From ben at versaccounting.com Sun Aug 7 14:10:50 2005 From: ben at versaccounting.com (Ben Duncan) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] SLAG update and information. In-Reply-To: <1E1hSC-0Di-00@earth.cosmos.com> References: <1E1hSC-0Di-00@earth.cosmos.com> Message-ID: <42F64EAA.4010103@versaccounting.com> Paul Boekholt wrote: > I suppose you can simply telnet into your UNIX server, but if you're going to > develop client/server apps, why don't you use a database server such as mysql? The Idea is to allow "Professional" series of SLAG applications to have SQL database backends. Immediate needs are , though , to have a Key/pair as part of the system for the RAD/IDE and eventual runtime. This will work as the "entry level database" as well. 30 years writing accounting system has taught me that sooner or later the lesson of: End User/Client: "My nephews step-son , who is an ACCESS WIZ and genius on the Playstation came in to tweak YOUR database and now your %$$@$ programs do not work. I WANT you to fix them FREE of charge!!!". So, at least the "entry" level applications can be using a trivial database of some kind. Overlay this with some sort of "Multi Value" & string based routines and you have a pretty flexible database engine. > > > > I don't see this, unless the payments and the AR are in the same file (and > even then it should be possible to use the same handle), or you open the AR > file for each record in the payments file and then forget to close it, which > would crash sooner or later anyway. Yes, in this case AR-OPEN is the file that contains OPEN item and it's type. Type could be a Payment on account, a charge on account, a credit memo, and a debit memo. IF I post a payment to customer "SMITH", it comes in from a transactional system on Payment Entry and gets posted to AR-OPEN. Same as "credit/debit" memo on account. In a Order Entry system, orders get posted to the Customers AR-OPEN as a charge. SO everything makes a stop in the AR-OPEN file. In the case of say overpayemnt on account, you have to "APPLY" (if that is what the customer says to do with it) the "open" credit. A Prime example of this is say I send ACME a check for $10,000USD to pay on my account. And ASSUME, I did not put a specific invoice number on the check. It would get posted to my account as an "OPEN" payment. Now the "APPLY" screen would call up the AR-OPEN "PAYMENT" type record and display it along with the "remaining" balance. The second part of the screen would be a scroll function allowing me to select each "INVOICE" type AR-OPEN record I wish to apply monies to. So in this case the AR-OPEN file is in the program twice, once as the "PRIMARY" file and another open as the "APPLY" to. Once the PAYMENT amount reached ZERO, I can no longer select any more INVOICES and I am done, so the Application writes out the "PAYMENT" type AR-OPEN record with a ZERO balance. > > d> With gdbm this is not a problem, when you open the file as a writer it is > always locked. With tdb, there are some locking functions but they aren't > wrapped. I can wrap them, if you still think you need tdb. > What do you know about "sleepycat" (Berkley)? http://www.sleepycat.com Seems to have a lot of features including the ability for secondary key access. As Always, thanks ... -- Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From p.boekholt at hetnet.nl Sun Aug 7 16:44:54 2005 From: p.boekholt at hetnet.nl (Paul Boekholt) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] SLAG update and information. In-Reply-To: <42F64EAA.4010103@versaccounting.com> Message-ID: <1E1s0s-03s-00@earth.cosmos.com> On Sun, 07 Aug 2005 13:10:50 -0500, Ben Duncan said: > The Idea is to allow "Professional" series of SLAG applications to have > SQL database backends. Immediate needs are , though , to have a Key/pair as > part of the system for the RAD/IDE and eventual runtime. >From your earlier post I gather you'll need a real database backend before June 2006 - that's less than 10 months from now. > So in this case the AR-OPEN file is in the program > twice, once as the "PRIMARY" file and another open as the "APPLY" to. Yes, but only because open accounts and payments are in the same file. You could either split different kinds of data into different files, or you could put all an application's data into a single file, open the file at application start and close it at exit. Or you could try to make sure a file is only opened in one place, maybe do it in an object-oriented way: % tdb_access.sl import("tdb"); variable db=tdb_open("/path/to/tdbfiles/" + current_namespace() + ".tdb", 0, O_RDWR | O_CREAT, 0600); define fetch(key) { return tdb_fetch(db, key); } ... % application.sl autoload("ar->fetch", "tdb_access"); ... account = ar->fetch("ddfb5465222"); > What do you know about "sleepycat" (Berkley)? http://www.sleepycat.com > Seems to have a lot of features including the ability for secondary key > access. I think you mean it supports duplicate keys. Big deal. From ben at versaccounting.com Sun Aug 7 18:15:32 2005 From: ben at versaccounting.com (Ben Duncan) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] SLAG update and information. In-Reply-To: <1E1s0s-03s-00@earth.cosmos.com> References: <1E1s0s-03s-00@earth.cosmos.com> Message-ID: <42F68804.6020802@versaccounting.com> Ok, first off, If in proceeding conversations, if i get a might trite, forgive me, I am not trying to be. I AM enjoying these discussions immensely. I am a Applications programmer by trade, not a System Programmer. Anyway, yes, I have 10 months to get this thing done now. I DO have the Appgen stuff as my model basis, as well as a whole slew of old COBOL programs and source to them. I actually converted a old MCBA COBOL program (Version 2.0) that was dated back in the 1980's and used a "screen" driver in about 10 minutes to SLAG. It was a simple Customer File Maintenance screen. I actually have a bunch of FoxPro applications as well and the source to them. SOP in the AR OPEN file discussion, is to have the all the AR-OPEN records in one file. Usually in Inventory, you have a Item master and then a Warehouse Item File, and in some more sophisticated systems a "BIN" file, which forms a one to many to many link. Hence Multi values work really well here. So there are and will be all sorts of variations. The idea is to follow what I already have and I know how it works. Ditto for any Applications Programmers whom pick up and go with SLAG. In duplicate key reference's , in the old VSAM/ISAM methods, and using a Customer Master as a reference here, you would have a PRIMARY key of Customer number, but could have "Customer Name" as a secondary index. SO in lookups, you would do a START on Customer NAME key and return a screen full of customers in a pick list. Now Appgen's dbm was a key/data block mode type file manager. To do a lookup, it used a secondary file that was built using "whatever" you attribute you specified, then put the real key in a multi value list. It was not a TRUE multi value like PICK, but used a list separator of "xFF" between each of the the multi value strings. Field delimiters were NULLS between each and every field. It is almost a 4NF overlayed on top of a key/data dbm engine. From what I can deduce, it actual created a in memory linked list when you read the datafile. It suffered from SOME bad corruption's from time to time. Record locking seems to be controlled by a "row" header that got a byte set that flagged the record as locked. Each record in the file always has a 36 byte header in it. Another data file manager I am looking at is the VBISAM out on soruceforge.net. It is an FOSS ISAM replacement for C-ISAM. Any suggestions or comments on that one? As always, you ARE appreciated and thanks for the time and effort in responding to me !!!! Paul Boekholt wrote: > On Sun, 07 Aug 2005 13:10:50 -0500, Ben Duncan said: > -- Ben Duncan - VersAccounting Software LLC 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From p.boekholt at hetnet.nl Sun Aug 14 04:14:33 2005 From: p.boekholt at hetnet.nl (Paul Boekholt) Date: Tue Jan 30 08:52:08 2007 Subject: [slang-users] slmysql Message-ID: <1E4DdZ-0P3-00@earth.cosmos.com> Hello, I've slirped a new mysql module. You can get it at http://www.cheesit.com/downloads/slmysql. From marko.mahnic at email.si Tue Aug 23 03:40:40 2005 From: marko.mahnic at email.si (Marko Mahnic) Date: Tue Jan 30 08:52:09 2007 Subject: [slang-users] debug: points where left on the stack In-Reply-To: References: <200508190356.j7J3ugI6010907@aluche.mit.edu> <200508221621.j7MGLJYE028161@aluche.mit.edu> Message-ID: <430AD2F8.6030405@email.si> Joerg Sommer wrote: > "John E. Davis" wrote: > >>Joerg Sommer wrote: >> >>>I'm interested in functions they leave values on the stack after quit >>>without using the return statement. I'm not interested in such constructs: >>> >>>do_check(); >>>do_something(); >>>if ( () ) >> >>You should try to minimize the use of such constructs. > > > Why? Is a cool feature of slang. > It is a cool feature but it makes the code harder to read, understand and mantain. In the example above you already wrote two interpretations (does do_check push the status or does do_something do it?). One way to control the stack would be to use sth similar to _auto_declare (or _boseos_info). If the compilation unit would for example declare _strict_return = 1 then all functions that leave sth on the stack would have to push the result on the stack with return. Such byte-compiled functions would look like this A = stack_pointer .... compiled body .... if (stack_pointer - A != _NRESULTS) do_error(...) In some cases one would need to return a different number of values even when _strict_return = 1. This could be done by setting _NRESULTS inside the function: define foo() { _NRESULTS = 2; push("abcde"); .... return 5; } _NRESULTS is similar to _NARGS but it is compiled only when _strict_return = 1, otherwise it is ignored. (can this be done ?) There are cases when the number of results is not known at compile time, but in such cases the function should return a list or an array (one object with multiple values, _NRESULTS = 1). IMO this would lead to better documented code. Marko From joerg at alea.gnuu.de Tue Aug 23 06:12:14 2005 From: joerg at alea.gnuu.de (Joerg Sommer) Date: Tue Jan 30 08:52:09 2007 Subject: [slang-users] debug: points where left on the stack References: <200508190356.j7J3ugI6010907@aluche.mit.edu> <200508221621.j7MGLJYE028161@aluche.mit.edu> <430AD2F8.6030405@email.si> Message-ID: Marko Mahnic wrote: > Joerg Sommer wrote: >> "John E. Davis" wrote: >> >>>Joerg Sommer wrote: >>> >>>>do_check(); >>>>do_something(); >>>>if ( () ) >>> >>>You should try to minimize the use of such constructs. >> >> Why? Is a cool feature of slang. >> > It is a cool feature but it makes the code harder to read, > understand ACK > and mantain. You need more documentation and it is not readable for a non-slang programmer. But something like this, too: define vinsert () { _NARGS-1; Sprintf; insert; } I don't think this is problem, because every programming language has its peculiarities and you can't read it if you don't know the language. > One way to control the stack would be to use sth similar > to _auto_declare (or _boseos_info). > If the compilation unit would for example declare > _strict_return = 1 slsh> message(_slang_version_string); 2.0.4 slsh> message(_strict_return); _strict_return is undefined :2::Undefined Name > then all functions that leave sth on the stack would have > to push the result on the stack with return. Yes. This is exactly what I am searching for. > Such byte-compiled functions would look like this > A = stack_pointer > .... compiled body .... > if (stack_pointer - A != _NRESULTS) do_error(...) This can be done with slang? Is it possible for an eos handler to get the number of arguments of return? > In some cases one would need to return a different number of > values even when _strict_return = 1. This could be done by > setting _NRESULTS inside the function: > > define foo() > { > _NRESULTS = 2; > push("abcde"); > .... > return 5; Why not use return("abcde", 5)? Bye, J?rg. -- Professor: "Gott", unverst?ndliches und mythisches Wesen, das sich einmal pro Woche im Kreis der Sterblichen manifestiert um Weisheit auf Folien unter das Volk zu bringen. (Dschungelbuch 11, FSU Jena) From marko.mahnic at email.si Tue Aug 23 12:02:22 2005 From: marko.mahnic at email.si (Marko Mahnic) Date: Tue Jan 30 08:52:09 2007 Subject: [slang-users] debug: points where left on the stack In-Reply-To: References: <200508190356.j7J3ugI6010907@aluche.mit.edu> <200508221621.j7MGLJYE028161@aluche.mit.edu> <430AD2F8.6030405@email.si> Message-ID: <430B488E.10103@email.si> Joerg Sommer wrote: > Marko Mahnic wrote: > >>Such byte-compiled functions would look like this >> A = stack_pointer >> .... compiled body .... >> if (stack_pointer - A != _NRESULTS) do_error(...) > > > This can be done with slang? Is it possible for an eos handler to get > the number of arguments of return? No. I was just suggesting a solution (that is why _strict_return and _NRESULTS are not defined). The SLang byte-compiler (C code) would have to be modified to implement such a feature. The first (A=...) and the last line (if ...) would be genrated by the compiler when _strict_return=1 but not when _strict_return=0. AFAIK this is similar to what _boseos_info does when you enable_stack_check(). I just rememberd another thing. The upper code does not take into account the passed parameters. The first line should probably be A = stack_pointer - _NARGS If _NRESULTS is not explicitly set within the function it would be calculated from the return statement(s). Also, all return statements would have to return the same number of results. Would SLang loose too much? Marko From lpe540 at yahoo.com Thu Aug 25 09:57:03 2005 From: lpe540 at yahoo.com (Joe Miller) Date: Tue Jan 30 08:52:09 2007 Subject: [slang-users] push array structure into slang Message-ID: <20050825135703.21628.qmail@web50007.mail.yahoo.com> Hi, I was wondering how to push an array of slang structs into slang from c. I have a c function that returns an array of C structures and I'd like to push onto slang. I've tried to do this a bunch of different ways and have to find a way that works. I was wondering if anyone had any suggestions. Here's one approach I took. I think it describes at least what I'm trying to do. typedef struct cstruct { double x; // x position double y; // y position } CSTRUCT, *CSTRUCT_P; SLang_CStruct_Field_Type SLANG_XY [] = { MAKE_CSTRUCT_FIELD(CSTRUCT, x, "x", SLANG_DOUBLE_TYPE, 0), MAKE_CSTRUCT_FIELD(CSTRUCT, y, "y", SLANG_DOUBLE_TYPE, 0), SLANG_END_CSTRUCT_TABLE }; void sl_fucnc (void) { CSTRUCT_P cp; int size = 4; c_func (cp, size); //Where cfunc creates an array of cp; SLang_Array_Type *at = SLang_create_array(SLANG_STRUCT_TYPE,0,NULL,&size,1); SLang_Struct_Type *st; SLang_Any_Type *any; for (int ww = 0; ww < arg2; ww++){ SLang_push_cstruct((VOID_STAR)&cp[ww], SLANG_XY); SLang_pop_anytype (&any); *((SLang_Struct_Type**)st) = (SLang_Struct_Type*)any; SLang_set_array_element (at, &ww, st); } SLang_push_array(at,1); } Any thoughts or suggestion would be greatly appreciated. I could be going about this all wrong so let me know if you need more info. Thanks. -joe ____________________________________________________ Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs From mnoble at space.mit.edu Thu Aug 25 10:50:06 2005 From: mnoble at space.mit.edu (Michael Noble) Date: Tue Jan 30 08:52:09 2007 Subject: [slang-users] push array structure into slang In-Reply-To: <20050825135703.21628.qmail@web50007.mail.yahoo.com> References: <20050825135703.21628.qmail@web50007.mail.yahoo.com> Message-ID: <20050825145006.GA18024@svoboda.mit.edu> Hi Joe, > for (int ww = 0; ww < arg2; ww++){ > SLang_push_cstruct((VOID_STAR)&cp[ww], SLANG_XY); > SLang_pop_anytype (&any); Have you tried popping the structure off as a structure, instead of an anytype? E.g. defining at the top SLang_Struct_Type *st = NULL; and then having your loop do if (-1 == SLang_pop_struct(&st)) return -1; In S-Lang1 the struct pop function is quasi-public (not declared statically, but is not in the public api), so when I needed to use it I wound up doing something like #define SLang_pop_struct _SLang_pop_struct and prototyping it myself. In SLang2 the SLang_pop_struct() function is public, so you don't need to play those games. For array creation it would be nice if one could create instances of SLang_Struct_Type* directly in the C api (roughly analogous to what SLang_create_mmt does for MMT types). Then arrays of structs could be created w/out resorting to using push/pop for each element, but this was not supported in SLang1, nor does it appear to be present in the SLang2 api. I doubt the push/pop method, though, is a big performance hit. HTH, -Mike From lpe540 at yahoo.com Thu Aug 25 11:44:39 2005 From: lpe540 at yahoo.com (Joe Miller) Date: Tue Jan 30 08:52:09 2007 Subject: [slang-users] push array structure into slang In-Reply-To: <20050825145006.GA18024@svoboda.mit.edu> Message-ID: <20050825154440.56791.qmail@web50007.mail.yahoo.com> Mike, I am using slang 1.4.9. So when I try #define SLang_pop_struct _SLang_pop_struct extern int _SLang_pop_struct (SLang_Struct_Type **); and then in the function. if (-1 == SLang_pop_struct(&st)) return -1; I get unresolved symbols when I try to import the module. S-Lang Error: Intrinsic Error: Error linking to /pool14/jmiller/wlm/chips2-module.so: /pool14/jmiller/wlm/chips2-module.so: undefined symbol: _Z17_SLang_pop_structPP18_SLang_Struct_Type I'm probably doing something obvious here, but I'm just not seeing it. Any thoughts. Thanks. -joe --- Michael Noble wrote: > Hi Joe, > > > for (int ww = 0; ww < arg2; ww++){ > > SLang_push_cstruct((VOID_STAR)&cp[ww], > SLANG_XY); > > SLang_pop_anytype (&any); > > Have you tried popping the structure off as a > structure, > instead of an anytype? E.g. defining at the top > > SLang_Struct_Type *st = NULL; > > and then having your loop do > > if (-1 == SLang_pop_struct(&st)) > return -1; > > In S-Lang1 the struct pop function is quasi-public > (not declared > statically, but is not in the public api), so when I > needed to > use it I wound up doing something like > > #define SLang_pop_struct _SLang_pop_struct > > and prototyping it myself. In SLang2 the > SLang_pop_struct() > function is public, so you don't need to play those > games. > > For array creation it would be nice if one could > create instances > of SLang_Struct_Type* directly in the C api (roughly > analogous to > what SLang_create_mmt does for MMT types). Then > arrays of structs > could be created w/out resorting to using push/pop > for each element, > but this was not supported in SLang1, nor does it > appear to be > present in the SLang2 api. I doubt the push/pop > method, though, > is a big performance hit. > > HTH, > -Mike > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From davis at space.mit.edu Thu Aug 25 13:28:29 2005 From: davis at space.mit.edu (John E. Davis) Date: Tue Jan 30 08:52:09 2007 Subject: [slang-users] push array structure into slang In-Reply-To: <20050825135703.21628.qmail@web50007.mail.yahoo.com> References: <20050825135703.21628.qmail@web50007.mail.yahoo.com> Message-ID: <200508251728.j7PHSTIW007692@aluche.mit.edu> Joe Miller wrote: >I have a c function that returns an array of C >structures and I'd like to push onto slang. I've tried >to do this a bunch of different ways and have to find >a way that works. I was wondering if anyone had any >suggestions. I will try to followup with an example of how to do this when time permits. However, in your case I think it is more important to reconsider your approach. Obviously, in C scope you have a set of (x,y) points stored as an array of structs. I strongly urge you not to use this representation in S-Lang scope because it will defeat the purpose of slang's array handling. Instead I recommend that you return a single struct with with two array-valued x, y fields. With such a representation, filtering would be trivial, e.g., pnts = your_function (...); i = where ((pnts.x < xmin) or (pnts.x >= xmax)); bad_x = pnts.x[i]; . . Also it would be possible to trivally pass such data to functions that expect arrays, e.g., mean_x = sum (pnts.x)/length(pnts.x); or even require ("gsl"); % Add some noise sigma = sqrt (pnts.y); pnts.y += ran_gaussian (sigma, length (pnts.y)); None of the above operations would be simple in your array-of-structs approach. I hope this helps. Good luck, --John From mnoble at space.mit.edu Thu Aug 25 13:45:24 2005 From: mnoble at space.mit.edu (Michael Noble) Date: Tue Jan 30 08:52:09 2007 Subject: [slang-users] push array structure into slang In-Reply-To: <20050825154440.56791.qmail@web50007.mail.yahoo.com> References: <20050825145006.GA18024@svoboda.mit.edu> <20050825154440.56791.qmail@web50007.mail.yahoo.com> Message-ID: <20050825174524.GA19736@svoboda.mit.edu> > symbol: _Z17_SLang_pop_structPP18_SLang_Struct_Type This entry point name has C++ linkage (mangled by the C++ compiler, e.g. in order to support overloading). Use the extern "C" qualifier to ensure C linkage. -Mike From lpe540 at yahoo.com Thu Aug 25 14:47:25 2005 From: lpe540 at yahoo.com (Joe Miller) Date: Tue Jan 30 08:52:09 2007 Subject: [slang-users] push array structure into slang In-Reply-To: <200508251728.j7PHSTIW007692@aluche.mit.edu> Message-ID: <20050825184725.75514.qmail@web50004.mail.yahoo.com> Thanks John. That approach works. -joe --- "John E. Davis" wrote: > Joe Miller wrote: > >I have a c function that returns an array of C > >structures and I'd like to push onto slang. I've > tried > >to do this a bunch of different ways and have to > find > >a way that works. I was wondering if anyone had any > >suggestions. > > I will try to followup with an example of how to do > this when time > permits. However, in your case I think it is more > important to > reconsider your approach. > > Obviously, in C scope you have a set of (x,y) points > stored as an > array of structs. I strongly urge you not to use > this representation > in S-Lang scope because it will defeat the purpose > of slang's array > handling. Instead I recommend that you return a > single struct with > with two array-valued x, y fields. With such a > representation, > filtering would be trivial, e.g., > > pnts = your_function (...); > i = where ((pnts.x < xmin) or (pnts.x >= xmax)); > bad_x = pnts.x[i]; > . > . > > Also it would be possible to trivally pass such data > to functions that > expect arrays, e.g., > > mean_x = sum (pnts.x)/length(pnts.x); > > or even > > require ("gsl"); > > % Add some noise > sigma = sqrt (pnts.y); > pnts.y += ran_gaussian (sigma, length (pnts.y)); > > None of the above operations would be simple in your > array-of-structs > approach. > > I hope this helps. > Good luck, > --John > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com