Skip to content

Operators and proceduresđź”—

Calling operatorsđź”—

When using one of the HALCON operators, HALCON Script behaves identical to HDevelop, with this general signature of an operator:

operator (iconic input : iconic output : control input : control output)

More Info

For more information about control and iconic data, see Basic types of parameters.

Declaring and calling proceduresđź”—

In HALCON Script, you write the code of a procedure just as you write the “main” program part, as procedures are just a part of the program file. Procedures are distinguished by certain keywords.

Adhere to the following:

  • A procedure must start with one proc statement and end with one endproc statement.
  • A procedure by default has private scope, that is, it is only accessible within the current file. To create a public procedure (that is, make it accessible from other files), declare it as such by adding the public statement before the first proc statement.
  • You can either use a dedicated mainprocedure or put all lines of code that are not part of a procedure (“standalone statements”) at the end of the program. This means: In the HSCRIPT file, all procedures (that is, all proc ... endproc blocks) must come before any standalone statements.
  • There can only be one procedure called main. If this procedure exists (that is, if there is a public proc main (...) endproc block), it serves as the entry point of the program. In this case, the main block does not need to be at the end, but there must not be any further standalone statements.
  • Only a public main procedure can be used for running a program. This means that the main procedure must start with the corresponding access specifier: public proc main.
  • Parameters are defined using the following keywords:

    • Iconic input: object keyword

    • Control input: tuple keyword

    • Iconic output: out object keyword

    • Control output: out tuple keyword

  • Parameters must be separated by , (comma).

General syntax of procedure declaration
proc proc_name (object InputImage, tuple InputParam, out object OutputImage, out tuple OutputParam)
  (...)
endproc

The above syntax creates a procedure with private scope by default. To specify the scope of a procedure, use the private or public keyword:

Syntax of procedure declaration, private scope
private proc proc_name (...) # (1)!
  (...)
endproc
  1. The private keyword is optional.
Syntax of procedure declaration, public scope
public proc proc_name (...)
  (...)
endproc

When declaring a procedure, the order of the parameter types (iconic in, control in, iconic out, control out) is not fixed, as can be seen in the following example.

Example: Procedure declarations with different parameter order

The following two declarations both are valid:

proc initialize_visualization_1 (tuple Width, 
                                 tuple Height, 
                                 out tuple WindowHandle, 
                                 out tuple WindowHandleText)
  <code of procedure>
endproc
proc initialize_visualization_2 (out tuple WindowHandle, 
                                 out tuple WindowHandleText,
                                 tuple Width,
                                 tuple Height)
  <code of procedure>
endproc
While both procedures expect identical input and output parameters, you have to provide them in the corresponding, correct order when calling the procedures:
initialize_visualization_1 ('600', '400', WindowHandle, WindowHandleText)

initialize_visualization_2 (WindowHandle, WindowHandleText, '600', '400')

Procedure resolutionđź”—

When your HSCRIPT file contains one or more correct import statements, all procedures from the imported files become available within your file. That means, you can call the external procedures from anywhere within your own code.

Importing procedures is not transitive. That means, if your own file imports from other_file.hscript, and other_file.hscript then imports from yet_another_file.hscript in turn, you will nonetheless only be able to access the procedures from other_file.hscript – but not from yet_another_file.hscript.

Keep the following in mind:

  • If your own file locally contains a procedure with the corresponding name, this procedure will be called but none of the external ones.
  • If there are only external procedures available, HDevelopEVO will arbitrarily choose one of them. There is no way to controll which one at the moment.
  • HDevelopEVO will report a warning that the regarding call is ambiguous and it will list the file from which the procedure will be called as well as the file containing the procedure that is hidden.

Preview restriction

Currently, there is no solution to select the procedure to call if there is more than one possible candidate.