S # Original Language introduction series (3)-cultivation tools,

Source: Internet
Author: User

S # Original Language introduction series (3)-cultivation tools,

S # Original Language introduction series (3)-cultivation tool Author: Shone

Copyright Disclaimer: This article is an original article by the blogger. You are welcome to repost or reference the content, but please indicate the source.

Ben Bo Abstract: the best way to understand a language is to enter the code in the editor according to the syntax rules, then run and check whether the results meet expectations. This blog post introduces the software interface of S # editor and the main functions of relevant modules, and expresses and generates ry through S # code with Local variables, this illustrates the common coding process of S # code.

Original software: S # language editor, runtime environment. NET 4.0, green software, direct running of a single EXE, no side effects. Online drive download link for https://pan.baidu.com/s/1dF4e08p

 

Today, a new section specifically introduces the editor function. The language function will be detailed in the subsequent series.

I. Tool menu bar

The editor toolbar provides the following functions:

  • Open button: Read the existing S # text file (*. shone) to the editing area.
  • "Save" button: Save the currently edited S # text to the specified file (*. shone.
  • Cut button: Cut the selected S # code text to the clipboard.
  • Copy button: copy the selected S # code text to the clipboard.
  • Paste button: copy the S # code text from the clipboard to the editing area.
  • "Undo" button: undo the last edit operation.
  • "Redo" button: redo the last Undo operation.
  • "Streamline" button: Empty and highlighted S # text that meets the syntax in the editing area. For example, eval (a = 1, B = 2: a + B) will simplify the Compact text: eval (a = 1, B = 2: a + B ).
  • "Format" button: format the S # text in the editing area and highlight the syntax. For example, eval (a = 1, B = 2: a + B) will be formatted into the following S # text, which is more neat and beautiful. Note that the simplification and formatting only affect the appearance of S # code, does not affect the semantics and computing result of S # code.

Eval

(

A = 1,

B = 2:

A + B

)

  • "Convert to computing value" button: Replace the current S # code with the S # code corresponding to the final calculation result. Note that the code in the intermediate process will be erased, such as eval (a = 1, B = 2: a + B) is converted to 3.

Menu Bar functions include:

  • The "constant" Main Menu provides shortcut inputs that are commonly used for π, ε, e, ∞, true, and false.
  • The "function" Main Menu provides quick input examples for most advanced functions.
  • The "statement" Main Menu provides quick input examples for most advanced statements.
Ii. code editing area

The S # code editing area contains three tabs: "S # code editing", "two-dimensional editing", and "computing result ", click different tabs to switch to the corresponding S # code editing or viewing mode.

1) S #Code editing

S # code editing is the default syntax highlighted S # code text editing mode. In addition to the regular text input function, as described above, when you enter letters, periods, or Ctrl + J keys, a drop-down selection box is displayed to facilitate the input of various symbols such as constants, variables, operators, functions, attributes, or method names. In addition, place the cursor over a variety of symbols to display the corresponding format, description, and current result of the symbol.

When you use the keyboard or mouse to edit the S # code text to change the current input or selection area, the corresponding row, column, position, and number of selected characters are displayed in the following status bar.

2) Two-Dimensional editing

The two-dimensional editing mode provides a more intuitive visual editing and viewing method for the s # Code Composition Structure and 2D geometric evaluation values, which is particularly useful for various complex S # codes containing geometric functions. For example, the S # code below is used to express the lateral section of the hanger. In two-dimensional editing mode, the location and shape of the ry corresponding to the S # code are displayed in the graphic area. Click the label of different S # code nodes. In the graphic area, the labels and graphs are highlighted in red. You can click the label to view the graph generation process.

RectCWH (0, (0,-200), 740,400 ). insPoint (0, (0,-860 )). fillet ([100,0]). merge (circr (0, (0,-700), 40 ))

 

In the graphic area, you can also press and hold the middle mouse buttons to pan and scroll the middle mouse buttons for scaling. You can also right-click the menu to configure the graphic display.

3) Calculation Result

The calculation result is used to display the computing result of the currently edited entire S # code or a selected S # code node. There are three methods to select the S # code node: one is to use the mouse to click the specified text in the S # code editing mode, the second is to use the mouse to click the specified tag or image in the two-dimensional editing mode, and the third is to use the mouse to click the specified node in the right syntax tree. Once the selected node is changed, the calculation result text box results also change, and the selected node graph in the lower right corner also changes accordingly.

 

