View Full Version : Girder and NetRemote... Please make them match languages at least!
NeoMorph
September 29th, 2007, 04:35 PM
OK... I have been doing some Girder coding and it's been ok... then I go over to NetRemote and find that functions that are available in Girder are not there in NetRemote.
For example I wanted to split a string... in Girder it's string.Split but in NetRemote it's not availbable.
Girder and NetRemote are supposed to be companion programs so why have Lua syntax in one program not in the other... It seems illogical to me.
It's the same with communications... in NetRemote you have NetRemote.SetVariable and NetRemote.GetVariable. In Girder you have SetVariable but no GetVariable. It makes trying to code a single Girder/NR panel a pain in the bum to say the least.
Sometimes these programs are the best in the world... othertimes they are the worlds worst nightmare. Consistency is what is lacking.
Sorry if I'm sounding really sulky tonight but I've hit a brick wall with NR and Girder and I can't figure out how to pass information back and forward between the two. I can trigger events fine... I can process the data ok... it's just that I can't get the two programs working together and the fact that one program has functions the other doesn't (that darned string splitting function for instance) means I HAVE to split the data up in girder and then send it piecemeal to NR (if I could find out how to do that that is). What with pain driving me round the bend I need to be able to do something to take my mind off it... but when your journey towards enlightenement has a chasm of non-functioning code right in front of the wheels of your vehicle the journey ends before it begins.
Rant off...
p.s. It's Lua... As a language I hate it with a vengeance. I'd even prefer APL over it because at least APL makes sense to me. Lua reminds of of the days of COBOL's Altered Gotos in the way it works and we outlawed the use of those Gotos for a reason... they make following the code flow a nightmare. With Lua the flow is all over the place! I guess I'm showing my age is all... I suppose I do come from the age of the "Top Down Programmer".
Rob H
September 29th, 2007, 11:37 PM
Strictly speaking the languages are the same it's just the libraries that are different. Many of Girder's additions to Lua's base libraries - string, math and table - are in the file Additions.lua, which could be copied across to NetRemote (apart from those that add to the gir library).
Not sure what you mean about the flow control being all over the place though. That's not really Lua's fault.
NeoMorph
September 30th, 2007, 02:09 AM
Strictly speaking the languages are the same it's just the libraries that are different. Many of Girder's additions to Lua's base libraries - string, math and table - are in the file Additions.lua, which could be copied across to NetRemote (apart from those that add to the gir library).
If it is that easy why isn't it done already? Why have two programs with different Lua libraries?
I've got to the stage where I've decided to give up. I just tried to create a table in girder ready to pass over to netremote and what happens... nothing because Lua compains that it isn't a table or some other problem when I try other things. It's just causing me grief when all I wanted to do was make my life easier. Instead I'm fighting with girder and netremote and taking 2 steps forward and then 10 steps back.
All because I can't find a decent tutorial that matches the Lua language here!... oh wait a minute.. Lua language(s) - Girder and NetRemote don't match.
I guess my days of being a programmer have finally come to an end if I can't get my head around a new language.
Talk about being depressed... I nearly threw my laptop at the wall after trying to sort out setting values into tables for over an hour... I've programmed in APL using 10 dimensional arrays in the past... Why can't I get a simple two dimensional array to work in Lua?
I give in... Lua wins!
dsmes
September 30th, 2007, 03:43 AM
When all else fails...
http://lua-users.org/wiki/ (especially http://lua-users.org/wiki/TutorialDirectory )
and of course: http://www.lua.org/pil/ and http://www.lua.org/manual/5.0/
I thought the question of this thread was going to be "What version of Lua is used by Girder and NetRemote? Lua version 5.0 or 5.1?"
Rob H
September 30th, 2007, 03:50 AM
Don't give up yet - what have you tried so far?
Are the arrays intended to be numerically indexed? If so then you'd use something like
local array = {
{'a', 'b', 'c'},
{'d', 'e', 'f'}
}
That would produce an array that you could access as e.g.
array[1][1] == 'a'
array[1][3] == 'c'
array[2][1] == 'd'
array[3][1] == attempt to index field `?' (a nil value)
array[1][4] == nil
You need to read Programming in Lua, by Roberto Ieruasalemischy (sp?) which covers pretty much everything you need to know about Lua itself. The Lua core is pretty much fixed - because it's intended as an embedded scripting language every environment that includes it will add its own libraries. I'll see what I can do about adding Additions.lua (or at least the parts that make sense) to NetRemote.
If you want arrays with non-numeric indices let me know.
NeoMorph
October 1st, 2007, 04:02 AM
Rob it turns out I wasn't absorbing my various ************ drugs into my system... so even though I was taking my pills I was going into withdrawal symptoms... and all down to an "upset stomach".
In the end it took a doctor callout as the pain was spiralling out of control (no good drug absorbtion = no pain relief) and I was getting more and more depressed and frantic as time went on. After getting a muscle relaxant shot and some other stuff the doc wanted me in hospital under observation... being an independant sod I said no of course.
At least I now now why my thinking was getting so darned muddy. I've been advised not to even try anything "stressy" for a week while my body gets back into balance (so no coding). With the meds I'm taking it's a balancing act because if I take pill A I have to take pill B to counter the side effects of A and then another to alleviate the side effects of B. Get them out of sync as it were and all hell breaks loose (as you saw). Pain increases, depression deepens and so begins the spiral down to what I call "I give in" syndrome.
Last time it happened this badly was around two years ago.
So fortunately (or unfortunately to you guys heh) I'll be back in the programming spirit sometime in the next week (hopefully that is). Until then it's going to be just reading and relaxing to music while I regain my equilib..equilibree... damn it... balance. I just want to say sorry about my outbursts even though I can't control them at the time... or even recognise when it is happening even though it is obvious to other people.
Later guys...
p.s. Rob, when I get back to coding I'll be getting that book you recommended. Thanks. (edit: Book ordered - thx again)
edit: This was taken from the review site...
One of the milestones of the history of Lua has been the release of the book Programming in Lua (a.k.a "PiL"), by Roberto Ierusalimschy, in 2003. This review is about the second edition of Programming in Lua, a.k.a. the "Blue PiL" due to the color of its cover.
... why is all about Pills or PiLs with me! :rolleyes:
Rob H
October 1st, 2007, 10:09 AM
Sorry to hear that John, must be a real bugger!
Bear in mind that PiL may refer to Lua 5.1 whereas Girder and NR use Lua 5.0, but the differences aren't too great. Main differences are that there's no select function, # doesn't work (use table.getn), and when dealing with varargs 5.1 uses ... both in the parameter list of the function and in the body of the code while 5.0 uses ... in the parameter list and the special identifier arg in the body of the code.
NeoMorph
October 1st, 2007, 12:18 PM
Oh nuts... I ordered the second edition!!! I think that's 5.1 where the original one is 5.0.
Oh well at least I will have a paper copy (I do like my programming manuals in hardcopy). I have downloaded a copy of the original manual in first edition pdf form so I can check that out when the second edition syntax doesn't work. In the first edition is says...
This book describes Lua 5.0. If you are using a more recent version, check the corresponding manual for occasional differences between versions. ... so that's the one I should have ordered. Is there any reason why you haven't used 5.1?
On to my programming rage incident you mentioned additions.lua... I had a look at it and can't find any reference to string.Split (the function that I would most like to see in NR). Searching for "Split" returns no hits at all.
I'll be glad when I can get coding again as I have some ideas why my array programming was failing. I can't check because for some reason the entire gml is empty and I was sure I saved but Girder crashed and I think it may have corrupted the gml. Oh well it didn't work anyway and sometimes a fresh start is a good thing.
I think before I start coding agian I will get a good grounding in basic Lua programming first. I've been learning on the fly up to now and haven't really understood what I was doing and couldn't figure out why certain things don't work. Now I know to look for 5.0 and not 5.1 syntax I can figure out why. :)
Rob H
October 1st, 2007, 01:13 PM
Lua 5.1 wasn't released when support for Lua 5 was added to Girder. Unfortunately a number of the additional components that we use e.g. luathread and luacom are not supported in Lua 5.1 yet.
The 5.1 version of PiL should still be fine.
My mistake, you're quite right, string.Split isn't included in Additions.lua - I think it's actually implemented in C and is in one of the DLLs (possibly in lwinfunc?)
Depending on the sort of split you want, it's relatively easy to implement split in Lua using regular expressions.
As a fairly naive implementation that will work with most characters
function string.Split(s, delim)
local res = {}
for part in string.gfind(s, '[^'..delim..']') do
table.insert(res, part)
end
return res
end
NeoMorph
October 1st, 2007, 02:02 PM
Back onto the array thing I think I realise what I was doing. I created an array but got converting it to a NetRemote variable wrong. How do you move a local array to a NR array.
For example I have the following data..
"q0";"Song Title 1","q1";"Song Title 2","q2";"Song Title3"
... and want to put that into an array that I can use with LoopIndex in NetRemote. The data is supplied by XBMC and I want to use it like I've previously used GAC information. Of course I've used it from NetRemotes side but I've not had to create it in Girder before as MediaBridge does all that.
It's a shame there isn't a MB plugin for XBMC but as it's using old tech it's not worth doing until the XBMC team create a version for current hardware. There are loads of people out there using XBMC and it blows away a lot of purpose built hardware Media Players and that's why I use it. I used to use Pinnacle Showcenter but it's thrown into the back of my junk bin as it is way clunky compared to XBMC - it's slow, the remote is crap, and the software is pathetic in comparison... and I used to think it was great heh.
Rob H
October 2nd, 2007, 03:59 AM
Well, if you feel like writing an MB plugin for XBMC don't let me stop you :)
If memory serves the last couple of versions of Mediabridge now support writing plugins in Lua. Again the problem would be documentation, I'm not sure how much of this is currently documented.
If you want to send a table from Girder to an NR Lua table then you'd use
NetRemote.SetVariable('avar', aTable)
This will put the contents of the table into an NR Lua table called avar and also increment the value of an NetRemote variable (not Lua) called avar.changed. You would use a variable watch on avar.changed to recognise that the table had been updated.
liofr
October 3rd, 2007, 02:53 PM
don't know if this threead is relative to standart library or promixis libray but i think if girder netrrmote support window and only microsoft . All the tool have to support .all Net compatible language ( ironpython C#,pyhton,vbscript ...) and perhaps in the future silverligth ( subset of wpf library for mobile pocket pc). I am new to girder and netremote and don't understand the choice of promixis about
1) gui (own implementation not visual studio like sharpdevelop ..)
2) language (lua !! none of .net language use )
why reinvent the wheel if microsoft create it !!
some domotic software appear for manage gui and home device (wpf and .net) . promixis team have to take care of that for netremote side ...
after so many years proixis exist i ll not think i ll find some thread about API .
tmorten
October 3rd, 2007, 05:42 PM
CCF and LUA are decisions that were made long ago, so I can only speculate on the thinking behind them. As I understand it, the CCF format that NetRemote uses was originally created for remote controls that were manufactured by Philips and Marantz. When the first version of NetRemote was created, it leveraged this format. NetRemote has subsequently extended the CCF format in a number of ways, which motivated the creation of its own authoring tool, NetRemote Designer.
Why use CCF?
- Easy transition for existing Philips/Marantz users
- Existing library of CCF files to draw from
- Existing tool support (now obviated by NetRemote Designer)
- Already incorporates support for embedding IR codes
LUA is intended as a simple scripting facility for users who might not have Computer Science degrees, but who are comfortable digging deeper than a point-and-click interface. LUA was created independently, and it has its own user community. It's not so much a reinvention of other languages which Microsoft endorses, as it is a different language all its own.
Why use LUA?
- Free
- Run-time interpreted; no compiler necessary
- Not tied to any particular platform
- Doesn't require any 3rd party tools
- Easy to learn
One could debate whether there are better choices than CCF/LUA, but moving to other standards isn't something that can happen in the near-term.
Regarding the other discussion about better symmetry between Girder and NetRemote's library of LUA functions, that seems like very constructive feedback. Hopefully a uniform library will be something that we can work towards.
Best,
Tim
NeoMorph
October 4th, 2007, 02:54 AM
Regarding the other discussion about better symmetry between Girder and NetRemote's library of LUA functions, that seems like very constructive feedback. Hopefully a uniform library will be something that we can work towards.
Best,
Tim
Yeah... even in my madness I got something right. :D
Moving between programming Lua script in NR and Girder can be rather confusing when you find that your script fails when you know that something like string.Split is using perfect syntax yet NR says it's not (Girder has string.Split and NetRemote doesn't).
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.