⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scripts.gml

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 GML
📖 第 1 页 / 共 4 页
字号:
.seethis elseif
.seethis else
.seethis endif
.alsosee end
.endfunc

.begfunc INPUT
.syntx * INPUT &lt.v1&gt.
.begdescr
Open a window (the
.keyref commandwindow
:cont.) and get a string from the user.  The string is assigned to the
variable &parm1.
:period.
.np
If &parm1 was assigned a value before the
.keyword input
script command was executed, then that value is used as a prompt
string in the input window.
.enddescr
.returns begin
.retval ERR_NO_ERR.
The setting of
.keyword lastrc
if a string was entered.
.retval NO_VALUE_ENTERED
The setting of
.keyword lastrc
if the user pressed
.param ESC
to cancel the input string.
.returns end
.xmplsect begin
.begxmpl input %(str)
Get a string from the user, placing the result in the local variable
.var %(str)
:period.
If
.var %(str)
had no previous value, then the user would be prompted with:
.millust begin
Enter Value:
.millust end
However, if
.var %(str)
had the value
.param Type in a filename:
:cont.,
then the user would be prompted with:
.millust begin
Type in a filename:
.millust end
.endxmpl
.xmplsect end
.alsosee begin
.seethis floatmenu
.seethis get
.alsosee end
.endfunc

.begfunc LABEL
.syntx * LABEL &lt.name&gt.
.begdescr
Defines the a label with the name &parm1 at the current line in the script.
.enddescr
.alsosee begin
.seethis goto
.alsosee end
.endfunc

.begfunc LOOP
.syntx * LOOP
.begdescr
Start a loop block.  This is the top of the block, after a
.keyref continue
:cont.,
.keyref endloop
or
.keyref until
control returns to the instruction after the
.keyword loop
command.
.enddescr
.alsosee begin
.seethis break
.seethis continue
.seethis endloop
.seethis endwhile
.seethis loop
.seethis quif
.seethis until
.seethis while
.alsosee end
.endfunc

.begfunc NEXTWORD
.syntx * NEXTWORD &lt.srcvar&gt. &lt.resvar&gt.
.begdescr
Remove the next space-delimited word from the variable &parm1
:period.
The word is placed in the variable specified by &parm1.
:period.
Both &parm1 and &parm2 must be variables only.
.enddescr
.xmplsect begin
.begxmpl nextword %a %b
If %a has
.mono 'this is a test'
assigned to it, then after this command
is processed, %a will have
.mono 'is a test'
assigned to it, and %b will have
.mono 'this'
assigned to it.
.endxmpl
.xmplsect end
.endfunc

.begfunc QUIF
.syntx * QUIF &lt.expr&gt.
.begdescr
Conditionally quit current loop or while loop block.
.np
Any variables contained in &parm1 are expanded before the expression
is evaluated.
.np
If &parm1 is true, the current looping block is exited and execution
resumes at the line after the end of the current block.
.np
If &parm1 is false, execution continues at the next line.
.enddescr
.alsosee begin
.seethis break
.seethis continue
.seethis endloop
.seethis endwhile
.seethis loop
.seethis until
.seethis while
.alsosee end
.endfunc

.begfunc RETURN
.syntx * RETURN &lt.rc&gt.
.begdescr
Exit the script, returning &parm1.
:period.
.np
If the script was invoked by another script, then this value becomes
.keyword lastrc
:period.
.np
If the script was invoked at the &cmdline, then this return code
is reported as the appropriate error, if &parm1 is not
.param ERR_NO_ERR
:period.
.np
There are symbolic values for various error codes.
These values are described in the appendix
:HDREF refid=errcode.
:period.
.enddescr
.endfunc

.begfunc UNTIL
.syntx * UNTIL &lt.expr&gt.
.begdescr
Closes a loop block.
.np
Any variables contained in &parm1 are expanded before the expression
is evaluated.
.np
If &parm1 is true, the first line after the loop block
is executed.
.np
If &parm1 is false, then
control is returned to the top of the loop block, and the loop
executes again.
.enddescr
.alsosee begin
.seethis break
.seethis continue
.seethis endloop
.seethis endwhile
.seethis loop
.seethis quif
.seethis while
.alsosee end
.endfunc

