Home › Forums › General › Programming › building text strings
Tagged: console
- This topic has 15 replies, 2 voices, and was last updated 6 years, 9 months ago by human fly.
-
AuthorPosts
-
May 27, 2017 at 10:01 am #72200
i’ve been trying to find out about manipulating text,
fetching it and putting it in a string.which is elementary to many of you, but a small success
for me 🙂so i made this little toy for making a dummy sysex string
(not a ‘proper’ message yet, i’m just finding out how it
works):https://app.box.com/s/xw3n2ehljf95o2v7n2e39x7zs4cuizsv
(win exe in zip 4.9mb)
if anyone’s interested in talking about this i’ll post
the bpanelz.
(nb: random not working yet)
basically, it’s a series of text entries as ‘bytes’,
and ‘makeString’ concatenates them with spaces and
displays it on a ‘string’ text label; to help me
visualize where i can go with it.i’d like to consult about a few things i can do,
as i’m just cribbing from other methods here.May 27, 2017 at 1:53 pm #72201Don’t understand what you are looking for…
Concatenation of strings is straightforward in Lua (just use ..).
Plenty of strings manipulation function on typical Lua training sites.In my Pro2 panel, i used trim(), rtrim(), ltrim(), split()…
Look in method Miscellaneous under Panel methodsMay 27, 2017 at 2:04 pm #72202ok thanks, i wasn’t aware of those.
(*for example*)it’s a big deal for me lol – “the trick i learnt today”
very satisfying 🙂 messing around with something like
this is my way of learning how to use it.a small step towards grasping the handling of sysex
messages, building tables, etc. – i will upload the
bpanelz when i’ve tidied it up.edit: i found ‘typical training sites’ not much fun,
and i’ve got a lot further looking at what you and
others have done, which whilst possibly ‘unethical’
(although i wouldn’t see why), provides a context
and a framework to get started with.
that’s my current ‘plateau’. i agree that i will need
to look deeper into it, but with allowed time etc.
i’ve got plenty to look at for now.this mini-panel is my current ‘testlab’, that i’m
building stuff into bit by bit, until i’ve got
something i can use. nb: it’s quite a lot to take
in, the patch retrieve/screen update, on first
approach, and people have used different methods,
so i’m just seeing what i feel comfortable with,
getting my head round it, in stages.May 27, 2017 at 2:40 pm #72203what am i looking for?
this part was about figuring out how to fetch data
and put it somewhere.
i think what i’d like to do next is be able to send
the ‘console’ result to a LCDlabel. then i can practice
applying some fundamental principles. i haven’t had much
luck with the Lua console so far (so i’ve bypassed that
for the time being).-looking for economical ways of avoiding repetition.
-am seeing how declaring at panel load is desirable
(to avoid repetition)
-is it possible+desirable to create certain functions
at panel load? why not just create everything there,
and call it later?- This reply was modified 6 years, 9 months ago by human fly.
May 27, 2017 at 9:05 pm #72205you canb puit all your home made functions in one method that you call “Miscellaneous”
They are available at all time and this has nothing to do with “at panel load”.
At panel load is only used to assign variables that are used later (for example, I assign all my modulators because those variables are used in all my OnClick / OnChange methods.May 27, 2017 at 10:31 pm #72206ok, i saw the miscellaneous method.
is that an ‘official’ method name for that purpose?
and it serves the same purpose as if you loaded them
with ‘panel loaded’?May 28, 2017 at 8:41 am #72210ok: i want to do this:
i have a button called ‘consoletrig’ -momentary-, and a
LCDLabel called ‘console1’. i’m calling the method ‘toConsole’,
called by the button.the method goes eg:
console ("receiving sysex")
nb: i do now see how console works: the small dev window reports
all results and errors. if you want to see the result in the big
console window, you have to have it open before you trigger the
event that runs the method. – i’m getting a weird thing, though:
the message is triggered twice, even if i only make it a single
value button.(i can also see the red error text now, that i thought
wasn’t happening anymore- that’s it, it used to appear in the other
window)so: what i would now like to do is ‘get’ the text that was sent
to console and have it displayed in the LCDlabel.i’ve tried a few things and i don’t know how it should be treated,
ie: as ‘text’ ? it didn’t likegetText()
and tells me i’m
trying to index global ‘console’ (a function value)any ideas for this? i would like a little on-panel console monitor.
at least for the time being, as a tool. even if it just displays
‘correct’ results, and doesn’t give the error messages (although
that would be good too).i do probably need to think further on the role and place of the
console output. i can see it ren’ed in methods, where it’s been
left in. maybe i can find an example of where it’s used to fetch
data.May 28, 2017 at 8:47 am #72211a quick google delivered this quote:
“the console is like a toilet. You can look at what’s in there
with your eyes, but touching it with your code is out of bounds.”How to fetch the fetch data from the console log? from javascript
but i see someone suggests
io.write
. that would make sense,
if i can find out how to use it to send console output as
text to the lcdlabel.- This reply was modified 6 years, 9 months ago by human fly. Reason: moreinfo
May 28, 2017 at 9:14 am #72213another suggestion from that page:
dumpoutput = function() local file = io.write([path to file dump here], "w+") for i, line in ipairs ([console output function]) do file:write("\n"..line); end end
but i don’t know if that is valid for Ctrlr, and i don’t know
what ‘w+’ is.he also says this:
“Note that the console output function has to store the output of the console in a table. To clear the console at the end, just doos.execute( "cls" )
.”edit: ah, ‘w+’ >
https://www.tutorialspoint.com/lua/lua_file_io.htmwe-eee-ee, frying my brain early in the morning..
May 28, 2017 at 9:22 pm #72214right well i went back to looking at panels, jax8p by
Carl Licroy – and i note that he uses console quite a lot.if you look at ‘midi message received’ method, each stage
is giving feedback via console. but what is that used for?
doesn’t seem to be destined for any display, so it must be
for error checking. ah yes: i’ve just seen everything that
ends up on the console from buttons on that panel – you need
to have the console page open before you do anything to see
anything appear.(wish someone had just told me haha)had hoped to discover it was used to send to a label but it
looks not to be the case. so maybe i’ll just forget about it
and work on some other approach, like ‘getRange’ and tables.
(still curious whether iowrite will do it though)edit: and i just realised ‘console’ does display in the
Lua editor compiler – that makes more sense. i just wasn’t
using it, and seeing it – because you tend not to re-compile
methods from panels when you’re looking at them.May 29, 2017 at 10:12 am #72216Look in method Miscellaneous under Panel methods
i see, i misunderstood that: it appears that any named method
is available if it exists. i made something called any_old_name(),
with a console output, and i can just refer to it, with nothing else,
in another method, and it runs.ie: so if i have, say, 2 functions, one with a console output, and
the other making a LED graphic switch on, i just need to stick those
function by name in any other method i want to run.so i can have a function attached to a button that goes:
function runThis() any_old_name() lightLED() end
as long as those exist elsewhere.
🙂 obvious to you. so all methods are loaded whether assigned to
anything or not. and panelloaded is only for specific actions
you want for the startup. ok.i’m thinking about how i might organize my projects and
centralise – which of course is what getPatchData etc methods
do.the panels are very good to look at, most helpful of all, so far.
the tutorials point pages are useful too.
although i find i’m having to jump all over the place to see what
comes from where – it takes(..me) time to piece it all together
-and digest the info –
i’m trying to see what is ‘standard’ in terms of panel update and
send/receive operations. quite fascinating, anyway, for an old
midi head to get to grips with.May 29, 2017 at 10:29 am #72217what i should probably be asking is this:
could you please give a definition/description of
the console and its role.(what can be done with it?)May 29, 2017 at 9:25 pm #72218amazing… you are doing the questions and the answers… however still looking to things in a too complex way 😉
The console is used to display some info while programming or while using a panel but for verifications. I would not use it as an external output window but maybe some Ctrlr developers would do it.
The console is available at 2 places: separate window or as the 4th tab within the Lua editor. I’m using that one most of the time.
You type a statement in the bottom part and get the result in the upper part.
A statement can be anything: one line of code, a check for a variable…When you type a line of code it is executed. This can be usefull at dev time when you forgot to do something. In that case, the statement is just repeated in the upper part. Example: myVar=10 typed in the lower part gives >>> myVar=10 in the upper part.
To check the value of a variable, you use the console(string) function. The argument must be a string. If not then you get an error message. SO, safest is to always use tostring() to convert.
Try with
console(tostring(myVar))
You will get
>>> console(tostring(myVar))
10
in the upper part.Now, you can include this console() statement in your Lua code and when the method will run it will write its info in the console window (separate or at the bottom of the Lua editor. The console must be opened prior.
You had also a question about my Miscellaneous method containing a lot of functions.
You name your methods as you want. I discovered that a Ctrlr method is a recipient for any function so I started grouping different functions under one method.
Like Miscellaneous, SpecificDisplays, SupportMethods…Hope that this time you understood the console() principle.
ANd now I have my text for the console explantion in the step by step guide 🙂May 29, 2017 at 10:32 pm #72219“ANd now I have my text for the console explantion in the step by step guide ?”
hehe 🙂 and i’m the guinea pig (cobaye).
*thank you* for taking the time to explain that.as you saw in my sequence of posts over a few days, the foggy haze
was starting to clear… there’s a difference with my initial
question about console, and a secondary idea, that is in fact
achieved by other means.
!plenty to keep me busy for the next few days.
oh: btw, this morning i saw something interesting in
dasfaker’s VirusT1 panel, where he uses getModulatorByIndex in
the assignVar table instead of getModulatorByName.
i think you have to be very organised to use that 🙂May 30, 2017 at 10:10 pm #72220Well, somewhere it is the same… provided that you declare all your mods (I mean assign to variables) in some method launched at the beginning (this is advised by atom).
Look at my method AssignModulators.
I’m using getModulatorByName but I could also used getModulatorByIndex and used for example the NRPN number as index. But which number then for non synth related mods?
I think it is easier to use getModulatorByName and corresponding variable names.May 31, 2017 at 7:35 am #72224yes, i agree: it is much easier to see what you are doing
having the modulator name to refer to.the assignVar/declare all modulators method: is perhaps
best done as a table ? to allow ‘getRange’ etc. statements to
be used? i would like to make one method, one table, with all
the main information i will need for the panel, so i don’t need
to skip around different methods so much.for example: i was trying out the randomizer method, and saw
the method where it gets modulators by group name – i didn’t
manage to make that work on my thing yet, was mainly curious
to see if i could get it to work.another use of the console i was thinking of was to generate
numerical lists automatically, rather than typing them out
the long way, simply to have something to copy into the method.
ie: list all modulators by name with ” ” with a getRange instruction,
to save time and work.
these are things i must practice a bit 🙂btw: (Mr Manual Writer) i’m referring to the Utility pane a lot
more now, to remember what parameters are available, and what
they are called. did not initially realise that it was for that.- This reply was modified 6 years, 9 months ago by human fly.
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.