steve909 Posted July 25, 2012 Posted July 25, 2012 Are there any drivers (or maybe there's some built in functionality that i'm not aware of) to manipulate strings?Let's say I want to take a variable that contains text like "info1_info2" and I want to separate that string into 2 pieces such that i can separately access "info1" and "info2"?Thanks,Steve
C4RVA Posted July 26, 2012 Posted July 26, 2012 This could be done with a driver works driver. Explain exactly what you are trying to do.
steve909 Posted July 27, 2012 Author Posted July 27, 2012 Thanks for the reply.I'm using the driver RyanE posted in this thread: http://c4forums.com/viewtopic.php?id=12278 (btw, thanks Ryan!)I'm currently playing around with my cameras and their ability to trigger/call a webpage...so let's say the camera detects motion and I want to lock or unlock a specific door. I could have the cameras send:http://192.168.1.1:8080/lock_frontdooror it could call:http://192.168.1.1:8080/unlock_reardoorIn theory I could test the one "COMMAND" for all possible permutations, but I was hoping to be able to take the "COMMAND" and break it apart into two variables one that stores whether to lock or unlock and the other to store which door. This example may not make a lot of practical sense, but i'm just experimenting for now - I can imagine some "COMMAND"s being more complex with more than two variables, etcThanks,Steve
cdepaola Posted August 2, 2012 Posted August 2, 2012 It's questions like this that make me want to pull apart the software to see what it's doing and how. "Composer" is a nice program and super simple for the uninitiated but it almost seems like a hindrance to someone who knows how to write code. Of course not knowing the inner working of C4 or ComposerPro I may be wrong. Is it sickness that I'd be willing to work for someone, doing remote programing, for nothing more thpros copy of Pro and really dig into my system and see how its working and how far I can push it. To me figuring out and writing code is better then an xbox or playstation
dgbrown Posted August 2, 2012 Posted August 2, 2012 The SDK docs will shed quite a bit of light on things for an experienced programmer.
alanchow Posted August 28, 2012 Posted August 28, 2012 It's questions like this that make me want to pull apart the software to see what it's doing and how. "Composer" is a nice program and super simple for the uninitiated but it almost seems like a hindrance to someone who knows how to write code. Of course not knowing the inner working of C4 or ComposerPro I may be wrong. Is it sickness that I'd be willing to work for someone, doing remote programing, for nothing more thpros copy of Pro and really dig into my system and see how its working and how far I can push it. To me figuring out and writing code is better then an xbox or playstationNothing stopping you from writing your own composer program. At the end of the day all its doing is outputting XML to Control4 for its project. Just need to shell into your controller and view DirectorState.xml to get an idea of how it all works.
KyleS Posted August 29, 2012 Posted August 29, 2012 There's other ways to do it, as you can see here http://stackoverflow.com/questions/1426954/split-string-in-lua but this might be a bit easier to follow:s = "lock_frontdoor"splitLocation = string.find(s, "_")firstHalf = string.sub(s, 0, splitLocation - 1)secondHalf = string.sub(s, splitLocation + 1)print("String: " .. s , " splitLocation: " .. splitLocation .. " firstHalf: " .. firstHalf .. " secondHalf: " .. secondHalf)
RyanE Posted August 29, 2012 Posted August 29, 2012 It's easier to use Lua patterns. Assuming you will always have one and only one underscore, I'd do it like this:local _, _, cmd, location = string.find(s, "(.*)_(.*)")Example:local s = "lock_frontdoor"local _, _, cmd, location = string.find(s, "(.*)_(.*)")print(cmd, location)prints out: lock frontdoorRyanE
Recommended Posts
Archived
This topic is now archived and is closed to further replies.