.begfunc WHILE
.syntx * WHILE &lt.expr&gt.
.begdescr
Start a loop block.  If &parm1 is true, the body of the loop
is executed.  If &parm1 is false, execution transfers to the
instruction after the
.keyref endwhile
command.
.np
Any variables contained in &parm1 are expanded before the expression
is evaluated.
.np
This is the top of the block, after a
.keyref continue
or
.keyref endwhile
control returns to the
.keyword while
command.
.enddescr
.alsosee begin
.seethis break
.seethis continue
.seethis endloop
.seethis endwhile
.seethis loop
.seethis quif
.seethis until
.alsosee end
.endfunc
.*
.fnlist end
.*
.* ******************************************************************
.section 'Script Examples'
.* ******************************************************************
.*
.np
The following section describes a number of the scripts
that are provided with &edvi.. Each script
is discussed in detail.

.sesect begin 'err.vi'
This is a simple script that edits a file that has the exact same
name as the current file, only has the extension .err.
.sexmp begin
.seline edit %D%P%N.err
.sexmp end
.seref begin
.serefer 1
The global variable
.var %D
contains the drive of the current file.
The global variable
.var %P
contains the full path to the current file.
The global variable
.var %N
contains the name of the current file (extension removed).
These are combined with the .err extension to create a full path
to an error file.  This file is edited.
.seref end
.sesect end

.sesect begin 'lnum.vi'
This script prompts the user for a line number, and
if a line number is entered, goes to that line.
.sexmp begin
.seline assign %a = /Enter Line Number:/
.seline input %a
.seline if lastrc != NO_VALUE_ENTERED
.seline     %a
.seline endif
.sexmp end
.seref begin
.serefer 1 2
These lines assigns the string
.param Enter Line Number:
to the local variable
.var %a
:period.
This value will be used by the
.keyref input
command on line 2 to prompt the user.
.serefer 3 5
As long as the input was not cancelled by the user
(by pressing the ESC key),
the line the user typed is executed directly.
This assumes that the user will type a number.
.seref end
.sesect end

.sesect begin 'qall.vi'
This script
tries to quit each file being edited.  If the file has been modified,
the user is prompted if he wishes to save the file.  If he replies 'y',
the file is saved.  If he replies 'n', the file is discarded.  If
he presses the ESC key and cancels the input, the script is exited.
.sexmp begin
.seline loop
.seline 
.seline     quit
.seline     if lastrc == ERR_FILE_MODIFIED
.seline         assign %a = /Save "%F" (y\/n)?/
.seline         input %a
.seline         quif lastrc == NO_VALUE_ENTERED
.seline         if "%a" == y
.seline             write
.seline             quit
.seline         else
.seline             quit!
.seline         endif
.seline     endif
.seline     quif lastrc != ERR_NO_ERR
.seline 
.seline endloop
.sexmp end
.seref begin
.serefer 1
Starts the loop.
.serefer 3 4
Tries to to quit the file.  If the quit command fails, and the
return code is
.param ERR_FILE_MODIFIED
(the
.keyref quit
command will fail if the file being abandoned is modified),
then the code from lines 5-14 is executed.
.serefer 5 6
Assigns the string
.param Save "&lt.filename&gt." (y/n)?
to the local variable
.var %a
:period.
This value will be used by the
.keyref input
command on line 6 to prompt the user.
.serefer 7
This exits the main loop if the user cancels the input prompt by
pressing the ESC key.
.serefer 8 13
If the user typed the letter y, then the edit buffer is saved and
exited, otherwise the contents of the edit buffer are discarded.
.serefer 15
This exits the main loop if any of the previous commands did
not return the "everything is OK" return code,
.param ERR_NO_ERR
:period.
.serefer 17
Ends the loop.  Control is returned to line 3.
.seref end
.sesect end

