Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

String manipulation: get tab contents until special sequence/truncate after special sequence?

in Questions Posts: 1,817

I need to read the contents of a tab but only part of it.

What I’d like to do is, on the tab to be read, put a special sequence behind a comment, maybe something like:

- - &$stophere#@

And only read the tab until there, or else read the whole tab and cut off everything after the special sequence.

Anyone know how I would do that?


  • dave1707dave1707 Mod
    Posts: 10,047

    @UberGoober No problem. I’ll whip something up.

  • dave1707dave1707 Mod
    Posts: 10,047

    @UberGoober Here it is. You can pick you own sequence and put it in the code. Right now I have —#* in the string find line. Enter the project and tab name then press find. It will print out the text up to the find sequence.

    function setup()
    function search()
        local temp=readProjectTab(project..":"
        local pos=string.find(temp,"--#*",1,true)
        if pos~=nil then
            local str=string.sub(temp,1,pos-1)
            print("Not found")
  • dave1707dave1707 Mod
    Posts: 10,047

    @UberGoober This can also be updated to create a new tab with the found text.

  • Posts: 1,817
    That’s fantastic, thanks!
Sign In or Register to comment.