# Scripting &kmplot;

A new feature in KDE 3.4 is that you can write scrips for Kmplot with DCOP. For example, if you want to define a new function `f(x)=2sin x+3cos x`, set its line width to 20 and then draw it, you type in a console:

`dcop kmplot-PID Parser addFunction "f(x)=2sin x+3cos x"` As a result, the new function's id number will be returned, or -1 if the function could't be defined.

`>dcop kmplot-PID Parser setFunctionFLineWidth 20 ID` This command sets the function with the id number ID the line width to 20.

`>dcop kmplot-PID View drawPlot` This command repaints the window so that the function get visible.

A list over the available functions:

KmPlotShell fileOpen &url

  Load the file `url`.

MainDlg isModified

  Returns true if any changes are done.

MainDlg editColors

  Opens the color edit dialog.

MainDlg editAxes

  Opens the coordinate system edit dialog.

MainDlg editScaling

  Opens the scaling edit dialog.

MainDlg editFonts

  Opens the fonts edit dialog.

MainDlg editConstants

  Opens the constants edit dialog.

MainDlg newFunction

  Opens the new function plot dialog.

MainDlg newParametric

  Opens the new parametric plot dialog.

MainDlg newPolar

  Opens the new polar plot dialog.

MainDlg toggleShowSlider0

  Shows/hides parameter slider window number 1.

MainDlg toggleShowSlider1

  Shows/hides parameter slider window number 2.

MainDlg toggleShowSlider2

  Shows/hides parameter slider window number 3.

MainDlg toggleShowSlider3

  Shows/hides parameter slider window number 4.

MainDlg slotSave

  Saves the functions (opens the save dialog if it is a new file).

MainDlg slotSaveas

  The same as choosing File Save as in the menu.

MainDlg slotEditPlots

  Opens the edit plots dialog.

MainDlg slotPrint

  Opens the print dialog.

MainDlg slotExport

  Opens the export dialog.

MainDlg slotSettings

  Opens the settings dialog.

MainDlg slotNames

  Shows a list of predefined math functions.

MainDlg slotCoord1

  Coordinate System I.

MainDlg slotCoord2

  Coordinate System II.

MainDlg slotCoord3

  Coordinate System III.

MainDlg getYValue

  The same as choosing Tools Get y-Value... in the menu.

MainDlg findMinimumValue

  The same as choosing Tools Search for Minimum Value... in the menu.

MainDlg findMaximumValue

  The same as choosing Tools Search for Maximum Value... in the menu.

MainDlg graphArea

  The same as choosing Tools Area Under Graph... in the menu.

Parser addFunction f_str

  Adds a new function with the expression `f_str`. If the expression does not contain a function name, it will be auto-generated. The id number of the new function is returned, or -1 if the function couln't be defined.

Parser delfkt id

  Removes the function with the id number `id`. If the function could not be deleted, false is returned, otherwise true.

Parser setFunctionExpression f_str id

  Sets the expression for the function with the id number `id` to `f_str`. Returns true if it succeed, otherwise false.

Parser countFunctions

  Returns the number of functions (parametric functions are calculated as two).

Parser listFunctionNames

  Returns a list with all functions.

Parser fnameToId f_str

  Returns the id number of `f_str` or -1 if the function name `f_str` was not found.

Parser id x

  Calculates the value `x` for the function with the ID `id` or returns 0.0 if `id` does not exist.

Parser functionFVisible id

  Returns true if the function with the ID `id` is visible, otherwise false.

Parser functionF1Visible id

  Returns true if the first derivative of the function with the ID `id` is visible, otherwise false.

Parser functionF2Visible id

  Returns true if the second derivative of the function with the ID `id` is visible, otherwise false.

Parser functionIntVisible id

  Returns true if the integral of the function with the ID `id` is visible, otherwise false.

Parser setFunctionFVisible visible id

  Shows the function with the ID `id` if `visible` is true. If `visible` is false, the function will be hidden. True is returned if the function exists, otherwise false

Parser setFunctionF1Visible visible id

  Shows the first derivative of the function with the ID `id` if `visible` is true. If `visible` is false, the function will be hidden. True is returned if the function exists, otherwise false.

Parser setFunctionF2Visible visible id

  Shows the second derivative of the function with the ID `id` if `visible` is true. If `visible` is false, the function will be hidden. True is returned if the function exists, otherwise false.