.sesect begin 'wrme.vi'
This example is the default write hook script
:period.
This is called just before a edit buffer is saved and exited.
If the file has a null name, then the user is prompted for a name. If
he cancels the prompt, then the save is aborted. Otherwise, the
new name is set and the save continues.
.sexmp begin
.seline if "%F" != ""
.seline     return ERR_NO_ERR
.seline endif
.seline assign %a = /Enter file name:/
.seline input %a
.seline if lastrc == NO_VALUE_ENTERED
.seline     return DO_NOT_CLEAR_MESSAGE_WINDOW
.seline endif
.seline echo off
.seline set filename = %a
.seline echo on
.seline return ERR_NO_ERR
.sexmp end
.seref begin
.serefer 1 3
Checks if the current file name is the empty string.  If it is not,
then there is a filename and the script returns
.param ERR_NO_ERR
to indicate that processing is to continue.
.serefer 4 8
The user is prompted with
.param Enter a file name:
:period.
If he cancels the
.keyref input
command by pressing the ESC key, then the script returns
.param DO_NOT_CLEAR_MESSAGE_WINDOW
:cont.,
which is not an error condition but causes the save process to abort
(remember, a hook point stops what it is doing if an
non-zero return code is returned from the hook script).
.serefer 9
Echo is disabled so that the setting of the filename will not
cause the normal message to appear in the message window.
.serefer 10
The filename is set to whatever the user typed in.
.serefer 11
Echo is enabled.
.serefer 12
The script returns
.param ERR_NO_ERR
to indicate that processing is to continue.
.seref end
.sesect end

.sesect begin 'proc.vi'
This example prompts the user for a procedure name.  If the user types
one, then a procedure skeleton is added:
.millust begin
/*
 * ProcName
 */
void ProcName(  )
{

} /* ProcName */
.millust end
and the user is left in input mode on the space before the
closing bracket (')').
.sexmp begin
.seline assign %a = /Procedure Name:/
.seline input %a
.seline if lastrc == NO_VALUE_ENTERED
.seline     return
.seline endif
.seline atomic
.seline echo off
.seline assign %x = /autoindent/@
.seline set noautoindent
.seline execute \e0o/*\n * %a\n */\n\e0ivoid %a( @ )\n{\n\n} /* %a */\n\e
.seline if %x == 1
.seline     set autoindent
.seline endif
.seline  -4
.seline execute \e0f@x
.seline echo on
.seline echo 1 Procedure %a added
.seline echo 2 " "
.seline keyadd i
.sexmp end

.seref begin
.serefer 1 5
The user is prompted with
.param Procedure Name:
:period.
If he cancels the
.keyref input
command by pressing the ESC key, then the script exits.
.serefer 6
The script is an
.keyref atomic
one; so all modifications to the edit buffer can be undone with a
single
.keyref 'undo (command)'
:period.
.serefer 7
Disables any output to the message window.
.serefer 8
This line gets the current state of the
.keyref autoindent 1
setting, and saves it the the local variable
.var %x
:period.
.serefer 9
Turns off autoindent, so that the text to be inserted will line up
properly.
.serefer 10
This line simulates the typing of a number of keystrokes at the keyboard.
The effect of these keys is to generate the following:
.millust begin
/*
 * ProcName
 */
void ProcName( @ )
{

} /* ProcName */
.millust end
.serefer 11 13
The local variable
.var %x
is set to the previous value of
.keyref autoindent 1
:period.
If
.keyref autoindent 1
was on before, then this turns it back on.
.serefer 14
This backs the cursor up to the line
.millust begin
void ProcName( @ )
.millust end
.serefer 15
This line simulates the typing of a number of keystrokes at the keyboard.
The effect of these keystrokes is to move forward to the '@' character
and delete it.  This leaves the cursor in the position necessary to
enter procedure parameters.
.serefer 16
Enables output to the message window.
.serefer 17 18
Displays a message.
.serefer 19
Adds the key 'i' to the keyboard buffer.  Once the script exits, &edvi
will process this key as if the user had typed it.  Thus, once the
script is done, the user is left inserting text.
.seref end
.sesect end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -