I want the CDP tool to accept text strings / character input for certa

Oy,

A few of the currently non working processes from the CDP tool, ’ Distort - Distort Shuffle’, ’ Blur - Blur Shuffle’ & ’ Grain - Grain Reorder’, need a text string as input for its main parameters to work.

Currently in the tool you can only, set through a slider or manually input through the keyboard, numeric values for its parameters…

I’d like to add functionality of inputting characters, so these non-working processes will work.

Looking through the code in the definition file (row 497 to 516), I think I need to change stuff here;

-- Establish type of argument, value, switch or switch with value
  local function arg_type(arg)
    local type = "value"
    if arg.switch ~= nil then 
      if (arg.min ~= nil) and (arg.max ~= nil) then 
        if arg.input == "brk" then
          type = "switchvaluevariable"
        else 
          type = "switchvalue"
        end
      else
        type = "switch" 
      end    
    elseif arg.input ~= nil then
      if arg.input == "brk" then 
        type = "valuevariable"
      end
    end
    return type
  end

I think I need to create an extra type available next to "valuevariable’ for arg.input specifically for characters.

I’m no coder and don’t plan to start learning lua from ‘hello world’-scratch, like to pragmatically hack this , but am not sure where to go from browsing in the terminal.

Does ‘vb container’ stand for variable box container? Should I create a new local entry for characters?

Someone please direct me to a place where I can read up on how this stuff works, kthnxbye :slight_smile:

YESYESYES +1 more CDP goodness, please.

Well its going to get complicated but here goes…

That function you have listed is fed an ‘arg’ line from the definition and then it works out what kind of argument it is. If you search through the code for its name ‘arg_type’ you will see where it is being called and you can sort of follow the flow of it in the code.

Anyway the first thing you need to do is decide how a text string will be defined in the definitions, in this case I would suggest you use input = “txt” for arguments that require a text string. At this stage you will also need to consider if a text string is only used on its own or can it be combined with a switch or a slider, I can’t remember so will have to look at the CDP docs, but for simplicity lets say a text string is only used on its own. In this case the function code you listed would change to the following:

-- Establish type of argument, value, switch or switch with value
  local function arg_type(arg)
    local type = "value"
    if arg.switch ~= nil then 
      if (arg.min ~= nil) and (arg.max ~= nil) then 
        if arg.input == "brk" then
          type = "switchvaluevariable"
        else 
          type = "switchvalue"
        end
      else
        type = "switch" 
      end    
    elseif arg.input ~= nil then
      if arg.input == "brk" then 
        type = "valuevariable"
      elseif arg.input == "txt"
        type = "textstring"
      end
    end
    return type
  end

Now that function will be able to identify arguments in a definition that require a text string and will return a string value “textstring” when it encounters one.

The next thing to do is look at the code which does something with the information returned by this function.

On line 550 you will see the start of the function (build_arg_params_row)which builds the different GUI elements, this function needs to be adapted so that it can build a text input field, see if you can figure this out by looking at the existing code. Also the ‘Example Tool Gui -> Available Controls’ tool that comes with the scripting pack helps with this.

Once that is done you need to look at the loop starting on line 854 and adapt that so that it is building the right argument string to be fed to the command line argument.

So yeah, like I said it gets complicated :slight_smile:

And thats all assuming that its only one text string thats required, I just had a look at Blur Shuffle and that needs two text strings, so now we need to consider how to define that in a definition and then that cascades down the code so that the right GUI can be built and then right command can be built. This needs to be done for every possible way a text string is used, are the cases where a text string is combined with a switch or with a slider and so on…

Thanks for the in-depth answer Afta8, won’t be bored this weekend :slight_smile:

Anyway the first thing you need to do is decide how a text string will be defined in the definitions, in this case I would suggest you use input = “txt” for arguments that require a text string. At this stage you will also need to consider if a text string is only used on its own or can it be combined with a switch or a slider,

As far as I know and I have tried out most processes, only the few I listed in the top post use a character string in this way, no combinations with switches or sliders. A lot of processes use text input through opening a data file which contains the text, something we can use through input = “brk”, unfortunately this doesn’t work for these particular effects. I’ve tried renaming text files to a string the process should accept as input, but maybe the file type (.txt) is also appended after opening the file so the process returns an error?

The next thing to do is look at the code which does something with the information returned by this function.

On line 550 you will see the start of the function (build_arg_params_row)which builds the different GUI elements, this function needs to be adapted so that it can build a text input field, see if you can figure this out by looking at the existing code. Also the ‘Example Tool Gui → Available Controls’ tool that comes with the scripting pack helps with this.
Once that is done you need to look at the loop starting on line 854 and adapt that so that it is building the right argument string to be fed to the command line argument.

Thanks for giving directions :slight_smile:

And thats all assuming that its only one text string thats required, I just had a look at Blur Shuffle and that needs two text strings, so now we need to consider how to define that in a definition and then that cascades down the code so that the right GUI can be built and then right command can be built. This needs to be done for every possible way a text string is used, are the cases where a text string is combined with a switch or with a slider and so on…

Yep, the 3 processes listed in the first post all need two string inputs (for so called domain & image), I haven’t encountered parameters needing only one. I thought the entered domain and image letters separated by a hyphen would be forwarded to the process as one argument, but now I see from the commandline structure it probably isnt;

blur shuffle infile outfile ABC CBA 3

Maybe this is to much work for only 3 processes that need this particular kind of input, setting up an input = “txt” that can distinguish between both domain/image possibilities? Will check out the gui builder stuff, see if I can make something out of it, cheers.

Ok, thinking about this some more, you could get away with having just one text field.

All you would be adding is the ability to insert a string anywhere in the command line and you could define multiples of these in the definition… That would actually be quite useful for getting some of the other non working features, for example once this is implemented you could create a testing definition that has as many text fields as you want.

Maybe this is not as complex I originally thought :slight_smile:

Anyway let’s pick this up in PM as it’s probably not much use to anyone else having this as an open discussion