2

NppExec dochelp says:

  • Now the NPP_EXEC command can pass arguments to the script. These arguments can be accessed in the script through the following macro-variables: $(ARGC), $(ARGV), $(ARGV[n]). Example: npp_exec "script name" param_1 "param 2". This example sets the following values for the script: $(ARGC) = 3; $(ARGV) = param_1 "param 2"; $(ARGV[0]) = script name; $(ARGV[1]) = param_1; $(ARGV[2]) = param 2.

But I am not sure where to set it up. Is it in Execute box or in Advanced Option?

For example,

  # counter_thread.rb
count = 0
counter_thread = Thread.new do
  1.upto(1000000) { count += 1; }
end

counter_thread.join unless ARGV[0]
puts "The counter was able to count up to #{count}."

Test 1 : NppExec runs this fine since no argument

counter_thread.rb
The counter was able to count up to 1000000.

Test 2 : Would like to know settings for the one below . (dont_call_join is an argument here)

counter_thread.rb dont_call_join
Abbas
  • 6,720
  • 4
  • 35
  • 49
gigaimage
  • 29
  • 5

1 Answers1

0

Assuming counter_thread.rb is a file that is currently open in Notepad++, then ruby counter_thread.rb dont_call_join will pass dont_call_join as an argument into Ruby in the usual way (i.e. via ARVG).

This will run your code as you seem to expect -- if you pass in an argument to the Ruby program, the counting thread does not run, otherwise it runs.

Perhaps this is the better example?

      inputbox "What is your name?" : Nobody    
      ruby -e "puts \"Hello #{ARGV[0]}!\" " $(INPUT[1])

The first line pops up a message box to get the user input (defaults to Nobody). The second line passes user input to the ruby one liner program. NppExec facilitates.

Assad Ebrahim
  • 6,234
  • 8
  • 42
  • 68