Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 23rd January 2012, 03:08   #1  |  Link
maxxon
Registered User
 
maxxon's Avatar
 
Join Date: Jan 2012
Location: On the net
Posts: 76
Arrays and such

Hello all,

I am new to AviSynth (less than a month) and I quickly noticed that there was no usable array system available (the one that was pointed to was uber slow due to O(n) implementation). So I have started to write a new one (well, actually almost finished, but couldn't post till now) which is O(1) but I was wondering if anyone else would be interested in this library.

If so, where would be a good place to put it?

There are also other libraries I created in passing such as a for loop, profiler, parameter list to array converter, memory allocation system and others.

Thanks,


Mx
maxxon is offline   Reply With Quote
Old 23rd January 2012, 03:50   #2  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 3,105
I am sure we would be interested, you can post a link here so we can play with it.

Also please do not double post, we all look in both Avisynth forums.

This looks like it fits in Development much better than Usage.
Asmodian is offline   Reply With Quote
Old 23rd January 2012, 03:54   #3  |  Link
maxxon
Registered User
 
maxxon's Avatar
 
Join Date: Jan 2012
Location: On the net
Posts: 76
Sorry for the cross post. I wasn't sure which location was better.

I'll have it complete in a day or so. Mostly clean up, and documentation.


Mx
maxxon is offline   Reply With Quote
Old 26th January 2012, 08:14   #4  |  Link
maxxon
Registered User
 
maxxon's Avatar
 
Join Date: Jan 2012
Location: On the net
Posts: 76
Ok, I've uploaded it to sourceforge. Please bare with me as I've not used this service before 2 days ago.

You can download the compressed archive here.

Please feel free to post feedback, questions or comments as they are all welcome.

Thanks,


Mx
maxxon is offline   Reply With Quote
Old 27th January 2012, 19:25   #5  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,380
I haven't had time to look at this in detail, but here are a few quick comments.

It looks like you've put a lot of work into this - certainly, there's a lot of code there. For that reason, it's hard to know where to start to understand how to use it and (doubly so) how it works.
Some examples would certainly be useful.

At a casual glance, your 'for' function looks quite complicated to use.
Moreover, since the block to be executed is Eval'd in the function scope, it cannot use local variables from the calling environment. That's what I was getting at in my post yesterday.

Are you aware of GScript?
It provides a simple for-loop construct (as a language extension, not a function).
It also has a block if-then-else which could be used in place of the ugly (IMHO, of course ) Eval blocks in your code.
If you like, you could even write the entire code in the extended GScript language and just use GImport instead of Import to load the files.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 28th January 2012, 01:23   #6  |  Link
maxxon
Registered User
 
maxxon's Avatar
 
Join Date: Jan 2012
Location: On the net
Posts: 76
I wish I knew about gscript before. Yes, my for is a bit messy, but it was all that I had. It'll be interesting to see how they profile against each other.

As for sharing stuff to the local environment, yes, it can be done, abet convolutedly. There is a forState that is passed around between each iteration. Learned such things from other functional languages including Boost::mpl.

You pass your string into the forState and return that from the block. An example would be to write the numbers from 1 to 10 separated by commas:
Code:
for(2, 11, """for_returnContinue(forState + "," + forIndex.string)""", "1").for_result
The initial state is "1" and then you keep appending a comma followed by the current index. It is a bit messy though.

A quick look at gscript, seem that you can't bail out of a loop prematurely. In the for I created, this is possible. A slight modification to the previous code to stop at 5 would look like this:
Code:
for(2, 11, """for__returnContinueIf(forState + "," + forIndex.string, forIndex < 5, forState)""", "1").for_result
Which basically says that if forIndex < 5, return the 1st parameter to the loop and continue iterating, otherwise, return the 3rd and bail. Interestingly, on prematurely terminating the loop this way, I can pass back any type, so if I reached 5, instead of returning the forState, I could return a clip, an int, or whatever. And I can determine if it was prematurely terminated by using for_continue on the for loop's result. If it is true, then the for loop continued till its natural conclusion. If false, then it was terminated prematurely.

References can also be used, but it looks strange:
Code:
ref = mem_new(3)
for(0, 5, """
    forState.mem_set(forState.mem_get + 1)
    forState.for_returnContinue
""", ref)
assert(ref.mem_get == 8)
That snippet adds 5 to the value pointed at by ref by adding 1, 5 times.

Yeah, I should make more examples to show how to use the library. I'm just trying to figure out some reasonable ones.


|\/|x

Last edited by maxxon; 28th January 2012 at 01:43.
maxxon is offline   Reply With Quote
Old 28th January 2012, 13:37   #7  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,380
Quote:
Originally Posted by maxxon View Post
As for sharing stuff to the local environment, yes, it can be done, abet convolutedly. There is a forState that is passed around between each iteration.
But no way to read and write arbitrary variables of the calling environment?

Quote:
A quick look at gscript, seem that you can't bail out of a loop prematurely.
Not explicitly, but a crude way to do it is just set the loop counter to its final value.
See posts #27-29 here (which also touches on the topic of arrays).
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 28th January 2012, 17:06   #8  |  Link
maxxon
Registered User
 
maxxon's Avatar
 
Join Date: Jan 2012
Location: On the net
Posts: 76
Quote:
Originally Posted by Gavino View Post
But no way to read and write arbitrary variables of the calling environment?
Well, the last way I described (using a reference) is somewhat arbitrary. You just have to go through the memory reference proxy.

Another more direct way to do it though references without passing through the forState variable is to build the for body string.
Code:
ref = mem_new("1")
for(2, 11, """
    ref = """"+ref+""""  # Note the 4 quotes, that puts in a quote inside of the string
    ref.mem_set(ref.mem_get + "," + forIndex)
    forState.for_returnContinue
""", "")
assert(ref.mem_get == "1,2,3,4,5,6,7,8,9,10")
ref.mem_delete   # forgot this line before.  If you don't delete your ref, you can end up with a memory leak
The ref inside the for is an alias to the ref outside. Since the ref string never contains quotes, this is always valid. The memory that the ref is pointing to can be a string that contains quotes, or can be a clip or other type.

But to use a named variable, no, there is no way unless the scripting language gives access to the push and pop contexts functions, or give a way to call a function that will not push and pop a context. Say like this:
Code:
function fn(param)
{
    assert(myVar == "hello")
    myVar = param
}
myVar = "hello"

"fn".apply_nocontext(3)

assert(myVar == 3)
Such a method would be very similar to the current Apply function except that no new context would be used.
EDIT: Actually, given what you said about creating filters, such a function is extremely doable.
EDIT: Opps, no, this would have to be on level of the parser.

EDIT: I am also working on static and anonymous structures which would allow for named access to the elements within. So, that would be a psudo named access feature. See next post.

Quote:
Originally Posted by Gavino View Post
Not explicitly, but a crude way to do it is just set the loop counter to its final value.
See posts #27-29 here (which also touches on the topic of arrays).
Yeah, I looked at AVSLib. That is the reason that I made created my library. To modify an AvsLib array of 64 elements took over a bloody minute to a minute and a half!!!!! I can use a reference array to go though 200 - 2000 in a second or two.

Due to how the reference array (RA) works (they are a concatenated string of memory references), they are fairly easy to build and manipulate. But again, you must delete the array or you will cause a memory leak. Given this, you can actually pass in a RA into a for the same way that I described for passing the alias to the ref, though the array would be static (you wouldn't be able to change its size unless you used a reference to the array), the elements would be accessible and manipulatable.


|\/|x

Last edited by maxxon; 28th January 2012 at 17:50.
maxxon is offline   Reply With Quote
Old 28th January 2012, 18:13   #9  |  Link
maxxon
Registered User
 
maxxon's Avatar
 
Join Date: Jan 2012
Location: On the net
Posts: 76
I'm also considering making structure support in this library. Consider for an anonymous structure:
Code:
a = struct_newAnnon(RA_new(\
    struct_el("var1", 8), \
    struct_el("var2", "text") \
))

assert(a.struct_get("var1") == 8)
assert(a.struct_get("var2") == "text")
a.struct_set("var1") == 3
assert(a.struct_get("var1") == 3)
or for a static structure:
Code:
struct_newDefine("myStruct", \
RA_new( \
    struct_el("var1", 9), \
    struct_el("var2", "hello") \
))

a = struct_new("myStruct")
assert(a.struct_get("var1") == 9)
assert(a.struct_get("var2") == "hello")

a.struct_set("var2", 5)
assert(a.struct_get("var2") == 5)
An anonymous struct would have O(log(n)) access to its elements, a static struct would have O(1) access to its elements. Both can be modified through a parameter call. Continuing from the last example:
Code:
function fn(string myData)
{
    assert(myData.struct_get("var2") == 5)
    myData.struct_set("var2", "new string")
}
fn(a)
assert(a.struct_get("var2") == "new string")

for(0, 5, """
    a=""""+a+""""
    assert(a.struct_get("var1") == 9 + forIndex)
    assert(a.struct_set("var1"), a.struct_get("var1") + 1)
""", "")

assert(a.struct_get("var1") == 14)
Is that something that would be useful?


|\/|x

Last edited by maxxon; 28th January 2012 at 18:27.
maxxon is offline   Reply With Quote
Old 28th January 2012, 18:31   #10  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,380
Quote:
Originally Posted by maxxon View Post
Another more direct way to do it though references without passing through the forState variable is to build the for body string.
Code:
ref = mem_new("1")
for(2, 11, """
    ref = """"+ref+""""  # Note the 4 quotes, that puts in a quote inside of the string
    ref.mem_set(ref.mem_get + "," + forIndex)
    forState.for_returnContinue
""", "")
assert(ref.mem_get == "1,2,3,4,5,6,7,8,9,10")
ref.mem_delete   # forgot this line before.  If you don't delete your ref, you can end up with a memory leak
OK I see, but it seems very cumbersome (and shouldn't it be forindex.string on 4th line?).
Personally (and I don't think I'm alone), I would much prefer to write:
Code:
result = "1"
for (i=2, 10) {
  result = result + "," + i.string
}
Quote:
Yeah, I looked at AVSLib. That is the reason that I made created my library.
Yes, I realised that. Your library will be a welcome alternative to AVSLib (which I confess I have never used).
How would you write Stephen R. Savage's example with your stuff?

EDIT: Just seen your latest post. I'll get back to you later on that.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 28th January 2012, 20:34   #11  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,380
Quote:
Originally Posted by maxxon View Post
Code:
...
for(0, 5, """
    a=""""+a+""""
    assert(a.struct_get("var1") == 9 + forIndex)
    assert(a.struct_set("var1"), a.struct_get("var1") + 1)
""", "")
Should that be:
Code:
    a.struct_set("var1", a.struct_get("var1") + 1)
Quote:
Is that something that would be useful?
To be honest, I'm not sure. Keep in mind that the purpose of Avisynth is to process video, not to be a general purpose programming language.
It's the sort of thing that may be of interest only to language geeks like you and me.
I'd be interested to hear what others think.

Actually, I played around with something similar back in 2008, but it was purely for amusement and I never released it.
I grandly called it 'Object AVS'.
FWIW, here's the code (including an example/test).
Code:
global AVSO_n = 0

function ObjNew(string "class") {
  global AVSO_n = AVSO_n + 1
  obj = "AVSO_" + string(AVSO_n)
  Defined(class) ? obj.ObjSet("class", class) : NOP
  return obj
}

function ObjGet(val obj, string member) {
  try { v =Eval(obj+"_"+member) }
  catch (e) { v = NOP }
  return v
}

function ObjSet(val obj, string member, val value) {
  Assert(IsObj(obj), "ObjSet: invalid object")
  vString = (IsString(value) ? chr(34)+chr(34)+chr(34)+value+chr(34)+chr(34)+chr(34) : string(value))
  Eval("global "+obj+"_"+member+"="+vString)
  return obj
}

function ObjSet(val obj, string member1, val value1, string member2, val value2) {
  ObjSet(obj, member1, value1)
  ObjSet(obj, member2, value2)
}

function ObjSet(val obj, string member1, val value1, string member2, val value2, string member3, val value3) {
  ObjSet(obj, member1, value1)
  ObjSet(obj, member2, value2)
  ObjSet(obj, member3, value3)
}

function ObjSet(val obj, string member1, val value1, string member2, val value2, string member3, val value3, string member4, val value4) {
  ObjSet(obj, member1, value1)
  ObjSet(obj, member2, value2)
  ObjSet(obj, member3, value3)
  ObjSet(obj, member4, value4)
}

function IsObj(val v) { return IsString(v) && LeftStr(v, 5) == "AVSO_" }

function ObjFunc(string class, string func) {
  i = FindStr(func, "(")
  j = FindStr(func, ")")
  f = "function AVSO_c_"+class+"_"+LeftStr(func, i)+"val this"+(j>i+1 ? "," : "")+MidStr(func, i+1)
  Eval(f)
}

function ObjCall(val obj, string call) {
  class = obj.ObjGet("class")
  call = FindStr(call, "(") == 0 ? call +"()" : call
  i = FindStr(call, "(")
  j = FindStr(call, ")")
  f = "AVSO_c_"+class+"_"+LeftStr(call, i)+"obj"+(j>i+1 ? "," : "")+MidStr(call, i+1)
  Eval(f)
}

BlankClip()
x = ObjNew()
x.ObjSet("prop", "xxx")
ObjFunc("myclass", "DoIt(){ return 42 }")
ObjFunc("myclass", "DoIt2(int i){ return i+1 }")
ObjFunc("myclass", """count() { return this.ObjGet("count") } """)
y = ObjNew("myclass")
y.ObjSet("count", 1234)

global ii = 998
Subtitle(string(x.ObjGet("prop")))
Subtitle(string(y.ObjCall("DoIt()")), y=20)
Subtitle(string(y.ObjCall("DoIt2(999)")), y=40)
Subtitle(string(y.ObjCall("DoIt2(ii)")), y=60)
Subtitle(string(y.ObjCall("count")), y=80)
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 29th January 2012, 07:16   #12  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 5,648
@Gavino, the new pretender (Maxxon) may well be impressive, but we all still love you best.
(unless he usurps you as omnipotent deity that we all think you are)
(The king is dead ... God save the King)
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 29th January 2012 at 07:58.
StainlessS is offline   Reply With Quote
Old 29th January 2012, 08:07   #13  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 5,648
@Maxxon, you could do worse that to have a look at AutoIt,
as an example see here (Myself just found it about Nov/Dec 2011)
http://forum.doom9.org/showthread.php?t=163343
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 29th January 2012, 08:08   #14  |  Link
maxxon
Registered User
 
maxxon's Avatar
 
Join Date: Jan 2012
Location: On the net
Posts: 76
Quote:
Originally Posted by Gavino View Post
OK I see, but it seems very cumbersome (and shouldn't it be forindex.string on 4th line?).
yes
Quote:
Originally Posted by Gavino View Post
Personally (and I don't think I'm alone), I would much prefer to write:
Code:
result = "1"
for (i=2, 10) {
  result = result + "," + i.string
}
Yeah, well, that's how it is now. But actually, I've come up with a way to push specific vars off the current stack frame and pop then onto another. It's quite a trick. I'll get back to you once it has been implemented.
Quote:
Originally Posted by Gavino View Post
Yes, I realised that. Your library will be a welcome alternative to AVSLib (which I confess I have never used).
How would you write Stephen R. Savage's example with your stuff?
Not sure of the example, too hard to see on my phone at the moment. Was the example that the big chunk of code you posted in the thread? I'll get back to you.


|\/|x

Last edited by maxxon; 29th January 2012 at 08:28.
maxxon is offline   Reply With Quote
Old 29th January 2012, 08:18   #15  |  Link
maxxon
Registered User
 
maxxon's Avatar
 
Join Date: Jan 2012
Location: On the net
Posts: 76
Quote:
Originally Posted by Gavino View Post
Should that be:
Code:
    a.struct_set("var1", a.struct_get("var1") + 1)
Yes, as a parameter of assert.


Quote:
Originally Posted by Gavino View Post
To be honest, I'm not sure. Keep in mind that the purpose of Avisynth is to process video, not to be a general purpose programming language.
It's the sort of thing that may be of interest only to language geeks like you and me.
I'd be interested to hear what others think.
Lol. Yeah, it's fun messing around with this crap. :-)

Quote:
Originally Posted by Gavino View Post
Actually, I played around with something similar back in 2008, but it was purely for amusement and I never released it.
I grandly called it 'Object AVS'.
FWIW, here's the code (including an example/test).
I'll have to take a closer look at it later when I'm not on my phone.

|\/|x
maxxon is offline   Reply With Quote
Old 29th January 2012, 08:27   #16  |  Link
maxxon
Registered User
 
maxxon's Avatar
 
Join Date: Jan 2012
Location: On the net
Posts: 76
Quote:
Originally Posted by StainlessS View Post
@Maxxon, you could do worse that to have a look at AutoIt,
as an example see here (Myself just found it about Nov/Dec 2011)
http://forum.doom9.org/showthread.php?t=163343
Hmmmm... Some sort of gui batch utility? I will have to take a look at it later. But it's not as fun as playing with a language like this. :-)


|\/|x
maxxon is offline   Reply With Quote
Old 29th January 2012, 08:33   #17  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 5,648
My sort of GUI batch utility (as I said, I only discovered it less than three months ago) and within
about 5 or 6 weeks of writing that GUI util), but it is a fully fledged language and very flexible.
Way more flexible than the Avisynth lang.

EDIT: Sorry, I read somewhere that you liked proggy languages, and answered, but presumably
I read it in a different thread, because there was no pause between my previous and then current
post.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 29th January 2012 at 08:44.
StainlessS is offline   Reply With Quote
Old 31st January 2012, 07:01   #18  |  Link
maxxon
Registered User
 
maxxon's Avatar
 
Join Date: Jan 2012
Location: On the net
Posts: 76
Quote:
Originally Posted by Gavino View Post
How would you write Stephen R. Savage's example with your stuff?
Sorry, I responded, but I couldn't see what it was you were asking. Now I know.

Quote:
Originally Posted by Stephen R. Savage View Post
Gavino, do you think you could extend this with some kind of cheap array or list-like data structure? It could just contain pointers to variables or something like that. I was thinking something like this could be useful:

Code:
super = MSuper()
test = Array(dimension=6)
for(i=1, 3) {
test[i] = MAnalyse(super, idx=i, isb=true)
test[i*2] = MAnalyse(super, idx=i)
}
MDeGrain3(super, test[1], test[4], test[2], test[5], test[3], test[6])
At the moment, using the current for function and assuming that MSuper returns a string (I don't know what it is, if not it would have to be made into a reference one), it would look like this:
Code:
super = MSuper()
test = RA_newDefault(6, 0)
for(1, 3, 
    test = """"test""""
    super = """"super""""
    test.RA_set(forIndex, MAnalyse(super, idx=forIndex, isb=true))
    test.RA_set(forIndex*2, MAnalyse(super, idx=forIndex))
}
MDeGrain3(super, test.RA_get(1), test.RA_get(4), test.RA_get(2), test.RA_get(5), test.RA_get(3), test.RA_get(6))
I'm writing a new set of functions, vars and forEx. vars will push and pop arbitrary variables on and off the stack and pass them in an object. forEx will utilise this lib to then make it look more like a non-function for loop. So it would look something like this:
Code:
super = MSuper()
test = RA_newDefault(6, 0)
forEx(vars_push(RA_new("super", "test")).eval, \
    "i", 1, 3, """
    test.RA_set(i, MAnalyse(super, idx=i, isb=true)
    test.RA_set(i*2, MAnalyse(super, idx=i)
""").eval
MDeGrain3(super, test.RA_get(1), test.RA_get(4), test.RA_get(2), test.RA_get(5), test.RA_get(3), test.RA_get(6))

|\/|x

Last edited by maxxon; 31st January 2012 at 13:34.
maxxon is offline   Reply With Quote
Old 31st January 2012, 07:33   #19  |  Link
maxxon
Registered User
 
maxxon's Avatar
 
Join Date: Jan 2012
Location: On the net
Posts: 76
Quote:
Originally Posted by Gavino View Post
Should that be:
Code:
    a.struct_set("var1", a.struct_get("var1") + 1)

To be honest, I'm not sure. Keep in mind that the purpose of Avisynth is to process video, not to be a general purpose programming language.
It's the sort of thing that may be of interest only to language geeks like you and me.
I'd be interested to hear what others think.

Actually, I played around with something similar back in 2008, but it was purely for amusement and I never released it.
I grandly called it 'Object AVS'.
FWIW, here's the code (including an example/test).
Code:
global AVSO_n = 0

function ObjNew(string "class") {
  global AVSO_n = AVSO_n + 1
  obj = "AVSO_" + string(AVSO_n)
  Defined(class) ? obj.ObjSet("class", class) : NOP
  return obj
}

function ObjGet(val obj, string member) {
  try { v =Eval(obj+"_"+member) }
  catch (e) { v = NOP }
  return v
}

function ObjSet(val obj, string member, val value) {
  Assert(IsObj(obj), "ObjSet: invalid object")
  vString = (IsString(value) ? chr(34)+chr(34)+chr(34)+value+chr(34)+chr(34)+chr(34) : string(value))
  Eval("global "+obj+"_"+member+"="+vString)
  return obj
}

function ObjSet(val obj, string member1, val value1, string member2, val value2) {
  ObjSet(obj, member1, value1)
  ObjSet(obj, member2, value2)
}

function ObjSet(val obj, string member1, val value1, string member2, val value2, string member3, val value3) {
  ObjSet(obj, member1, value1)
  ObjSet(obj, member2, value2)
  ObjSet(obj, member3, value3)
}

function ObjSet(val obj, string member1, val value1, string member2, val value2, string member3, val value3, string member4, val value4) {
  ObjSet(obj, member1, value1)
  ObjSet(obj, member2, value2)
  ObjSet(obj, member3, value3)
  ObjSet(obj, member4, value4)
}

function IsObj(val v) { return IsString(v) && LeftStr(v, 5) == "AVSO_" }

function ObjFunc(string class, string func) {
  i = FindStr(func, "(")
  j = FindStr(func, ")")
  f = "function AVSO_c_"+class+"_"+LeftStr(func, i)+"val this"+(j>i+1 ? "," : "")+MidStr(func, i+1)
  Eval(f)
}

function ObjCall(val obj, string call) {
  class = obj.ObjGet("class")
  call = FindStr(call, "(") == 0 ? call +"()" : call
  i = FindStr(call, "(")
  j = FindStr(call, ")")
  f = "AVSO_c_"+class+"_"+LeftStr(call, i)+"obj"+(j>i+1 ? "," : "")+MidStr(call, i+1)
  Eval(f)
}

BlankClip()
x = ObjNew()
x.ObjSet("prop", "xxx")
ObjFunc("myclass", "DoIt(){ return 42 }")
ObjFunc("myclass", "DoIt2(int i){ return i+1 }")
ObjFunc("myclass", """count() { return this.ObjGet("count") } """)
y = ObjNew("myclass")
y.ObjSet("count", 1234)

global ii = 998
Subtitle(string(x.ObjGet("prop")))
Subtitle(string(y.ObjCall("DoIt()")), y=20)
Subtitle(string(y.ObjCall("DoIt2(999)")), y=40)
Subtitle(string(y.ObjCall("DoIt2(ii)")), y=60)
Subtitle(string(y.ObjCall("count")), y=80)
Interesting. I was thinking that in the not so distant future I could use the struct I specified with the regular function system to do something similar. Something like this:
Code:
struct_define("myclass", RA_new(struct_el("var1", 0)))

function myclass_new()
{
}

function myclass_get(string obj)
{
    obj.struct_get("var1")
}

function myclass_set(string obj, int val)
{
    obj.struct_set("var1", val)
}

function myclass_delete()
{
}

instance = obj_new("myclass")
assert(instance.obj_call("get")==0)
instance.obj_call("set", 9)
assert(instance.obj_call("get")==9)
instance.obj_delete
Although, I've not specified how I would do this, I don't think it would be that difficult.

Then later on tack on an inhieritance system which would do function searches up the inhierentance tree if ones don't exist. Of course that probably wouldn't work properly until the try catch bug is fixed.


|\/|x

p.s. please forgive any spelling mistakes, I've just got a new laptop and I've not installed the dictionary yet.

Last edited by maxxon; 31st January 2012 at 07:35.
maxxon is offline   Reply With Quote
Old 31st January 2012, 07:39   #20  |  Link
maxxon
Registered User
 
maxxon's Avatar
 
Join Date: Jan 2012
Location: On the net
Posts: 76
Quote:
Originally Posted by StainlessS View Post
My sort of GUI batch utility (as I said, I only discovered it less than three months ago) and within
about 5 or 6 weeks of writing that GUI util), but it is a fully fledged language and very flexible.
Way more flexible than the Avisynth lang.

EDIT: Sorry, I read somewhere that you liked proggy languages, and answered, but presumably
I read it in a different thread, because there was no pause between my previous and then current
post.
Interesting, will have to take a look at it later then.


|\/|x
maxxon is offline   Reply With Quote
Reply

Tags
array, avisynth, fast, o(1)

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:40.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.