commandb編譯
Ⅰ Sub3 運行 python command+b 沒反應
安裝sublime text3後,按Ctrl+b無法運行python文件。
解決方法:
打開sublime ->戚逗胡 tools -> build system ->new build system,在打開的新tab頁面添加如下內容:
command +s保存到目錄(Sublime Text3/Packages/User,保高攔存時的默認目錄),可任意命指槐名(建議python3),但後綴名不能更改。
然後在tools→build system中選擇添加的項,通過command +b命令即可運行Python文件。
Ⅱ Delphi的命令行編譯命令
Borland出品的Delphi,有著閃電般的編譯速度,但是在界面控制項使用較多、工程項目較大的時候,編譯一個工程仍需要一段時間,打開龐大的Delphi IDE,也需要時間。其實,在一個工程開發結束,調試完成之後的Release編譯,完全可以用命令行來執行,因為Delphi的編譯器參數不像C++編譯器那樣復雜。
筆者把Delphi聯機手冊中關於命令行編譯(command-line compiler)的幾篇主題作了翻譯,希望對Delphi開發人員有幫助。
目錄
1. Command-line compiler
命令行編譯器
2. Command-line compiler options
命令行編譯器選項
3. Compiler directive options
編譯器指令選項
4. Compiler mode options
編譯模式選項
5. DCC32.CFG file
編譯器配置文件DCC32.CFG
6. Debug options
調試選項
7. Directory options
目錄選項
8. IDE command-line options
IDE命令行選項
9. Generated files
幾個IDE自動生成的文件介紹
Command-line compiler
命令行編譯器
Delphi's command-line compiler (dcc32.EXE) lets you invoke all the functions of the IDE compiler (DELPHI32.EXE) from the DOS command line (see IDE command-line options. Run the command-line compiler from the DOS prompt using the syntax:
Delphi』s命令行編譯器(dcc32.exe)允許你從DOS命令行方式(參照:IDE命令行選項)實現IDE編譯器(delphi32.exe)的所有功能。用DOS命令運行命令行編譯器語法如下:
dcc32 [options] filename [options]
dcc32 [選項] [文件名] [選項]
where options are zero or more parameters that provide information to the compiler and filename is the name of the source file to compile. If you type dcc32 alone, it displays a help screen of command-line options and syntax.
零或多個參數給編譯器提供信息,文件名指定需要編譯的源文件名。如果你單獨輸入dcc32,它會顯示一個關於命令行編譯的選項和語法的屏幕。
If filename does not have an extension, the command-line compiler assumes .dpr, then .pas, if no .dpr is found. If the file you're compiling to doesn't have an extension, you must append a period (.) to the end of the filename.
如果文件名沒有擴展名,命令行編譯器會查找擴展名為.dpr的同名文件,如果找不到,則查找擴展名為.pas的同名文件。如果你的源文件確實沒有擴展名,你需要在文件名的末尾添加(.)。
If the source text contained in filename is a program, the compiler creates an executable file named filename.EXE. If filename contains a library, the compiler creates a file named filename.DLL. If filename contains a package, the compiler creates a file named filename.BPL. If filename contains a unit, the compiler creates a unit file named filename.dcu.
如果指定的源文件是一個工程文件,編譯器會創建一個擴展名為.EXE的同名可執行文件。如果指定的源文件是一個庫文件,編譯器創建一個擴展名為.DLL的同名動態鏈接庫文件。如果指定的源文件是一個包文件,編譯器會創建一個擴展名為.BPL的同名包。如果指定的源文件是一個單元文件,編譯器會創建一個擴展名為.dcu的目標代碼文件。
You can specify a number of options for the command-line compiler. An option consists of a slash (/) or immediately followed by an option letter. In some cases, the option letter is followed by additional information, such as a number, a symbol, or a directory name. Options can be given in any order and can come before or after the file name.
你可以為命令行編譯器指定多個參數。一個參數包含一個破折號「-」(或「/」)和緊跟著的一個選項字元構成。通常情況下,選項字元後面會跟一些附加的信息,如一個數字、一個符號、一個目錄等。選項可以是任意順序並且可以在源文件名前面或後面。
Command-line compiler options
命令行編譯選項
The IDE lets you set various options through the menus; the command-line compiler gives you access to these options using the slash (/) delimiter. You can also precede options with a hyphen (-) instead of a slash (/), but those options that start with a hyphen must be separated by blanks. For example, the following two command lines are equivalent and legal:
IDE允許你使用菜單來設置各種編譯選項,而命令行編譯器允許你使用字元「/」作為分隔符來設定這些編譯選項。你也可以使用連字元「-」來代替「/」,但是用「-」引出的參數之間必須用空格隔開。例如,下面兩個命令都是等同的也是合法的:
DCC -IC:\DELPHI -DDEBUG SORTNAME -$R- -$U+
DCC /IC:\DELPHI/DDEBUG SORTNAME /$R-/$U+
The first command line uses hyphens with at least one blank separating options. The second uses slashes and no separation is needed.
第一個編譯命令用「-」引出參數,且參數之間有多個空格分隔。第二個編譯命令用「/」引出參數,參數之間不必要分隔。
The following table lists the command-line options. In addition to the listed options, all single-letter compiler directives can be specified on the command line, as described in Compiler directive options.
下列表中列出所有的命令行參數。在附加的選項列表中,所有的單字元編譯器指令都可以在命令行編譯中使用,詳情請參照:編譯器指令。
Option Description
選項 描述
Aunit=alias 設置單元別名
B 編譯所有單元
CC 編譯控制台程序
CG 編譯圖形界面程序
Ddefines 編譯條件符號定義
Epath 可執行文件輸出路徑
Foffset 查找運行期間錯誤
GD 生成完整.Map文件
GP 生成.Map文件Public段
GS 生成.Map文件Segment段
H 輸出提示信息
Ipaths 文件包含路徑
J 生成.Obj目標文件
JP 生成C++類型.Obj目標文件
Kaddress Set image base address
LEpath 包.BPL文件輸出路徑
LNpath .dcp文件輸出路徑
LUpackage 使用運行期間包列表
M 編譯有改動的源文件
Npath dcu/dpu文件輸出目錄
Opaths .Obj文件(匯編目標代碼文件)路徑
P 按8.3格式文件名查找
Q 安靜模式
Rpaths 資源文件(.RES)路徑
TXext 目標文件擴展名
Upaths 單元文件路徑
V 為Turbo Debugger生成調試信息文件
VN 以.Giant格式生成包含命名空間的調試信息文件(將用於C++Builder)
VR 生成調試信息文件.rsm
W 輸出警告信息
Z Disable implicit compilation
$directive Compiler directives
--Help 顯示編譯選項的幫助。同樣的,如果你在命令行單獨輸入dcc32,也會顯示編譯選項的幫助。
--version 顯示產品名稱和版本
Compiler directive options
編譯器指令選項
Delphi supports the compiler directives described in Compiler directives. The $ and D command-line options allow you to change the default states of most compiler directives. Using $ and D on the command line is equivalent to inserting the corresponding compiler directive at the beginning of each source file compiled.
Delphi支持用編譯器指令關鍵字描述的編譯器指令。使用「$」和「D」命令行選項可以改變所有的默認編譯器狀態。用「$」和「D」命令行選項等同於在源文件的前面添加編譯器指令。
Switch directive option
編譯器指令選項開關
The $ option lets you change the default state of all of the switch directives. The syntax of a switch directive option is $ followed by the directive letter, followed by a plus (+) or a minus (-). For example:
「$」允許你改變每一種編譯器指令默認狀態。編譯器指令的語法是「$」後緊跟一個指令字元,再跟一個「-」或「+」。例如:
dcc32 MYSTUFF -$R-
compiles MYSTUFF.pas with range-checking turned off, while:
不使用邊界檢查編譯MYSTUFF.pas單元:
dcc32 MYSTUFF -$R+
compiles it with range checking turned on. Note that if a {$R+} or {$R-} compiler directive appears in the source text, it overrides the -$R command-line option.
使用界面檢查編譯MYSTUFF.pas單元。如果將編譯器指令{$R+}或{$R-}添加到源文件的開始,它將覆蓋從命令行傳入的參數。
You can repeat the -$ option in order to specify multiple compiler directives:
你可以用多個「$」來指定多個編譯器指令,如:
dcc32 MYSTUFF -$R--$I--$V--$U+
Alternately, the command-line compiler lets you write a list of directives (except for $M), separated by commas:
命令行編譯器允許作用逗號分隔的編譯器指定列表,如:
dcc32 MYSTUFF -$R-,I-,V-,U+
只需要用一個「$」符號。
Only one dollar sign ($) is needed.
注意,因為$M的格式不一樣,你不能在逗號分隔的指令列表中使用$M
Note that, because of its format, you cannot use the $M directive in a list of directives separated by commas.
Conditional defines option
條件編譯選項
The -D option lets you define conditional symbols, corresponding to the {$DEFINE symbol} compiler directive. The -D option must be followed by one or more conditional symbols separated by semicolons (;). For example, the following command line:
「-D」選項允許你定義一個編譯條件,符合你用{$DEFINE symbol}定義的編譯器指令。「-D」選項後必須跟隨一或多個用分號分隔的編譯條件符號,如下命令:
dcc32 MYSTUFF -DIOCHECK;DEBUG;LIST
defines three conditional symbols, iocheck, debug, and list, for the compilation of MYSTUFF.pas. This is equivalent to inserting:
定義了三個編譯條件符號:IOCHECK,DEBUG,LIST,用於MYSTUFF.pas單元中。這等同於在源文件中插入以下語句:
{$DEFINE IOCHECK}
{$DEFINE DEBUG}
{$DEFINE LIST}
at the beginning of MYSTUFF.pas. If you specify multiple -D directives, you can concatenate the symbol lists. Therefore:
如果你指定了多個「-D」選項,你可以聯接它們,如下:
dcc32 MYSTUFF -DIOCHECK-DDEBUG-DLIST
is equivalent to the first example.
等同於第一個例子。
Compiler mode options
編譯模式選項
A few options affect how the compiler itself functions. As with the other options, you can use these with either the hyphen or the slash format. Remember to separate the options with at least one blank.
有幾個選項能影響編譯器自身的功能。像其它選項一個,你可以使用「/」或「-」的格式。別忘了用至少一個空格分隔這些選項。
Make (-M) option
選項(-M)
The command-line compiler has built-in MAKE logic to aid in project maintenance. The -M option instructs command-line compiler to check all units upon which the file being compiled depends. Using this option results in a much quicker compile time.
命令行編譯器使用構造邏輯的方式來維護工程。「-M」選項指示編譯器檢查所有與編譯文件相關聯的文件。用這個參數會導致編譯時間增大。
A unit is recompiled under the following conditions:
一個源文件在下列情況下會重新編譯:
The source file for that unit has been modified since the unit file was created.
源文件被創建以來被修改過;
用「$I」指令包含的任何文件,用「$L」包含的任何.Obj文件,或用「$R」關聯的任何資源文件.Res,比源文件中的要新;
Any file included with the $I directive, any .OBJ file linked in by the $L directive, or any .res file referenced by the $R directive, is newer than the unit file.
The interface section of a unit referenced in a uses statement has changed.
單元介面部分interface的uses段有改動。
Units compiled with the -Z option are excluded from the make logic.
在單元編譯時指令「-Z」在構造邏輯期不被接受。
If you were applying this option to the previous example, the command would be:
如果你在上一個例子中使用這個指令,編譯命令就應該是:
dcc32 MYSTUFF -M
Build all (-B) option
編譯所有 選項(-B)
Instead of relying on the -M option to determine what needs to be updated, you can tell command-line compiler to update all units upon which your program depends using the -B option. You can't use -M and -B at the same time. The -B option is slower than the -M option and is usually unnecessary.
用於取代要知道哪些單元需要更新-M的選項,你可以使用-B選項來更新所有你的程序中關聯的單元。你不能在程序中同時使用-M和-B。選項-B比-M速度更慢,而且它並不是必需的。
If you were using this option in the previous example, the command would be
如果你在前一個例子中使用這個參數,編譯命令就應該是:
dcc32 MYSTUFF -B
Find error (-F) option
查找錯誤 選項(-F)
When a program terminates e to a runtime error, it displays an error code and the address at which the error occurred. By specifying that address in a -Faddress option, you can locate the statement in the source text that caused the error, provided your program and units were compiled with debug information enabled (via the $D compiler directive).
當一個程序由於運行期間錯誤而終止時,它會顯示一個錯誤號和錯誤地址在錯誤發生時。用-Faddress選項來指定錯誤地址,你在源文件中能找到引發錯誤的位置,如果你的程序和單元編譯時附加了調試信息(使用$D編譯器指令)。
In order for the command-line compiler to find the runtime error with -F, you must compile the program with all the same command-line parameters you used the first time you compiled it.
為了命令行編譯器能用-F選項查找運行期間錯誤,你必須傳遞與第一次編譯時相同的指令列表。
As mentioned previously, you must compile your program and units with debug information enabled for the command-line compiler to be able to find runtime errors. By default, all programs and units are compiled with debug information enabled, but if you turn it off, using a {$D-} compiler directive or a -$D- option, the command-line compiler will not be able to locate runtime errors.
先前提到過,你的程序和單元必須啟用調試信息,命令行編譯器才能查找運行期間錯誤。默認情況下,所有的程序和單都是啟用調試信息的,除非你用{-D}或-$D-指令關閉它,這樣,命令行編譯器就不能查找運行期間錯誤了。
Use packages (-LU) option
使用包(-LU)選項
Use the -LU option to list additional runtime packages that you want to use in the application being compiled. Runtime packages already listed in the Project Options dialog box need not be repeated on the command line.
使用-LU選項來在編譯時添加你應用程序中要用到的運行期間包。運行期間包已經在「工程選項」對話框中列舉的,不必再在命令行中添加。
Disable implicit compilation (-Z) option
(此選項在delphi6.0/7.0中有不同描述,在此不作翻譯)
The -Z option prevents packages and units from being implicitly recompiled later. With packages, it is equivalent to placing {$ IMPLICITBUILD OFF} in the .dpk file. Use -Z when compiling packages that provide low-level functionality, that change infrequently between builds, or whose source code will not be distributed.
Target file extension (-TX) option
目標文件擴展名(-TX)選項
The -TX option lets you override the default extension for the output file. For example,
選項-TX允許你改寫默認的輸出文件擴展名。例如:
dcc32 MYSTUFF -TXSYS
generates compiled output in a file called MYSTUFF.SYS.
生成的將是一個叫做MYSTUFF.SYS的文件。
Quiet (-Q) option
安靜模式(-Q)選項
The quiet mode option suppresses the printing of file names and line numbers ring compilation. When the command-line compiler is invoked with the quiet mode option
安靜模式選項禁止在編譯時顯示文件名及代碼行數,如果命令行編譯器調用這個選項的話。
dcc32 MYSTUFF -Q its output is limited to the startup right message and the usual statistics at the end of compilation. If any errors occur, they will be reported.
它的輸出僅限於起始時行版權信息以及結尾的統計信息。當然,如果發生錯誤,它也會輸出。
DCC32.CFG file
DCC32.CFG配置文件
You can set up a list of options in a configuration file called DCC32.CFG, which will then be used in addition to the options entered on the command line. Each line in configuration file corresponds to an extra command-line argument inserted before the actual command-line arguments. Thus, by creating a configuration file, you can change the default setting of any command-line option.
你可以設置一個編譯選項列表到一個叫做DCC32.CFG的配置文件中,它將用於編譯時附加到命令行參數後。配置文件的每一行都相當於一個額外的命令行參數插入到實際的命令行參數前(注意,是實際參數前)。因而,你可以使用這個配置文件改變一些命令行參數的默認設置。
The command-line compiler lets you enter the same command-line option several times, ignoring all but the last occurrence. This way, even though you've changed some settings with a configuration file, you can still override them on the command line.
命令行編譯器允許你輸入相同的命令行參數,它將忽略所有除最後一個之外。這個的話,盡管通過配置文件你可以改變一些設置,你仍然可以覆蓋它使用命令行參數。
When dcc32 starts, it looks for DCC32.CFG in the current directory. If the file isn't found there, dcc32 looks in the directory where DCC32.EXE resides.
當dcc32啟動時,它查找DCC32.CFG文件在當前目錄。如果文件沒有找到,dcc32會查找它所在的目錄。
Here's an example DCC32.CFG file, defining some default directories for include, object, and unit files, and changing the default states of the $O and $R compiler directives:
以下是一個DCC32.CFG配置文件的例子,定義了關於文件包含、OBJ文件包含、單元文件搜索路徑信息,並改變了編譯器指令$O和$R的默認值。
-IC:\DELPHI\INC;C:\DELPHI\SRC
-OC:\DELPHI\ASM
-UC:\DELPHI\UNITS
-$R+
-$O-
Now, if you type:
現在,如果你輸入:
dcc32 MYSTUFF
the compiler performs as if you had typed the following:
編譯器把它當作你輸入如下命令:
dcc32 -IC:\DELPHI\INC;C:\DELPHI\SRC -OC:\DELPHI\ASM -UC:\DELPHI\UNITS -$R+ -$O- MYSTUFF
Debug options
調試選項
The compiler has two sets of command-line options that enable you to generate external debugging information: the map file options and the debug info options.
編譯器有兩個命令行參數可以生成外部調試信息:MAP文件選項和調試信息選項。
Map file (-G) options
Map文件(-G)選項
The -G option instructs the command-line compiler to generate a .map file that shows the layout of the executable file. Unlike the binary format of executable and .dcu files, a .map file is a legible text file that can be output on a printer or loaded into the editor. The -G option must be followed by the letter S, P, or D to indicate the desired level of information in the .map file. A .MAP file is divided into three sections:
選項-G指示命令行編譯器生成一個.map文件來查看一個可執行文件的布局。不同於可二進制的可執行文件和.dcu文件,.map文件是一個可讀的文本文件,可以被列印或是其它文本編輯器編輯。選項-G後必須跟字元S、P或D,去決定你想要在.map文件列出的信息。一個.MAP文件被分成三個節:
Segment
Publics
Line Numbers
-GS outputs only the Segment section, -GP outputs the Segment and Publics section, and -GD outputs all three sections. -GD also generates a .DRC file that contains tables of all string constants declared using the resourcestring keyword.
-GS選項只輸出Segment Section,-GS選項輸出Segment和Publics,-GD輸出所有的三個Sections.-GD選項也生成一個擴展名為.DRC的文件包含所有的用resourcestring關鍵字聲明的字元串常量。
For moles (program and units) compiled in the {$D+,L+} state (the default), the Publics section shows all global variables, proceres, and functions, and the Line Numbers section shows line numbers for all proceres and functions in the mole. In the {$D+,L-} state, only symbols defined in a unit's interface part are listed in the Publics section. For moles compiled in the {$D-} state, there are no entries in the Line Numbers section.
用默認的編譯選項{$D+,L+}編譯模塊(程序或單元),Publics Section列舉所有的全局變數、過程和函數,Line Numbers Section列舉模塊中所有的過程和函數的行號。如果用{$D+,L-}編譯選項編譯模塊,Publics Section中僅列舉在單元的interface部分定義的符號。如果用{$D-}選項編譯模塊,在Line Numbers Section沒有任何入口。
Debug info (-V) options
調度選項(-V)
The -V options (-V, -VN. and -VR), which cause the compiler to generate debug information, can be combined on the command line.
選項-V、-VN、-VR會指示編譯器生成調試信息,它們能在命令行中組合使用。
Generate Turbo Debugger debug info (-V) option
生成Turbo Debugger使用的調試信息的選項(-V)
When you specify the -V option on the command line, the compiler appends Turbo Debugger 5.0-compatible external debug information at the end of the executable file. Turbo Debugger includes both source- and machine-level debugging and powerful breakpoints.
當你在命令行中使用-V選項時,編譯器會在可執行文件的末尾附加與Turbo Debugger5.0一致的外部調試信息。Turbo Debugger包含代碼和硬體級別的強大的斷點。
Even though the debug information generated by -V makes the resulting executable file larger, it does not affect the actual code in the executable, and does not require additional memory to run the program.
雖然附加調試信息到查執行文件中會使可執行文件增大,但是它並不影響實際可執行文件中的可執行代碼,也不需要額外的內存來啟動程序。
The extent of debug information appended to the executable file depends on the setting of the $D and $L compiler directives in each of the moles (program and units) that make up the application. For moles compiled in the {$D+,L+} state, which is the default, all constant, variable, type, procere, and function symbols are known to the debugger. In the {$D+,L-} state, only symbols defined in a unit's interface section are known to the debugger. In the {$D-} state, no line-number records are generated, so the debugger cannot display source lines whe
Ⅲ sublime text 3 for osx 快速編譯打開html文件,在windows下快捷鍵是ctrl + b,在mac下command+b不行
1. 可以直接打開圖片
版本3有個很好的特性(對於前端來說):可以直接在ST3中打開圖片。
2. Goto Anything功能 — 快速查找(ctrl + P)
輸入@+函數名可以快速找到函數。
輸入#+文本可以快速進行文件內文本匹配。
3. 多行游標功能(ctrl + D,非常實用)
如何將文件中的某個單詞更改為另一個?
方法一:利用查找替換功能:ctrl + H
方法二(推薦):多行游標功能,選中一個後,按ctrl+D可以同時選中另一個,同時多了另一個游標。
但多行游標能完成查找替換功能不能完成的工作。
比如在某些符合條件的語句後面添加新行,同時加入一些新的文本,如何快速的達到這一目的?
- 可以選中某一個模式,然後ctrl+D選中另一個,如果有某些不想添加新行的模式則按ctrl+K,ctrl+D跳過這個進入下一個符合條件的模式行。
- 還可以按Alt + F3快捷鍵全選所有符合條件的單詞,產生多個游標,而不用一個個ctrl+D選中。
- 如果要在每行都加入游標,可以先ctrl+A然後ctrl+shift+L即可。
- 如果想在某個字元的多行後面加上游標,可以將游標放在這個字元後面,按住shift鍵,然後右鍵可以向下拖動產生多個游標。
4. 命令模式(應盡可能使用,而不用浪費腦細胞記憶大量命令的快捷鍵)
比如用ctrl+N新建一個文件後,默認是plain text,沒有語法高亮功能,如何設置語法模式?
- 可以通過右下角的語法選擇區選擇希望設置的語法模式。
- 還有另一種更好的辦法,即使用ctrl + shift + P打開命令模式,然後輸入set syntax [language]設置為某種語言的語法模式,比如set syntax java則設置為java語法高亮。
- st3支持模糊匹配,你也可以直接輸入syntax java或ssjava。
- 若當前已經是某種語言的語法模式,則可以直接輸入其它語言進行切換(而不用輸入set syntax或syntax了),比如當然為java語法模式,那麼直接輸入js就可以馬上切換為javascript語法模式。
還可以輸入minimap隱藏或顯示右邊的minimap縮影
5. 快速跳轉到某一行
按下Ctrl + G,輸入行號,可以快速跳轉到該行。
6. 快速添加新行
Ctrl + Enter可以在當前行下新建一行。
Ctrl + Shift + Enter可以在當前行上面添加一行。
7. 多行縮進
選中多行後按Ctrl + ]可以增加縮進,按Ctrl + [可以減少縮進。
PS:發現用Tab和Shift + Tab也是可以的。
8. 完整拷貝,避免格式錯亂
我們發現,在從別的文件中拷貝一段代碼過來的時候,多半隻是第一行縮進,後面都亂了,這時可以使用Ctrl + Shift + V進行粘貼,可以在粘貼的過程中保持縮進,這時格式都是正確的。
9. 重新打開關閉的標簽
在Chrome裡面,如果你不小心關閉了某個標簽頁並想恢復它,你可以按下Shift + Ctrl + T重新打開它。
在ST3中也一樣,如果你不小心關閉了某個文件,可以按下Shift + Ctrl + T快速恢復。連續重復該按鍵,ST將會按照關閉的先後順序重新打開標簽頁。
10. 按住shift + ctrl然後按←或→可快速選中一行中的某一部分,連續按擴大選擇范圍。
比如你需要將某一部分進行注釋(ctrl+/)或刪除,使用這個功能就很方便。
11. 上下移動行
定位游標或選中某塊區域,然後按shift+ctrl+↑↓可以上下移動該行。
12. shift + ctrl + d可快速復制游標所在的一整行,並復制到該行之前。
13. Ctrl+Shift+M:選中花括弧裡面的全部內容不包括{}。
14. Ctrl+Shift+K:刪除整行。
15. 快速關閉HTML里的標簽
寫html文件時利用快捷鍵Alt + .可以快速關閉某個標簽,如寫<html>後按Alt+.可以快速得到</html>。
但這樣還是挺繁瑣,可以使用前端插件Emmet插件,直接在新建的html文件里(首先得設置語法模式為html)直接輸入!(代表html5格式的html文檔)然後按下ctrl+E即可。
Ⅳ 在vba的用戶窗體中,有一個文本框textbook1有一個命令按鈕commandb
sub commandbutton1_click()
dim i as integer, xx as long '定義變數
xx = 1 '給變數xx賦初值
for i = 1 to 10 '循環
xx = xx * i '用循環計算1*2*3····*10的結果
next i '循環出口
textbook1.text = xx '念耐在文本仔兄春框textbook1中顯示塵蘆
end sub
Ⅳ 在vba的用戶窗體中,有一個文本框textbook1有一個命令按鈕commandb
這個簡單啊,比較容易實現,上一位回答者的答案似乎可以
Ⅵ 硬體協議sdk如何打包
關注
從事Android開發久了不可避免的會接觸對外介面的封裝,下面本人就以自己寫過的一個例子系統講講怎樣對應用sdk的開發。
1.封裝
我們在與其他公司合作的時候,往往會有技術方面的協作,但我們又不想過多的暴露我們某些技術方面的細節,比如:ip地址、技術參數、核心演算法。
於是我們會對這部分代碼進行封裝,這部分需要精通Java的設計模式。
下面上傳我的項目:
這里寫圖片描述
新建一個Android工程,添加一個Model:musicdot。
musicdot是本人自己解析網路音樂的歌曲搜索請求實現的在線搜歌功能包。所以我將要對這部分代碼進行封裝打包,以達到隱藏具體搜索請求的目的。(由於司准備讓整個項目打包成SDK,經過大量查閱打包SDK的博客,和自己的實踐,我把打包過程,中間遇到的各種問題,踩過的坑簡單的總結一下,讓看到的道友少踩些坑。
一、創建一個workspace
可以在桌面新建個testSDK文件夾,在這個文件夾里創建個WorkSpace。如圖:
二、創建SDK
1.打開workspace,創建一個project,如圖:
2.選擇Cocoa Touch Framework,如圖:
3.創建framework,把framework添加到workspace里。如圖:
三、創建SDKDemo
1.打開TestSDK.xcworkspace文件,創建project ,選擇Single View Application。如圖:
2.紅框里的都選擇TestSDK.xcworkspace。
這樣就把SDK和demo都創建好了,這樣創建SDK加demo可以方便調試,如果sdk中有問題,可以直接在SDK中斷點調試。創建後的效果如圖:
3.修改build settings 配置參數。如圖:
更改參數,在Architectures下增加armv7s,並選中。將Build Active Architecture only設置為NO
四、添帶局加你的項目代碼到SDK中
如果你的項目用到了Xib,圖片,mp3,storyboard等,那麼你就要添加一個bundle資源包蠢豎讓,把這些資源添加到資源包里。
五、創建bundle資源包。
1.在target中點擊右下角的+號,選擇macOS,找到Framework&Library,選擇Bundle。如圖:
2.修改配置文件:
"Base SDK" 設置為 "纖禪IOS"
"Build Active Architecture Only" 設置為 "YES"
"Debug Information Format" 設置為 "DWARF with dSYM File"
"Skip Install" 設置為 "NO"
"Strip Debug Symbols During Copy" 中"Release"模式設置為 "YES"
"IOS Deployment Target" 設置為 "IOS 9.0"(具體根據自己的項目,設置系統版本)
"COMBINE_HIDPI_IMAGES" 設置為 "NO"
3.在Build phases中添加Xib。如圖:
4.選擇bundle,command + B編譯,如圖:
編譯之後,SDK工程下會多個bundle的文件夾,你可以把圖片,MP3,plist文件放到該文件夾里,如圖:
5.調用bundle資源包里的資源。
//調用自定義View的Xib
+(MyView *)instancePubView
{
NSArray * nibView = [[NSBundle mainBundle] loadNibNamed:@"testBL.bundle/MyView" owner:nil options:nil];
return [nibView objectAtIndex:0];
}
//調用視圖控制器的Xib
-(instancetype)init{
NSBundle * bundle = [NSBundle bundleWithPath:[[[NSBundle mainBundle] resourcePath] :@"testBL.bundle"]];
self = [super initWithNibName:@"LoginViewController" bundle:bundle];
return self;
Ⅶ xcode 如何編譯
Xcode 常用編譯選項設置
在xcconfig文件中指定即可。
用標准庫連接
LINK_WITH_STANDARD_LIBRARIES = YES如果激活此設置,那麼編譯器在鏈接過程中會自動使用通過標准庫的鏈接器。
Info.plist 輸出編碼
INFOPLIST_OUTPUT_FORMAT = binary指定Info.plist文件的輸出編碼(默認情況下,輸出與輸入的編碼保持不變),這個輸出編碼能指定「binary」或者「XML」。
生 成調試符號GCC_GENERATE_DEBUGGING_SYMBOLS = NO當啟用的時候,詳情等級能夠通過build的』Level of Debug Symbols』設置去控制。 隱藏內聯方法GCC_INLINES_ARE_PRIVATE_EXTERN = YES Objective-C GCGCC_ENABLE_OBJC_GC = Unsupported 優化級別GCC_OPTIMIZATION_LEVEL = Fastest, Smallest [-OS]
None: 不做優化使用這個設置,編譯器的目標是減少編譯成本,使調試產生預期的結果。
Fast:優化編譯將為大函數佔用更多的時間和內存使用這個設置,編譯器將嘗試減少代碼的大小和執行時間,不進行任何優化,需要大量編譯時間。
Faster:編譯器執行幾乎所有支持的優化,它不考慮空間和速度之間的平衡與「Fast」設置相比,該設置會增加編譯時間和生成代碼的性能。編譯器不進行循環展開、內聯函數和寄存器變數的重命名。
Fastest:開啟「Faster」支持的所有的優化,同時也開啟內聯函數和寄存器變數的重命名選項
Fastest,smallest:優化代碼大小這個設置啟用「Faster」所有的優化,一般不增加代碼大小,它還執行旨在減小代碼大小的進一步優化。
C 語言方言GCC_C_LANGUAGE_STANDARD = C89 警告 檢查Switch語句GCC_WARN_CHECK_SWITCH_STATEMENTS = YES 隱藏局部變數GCC_WARN_SHADOW = YES 隱式轉換成32位的類型GCC_WARN_64_TO_32_BIT_CONVERSION = YES 未完成的Objective-C協議GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = YES 抑制所有的警告GCC_WARN_INHIBIT_ALL_WARNINGS = NO 初始化時沒有完整的括弧GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES例子(a沒有完全的括弧,b有):
int a[ 2 ][ 2 ] = { 0, 1, 2, 3 };
int b[ 2 ][ 2 ] = { { 0, 1 }, { 2, 3 } };
不匹配的返回類型
GCC_WARN_ABOUT_RETURN_TYPE = YES 缺少括弧GCC_WARN_MISSING_PARENTHESES = YES例子:
{
if( a )
if( b )
foo();
else
bar();
}
{
if( a )
{
if( b )
foo();
else
bar();
}
}
在結構體初始化時缺少欄位
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES
缺 少函數原型GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES 在文件結尾缺少新行GCC_WARN_ABOUT_MISSING_NEWLINE = YES 選擇了多個定義的類型(@Selector)GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO 嚴格的Selector匹配GCC_WARN_STRICT_SELECTOR_MATCH = YES 把缺少函數原型當作錯誤GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES 把所有的警告當作錯誤GCC_TREAT_WARNINGS_AS_ERRORS = YES 未定義的SelectorGCC_WARN_UNDECLARED_SELECTOR = YES 未初始化的自動變數GCC_WARN_UNINITIALIZED_AUTOS = YES 未知的Pragma指令GCC_WARN_UNKNOWN_PRAGMAS = YES 未使用的函數GCC_WARN_UNUSED_FUNCTION = YES 未使用的標簽GCC_WARN_UNUSED_LABEL = YES 未使用的參數GCC_WARN_UNUSED_PARAMETER = YES 未使用的值GCC_WARN_UNUSED_VALUE = YES當一個語句計算的結果顯式的未使用的時候發出警告 未使用的變數GCC_WARN_UNUSED_VARIABLE = YES 警告-所有過時的函數GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES offsetof宏未定義使用的警告GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = YES
iphone 常用的<app>-info.plist設置
Application requires iPhone environment如 果應用程序不能在ipod touch上運行,設置此項為true;
Application uses Wi-Fi如果應用程序需要wi-fi才能工作,應該將此屬性設置為true。這么做會提示用戶,如果沒有打開wi-fi的話,打開wi-fi。為了節省 電力,iphone會在30分鍾後自動關閉應用程序中的任何wi-fi。設置這一個屬性可以防止這種情況的發生,並且保持連接處於活動狀態
Bundle display name這用於設置應用程序的名稱,它顯示在iphone屏幕的圖標下方。應用程序名稱限制在10-12個字元,如果超出,iphone將縮寫名 稱。
Bundle identifier這個為應用程序在iphone developer program portal web站點上設置的唯一標識符。(就是你安裝證書的時候,需要把這里對應修改)。
Bundle version這個會設置應用程序版本號,每次部署應用程序的一個新版本時,將會增加這個編號,在app store用的。
Icon already includes gloss and bevel effects默認情況下,應用程序被設置了玻璃效果,把這個設置為true可以阻止這么做。
Icon file(這個不用多說了)設置應用程序圖標的。
Main nib file base name應用程序首次啟動時載入的xib文件 這個基本用不到。
Initial interface orientation 確定了應用程序以風景模式還是任務模式啟動
Localizations多語言。應用程序本地化的一列表,期間用逗號隔開,例如 應用程序支持英語 日語,將會適用 English,Japanese. Status bar is initially hidden 設置是否隱藏狀態欄。你懂的。
Status bar style選擇三種不同格式種的一種。
URL types應用程序支持的url標識符的一個數組。
用URL Scheme進行程序跳轉
打開info.plist,添加一項URL types
展開URL types,再展開Item1,將Item1下的URL identifier修改為URL Scheme
展開URL Scheme,將Item1的內容修改為myapp
其他程序可通過myapp://訪問此自定義URL
參考:http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
IOS後台播放音樂
OS後台播放只是在IOS4.0以後的版本支持。
1,設置後台播放會話
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setActive:YES error:nil];
[session setCategory: error:nil];
2,在info.plist裡面添加
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
靜態庫沒法包含category/分類?
如果你導入一個objc靜態庫,發現很多objc的category 不能調用,可以嘗試在主工程中加入linker選項:
-all_load 加入這個一般就夠了
-ObjC
讓程序最小化再開啟時,從頭開始:
按下 「Home」 鍵以後程序可能並沒有退出而是轉入了後台運行。如果您想讓應用直接退出,最簡單的方法是:在 info-plist 裡面找到 Application does not run in background 一項,勾選即可。
程序退出後任務欄還是有圖標,但是程序原來的所有運行狀態全部丟失,點擊任務欄圖標也不過相當於再次啟動程序;如果允許後台運行,點擊任務欄圖標後會恢復程序中斷時的界面。
本地化字元串:
在infoPlist.strings裡面寫
「string1″=」水果」
代碼裡面寫 myLabel.text = NSLocalizedString(@」string1″, nil);
本地化的Bundle display name:
1)創建一個空文件,取名為InfoPlist.strings
2)對InfoPlist.strings進行本地化(Get Info -> Make Localization),然後設置需要的語言(如中文zh)
3)編輯不同的InfoPlist.strings文件,設置顯示名字
CFBundleDisplayName = 「名字」;
4)(這步不做貌似也可以)編輯Info.plist,添加一個新的屬性Application has localized display name, 設置其類型為boolean,並將其value設置為選中狀態
default圖片的銜接問題:
程序開始後,手動載入default圖片,然後進行過渡效果即可。
遍歷目錄:
NSString *appDocDir = [[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject] relativePath];NSArray *contentOfFolder = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:appDocDir error:NULL];for (NSString *aPath in contentOfFolder) { NSLog(@"apath: %@", aPath); NSString * fullPath = [appDocDir :aPath]; BOOL isDir; if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath isDirectory:&isDir] && !isDir) { [fileList addObject:aPath]; }}
IB:
不論寫不寫property的retain,由IBOutlet都會為對象加一個retainCount,所以只要連接了,就需要在viewDidUnload與dealloc中release並適當置為nil。
預先在IB裡面載入好的文件(比如圖片),即使釋放了Controller,IB中的文件也不會被釋放,直至內存警告,解決辦法是較大的資源用代碼載入。
UIWebView:
用代碼載入UIWebView的內容,navigationType是UIWebViewNavigationTypeOther
CAAnimation:
一定要記得[self.view.layer removeAllAnimations];因為CAAnimation會retain它的delegate
設備型號識別,可通過審核:
+ (NSString*)getDeviceVersion{ size_t size; sysctlbyname("hw.machine", NULL, &size, NULL, 0); char *machine = (char*)malloc(size); sysctlbyname("hw.machine", machine, &size, NULL, 0); NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding]; free(machine); return platform;}
輸出:
//@」iPad1,1″
//@」iPad2,1″
//@」i386″
逗號後面數字解釋:(i386是指模擬器)
1-WiFi版
2-GSM/WCDMA 3G版
3-CDMA版
AppleTV(2G) (AppleTV2,1)
iPad (iPad1,1)
iPad2,1 (iPad2,1)Wifi版
iPad2,2 (iPad2,2)GSM3G版
iPad2,3 (iPad2,3)CDMA3G版
iPhone (iPhone1,1)
iPhone3G (iPhone1,2)
iPhone3GS (iPhone2,1)
iPhone4 (iPhone3,1)
iPhone4(vz) (iPhone3,3)iPhone4 CDMA版
iPhone4S (iPhone4,1)
iPodTouch(1G) (iPod1,1)
iPodTouch(2G) (iPod2,1)
iPodTouch(3G) (iPod3,1)
iPodTouch(4G) (iPod4,1)
判斷ipad/iphone
12UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPadUI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone
或者
1[[[UIDevice currentDevice] model] isEqualToString:@"iPad"];
判斷設備是否有攝像頭
1[UIImagePickerController isSourceTypeAvailable:];
Ⅷ matlab2020b編譯圖標在哪裡
菜單欄。
在菜單欄中找到編譯按鈕,然後進行相關的操作,如果菜單中沒有出現,在command窗口(命令行窗口)中輸入edit回車就行。
matlab編輯器窗口和主窗口分開還原的步驟。首先,在編輯器窗口下,按ctrl+shift+D,此時編輯器窗口和主窗口就合並在一起了。然後,在菜單欄中選擇布局-默認,如下圖。這樣就恢復到原來的布局了。
Ⅸ 請問怎麼在xcode里編譯c++程序 剛入手mac 用的是 app store 里的xcode 謝謝
create new project -> mac os x下application -> command line tool -> next -> proctName&type [c++] -> next
編寫完代碼後點擊左上角三角run就行了,或者command+B編譯,或者直接command+R 運行