Wednesday, August 26, 2015

C# this time, and Lua

Well, after a bit of digging, I'm back into C#.  I'm looking at that because of the need to examine the current status of a network.  And I had something like that built in VB.net, but i couldn't figure out threading.  So the program didn't play nice or update very well.

Well, I found a few webpages and figured that out.  This post on dailycoding.com was one of them.  That really helped get the ball rolling, so now I can run a ping function in the background and invoke updates to get things changed during program execution.  I'm guessing that I finally learned something out of that one because the code had been stripped down enough to where there wasn't a huge collection of extemporaneous junk that needed beat past.  Is it that hard to write code documentation that gives basic understanding without having to reinvent the wheel?

Which brings me to Lua.  I started using some products from Digital Loggers.  Basically the Rack Mount AC PDU.  It's a great product with a great concept, but changing from Basic on the Web Power Switch to Lua on the Rack Mount AC PDU causes havoc.  All the scripting type stuff that used to be easy with the Basic scripting language now has to be rewritten from scratch.

Did I mention you have to fight past bad Lua documentation?  I'm not necessarily saying Lua has bad documentation.  I'm saying Digital Loggers implementation of Lua is a pain.

For example...

function test_display()
    DISPLAY "\1Percent %%\v"
    DISPLAY "\2Backslash \\\v"
    DISPLAY "\1%a\v" --  current Bus A

This is an example of some code provided to change the display.  

Great.  Can someone tell me where the variable name is in that code block?   I know the -- blocks are comments.  DISPLAY is a command to show something on the display. Got that working.  Great.  

Secondly, on the script bit I know the line \1% indicates the first line, and anything afterwards is printed out.  But where is the variable?  

So if I want to put in a wait function, and then display on the screen "rebooting computer", I have to write individual reboot functions for every single device.

I could just write a wait(time in seconds, device name as string) function and call that whenever I needed.  But as is, it looks like I'm having to write inline functions.

Joy.  That defeats the entire purpose of object oriented coding and complex scripting languages.