The right panel area contains multiple switch buttons, including "lexical", "Syntax", "Search", and "all ", click different buttons to switch to the corresponding secondary editing or viewing function panel.

3. Secondary panel on the right

1) Lexical panel

All S # code has a corresponding lexical tree. Each of its Tree nodes is an inseparable minimum symbolic unit.

 

Click different Tree nodes, and the node text can be modified independently in the edit box below.

In addition, right-click the selected node to bring up the menu. Select "" to locate and select the corresponding text in the S # code text editing box.

2) Syntax panel

All S # codes that comply with the S # syntax rules have corresponding syntax trees. Each of these Tree nodes is the corresponding Syntax Parsing node. Note that the S # code that does not comply with the syntax rules is only the lexical tree but not the syntax tree. The "Syntax" switch button is dimmed.

 

Click different Tree nodes, and the node text can be modified independently in the edit box below. If the calculated value of the selected node is a ry, the preview area in the lower right corner shows the corresponding graph of the selected node. Place the cursor on the syntax tree node to display the corresponding format, description, and current result of the node symbol.

In addition, right-click the selected node to bring up a menu. The menu items are described as follows:

Locate text: you can locate and select the corresponding text in the S # code text editing box.

Copy S # code: copy the S # code text of the selected node to the system clipboard.

Copy result: You can copy the computing result of the selected node to the system clipboard. Note that the result is usually an S # code, which only contains constants and does not contain any variables.

Copy real value: You can copy the actual computing result of the selected node to the system clipboard. Note that in most cases, the real value is similar to the result, but there are differences when expressing strings. The real value does not contain quotation marks and escape characters.

3) Search panel

This Panel provides the function to find or replace the content of the S # code text editing box. You can select different uppercase/lowercase or full-text matching conditions when specifying the content to be searched. In addition, you can replace the specified content one by one or all at a time.

 

4) All panels

All panels are used to provide the syntax format and input example of all S # code symbols (including various constants, operators, functions, attributes, and methods) preset by S # language, this allows you to search, browse, or enter the specified S # code symbol based on the data type.

Double-click or drag from the S # code symbol list to insert the corresponding S # code symbol example at the current S # code editing position, you can click the category drop-down box to switch to a different data type S # code symbol category.

Iv. S # sample code

The purpose of this example is to express and generate the ry through the S # code with a local variable. Note that the examples are mainly used to describe the common coding procedures of S # code. The specific formulas or functions used in the examples do not need to be further explored. We will introduce them in detail later.

 

1) Requirement Analysis of local variables

Assume that the width of each bar is W, the height is H, and the radius of the rounded corner is R. The vertical columns and spacing of array images are Nx and Dx, and the horizontal rows and spacing are Ny and Dy, respectively.

2) Input the local evaluate basic S # code

You can use the eval function to set local variables and evaluate the final S # code. Open the S # code editor and enter the following S # code.

 

3) Changed to a single bar chart # code

A single columnar image can use a wide-height rectangle (RectCWH ry function) for an inverted rounded corner (. the final evaluation value of S # code 0 in the above eval function is changed to Code such as S.

 

4S # code

You can use the horizontal vertical center array (. Panscar method) to generate a columnar graph array. Continue to modify the final evaluation value S # code in the above eval function, as shown in.

 

5) Test S # code and output AutoCAD graphics

The code for testing S # is relatively simple. You can directly change the value of the local variable in S # code. For example, you can change W to 20 to see that each bar chart is wider. After modifying the value assignment of a local variable, select "output to AutoCAD window" in the CAD menu to generate the corresponding CAD image and use it for design and other purposes. Note: Because this function depends on CAD that has been stripped off, it mainly describes the purpose and makes the instance more complete and trustworthy.

 

 

Copyright Disclaimer: This article is an original article by the blogger. You are welcome to repost or reference the content, but please indicate the source.

Original software: S # language editor, runtime environment. NET 4.0, green software, direct running of a single EXE, no side effects. Online drive download link for https://pan.baidu.com/s/1dF4e08p

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.