Parser setFunctionIntVisible visible id

  Shows the integral of the function with the ID `id` if `visible` is true. If `visible` is false, the function will be hidden. True is returned if the function exists, otherwise false.

Parser functionStr id

  Returns the function expression of the function with the ID `id`. If the function not exists, an empty string is returned instead.

Parser functionFColor id

  Returns the color of the function with the ID `id`.

Parser functionF1Color id

  Returns the color of the first derivative of the function with the ID `id`.

Parser functionF2Color id

  Returns the color of the second derivative of the function with the ID `id`.

Parser functionIntColor id

  Returns the color of the integral of the function with the ID `id`.

Parser setFunctionFColor color id

  Sets the color of the function with the ID `id` to `color`. True is returned if the function exists, otherwise false.

Parser setFunctionF1Color color id

  Sets the color of the first derivative of the function with the ID `id` to `color`. True is returned if the function exists, otherwise false.

Parser setFunctionF2Color color id

  Sets the color of the second derivative of the function with the ID `id` to `color`. True is returned if the function exists, otherwise false.

Parser setFunctionIntColor color id

  Sets the color of the integral of the function with the ID `id` to `color`. True is returned if the function exists, otherwise false.

Parser functionFLineWidth id

  Returns the line width of the function with the ID `id`. If the function not exists, 0 is returned.

Parser functionF1LineWidth id

  Returns the line width of the first derivative of the function with the ID `id`. If the function not exists, 0 is returned.

Parser functionF2LineWidth id

  Returns the line width of the first derivative of the function with the ID `id`. If the function not exists, 0 is returned.

Parser functionIntLineWidth id

  Returns the line width of the integral of the function with the ID `id`. If the function not exists, 0 is returned.

Parser setFunctionFLineWidth linewidth id

  Sets the line width of the function with the ID `id` to `linewidth`. True is returned if the function exists, otherwise false.

Parser setFunctionF1LineWidth linewidth id

  Sets the line width of the first derivative of the function with the ID `id` to `linewidth`. True is returned if the function exists, otherwise false.

Parser setFunctionF2LineWidth linewidth id

  Sets the line width of the second derivative of the function with the ID `id` to `linewidth`. True is returned if the function exists, otherwise false.

Parser setFunctionIntLineWidth linewidth id

  Sets the line width of the integral of the function with the ID `id` to `linewidth`. True is returned if the function exists, otherwise false.

Parser functionParameterList id

  Returns a list with all the parameter values for the function with the ID `id`.

Parser functionAddParameter new_parameter id

  Adds the parameter value `new_parameter` to the function with the ID `id`. True is returned if the operation succeed, otherwise false.

Parser functionRemoveParameter remove_parameter id

  Removes the parameter value `remove_parameter` from the function with the ID `id`. True is returned if the operation succeed, otherwise false.

Parser functionMinValue id

  Returns the minimum plot range value of the function with the ID `id`. If the function not exists or if the minimum value is not definied, an empty string is returned.

Parser functionMaxValue id

  Returns the maximum plot range value of the function with the ID `id`. If the function not exists or if the maximum value is not definied, an empty string is returned.

Parser setFunctionMinValue min id

  Sets the minimum plot range value of the function with the ID `id` to `min`. True is returned if the function exists and the expression is valid, otherwise false.

Parser setFunctionMaxValue max id

  Sets the maximum plot range value of the function with the ID `id` to `max`. True is returned if the function exists and the expression is valid, otherwise false.

Parser functionStartXValue id

  Returns the initial x point for the integral of the function with the ID `id`. If the function not exists or if the x-point-expression is not definied, an empty string is returned.

Parser functionStartYValue id

  Returns the initial y point for the integral of the function with the ID `id`. If the function not exists or if the y-point-expression is not definied, an empty string is returned.

Parser setFunctionStartXValue min id

  Sets the initial x point for the integral of the function with the ID `id` to `x`. True is returned if the function exists and the expression is valid, otherwise false.

Parser setFunctionStartYValue max id

  Sets the initial y point for the integral of the function with the ID `id` to `y`. True is returned if the function exists and the expression is valid, otherwise false.

View stopDrawing

  If &kmplot; currently is drawing a function, the procedure will stop.

View drawPlot

  Redraws all functions.