General Barron/Sandbox – User
mNo edit summary |
Lou Montana (talk | contribs) m (Text replacement - "Category:Armed Assault" to "{{arma1}}") |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
This is your 'Sandbox'. | This is your 'Sandbox'. | ||
Line 14: | Line 13: | ||
''The table of content you see at the just below this is automatically created from the section headers (lines surrounded by equal signs).'' | ''The table of content you see at the just below this is automatically created from the section headers (lines surrounded by equal signs).'' | ||
==Formatting== | == Formatting == | ||
:'''bold''' | :'''bold''' | ||
::''italic'' | ::''italic'' | ||
:::Indentation (one position per colon) | :::Indentation (one position per colon) | ||
==Links== | == Links == | ||
===Internal Links (pages on this wiki)=== | === Internal Links (pages on this wiki) === | ||
[[Operation Flashpoint: Easter Eggs]] (use full title for normal pages) | [[Operation Flashpoint: Easter Eggs]] (use full title for normal pages) | ||
Line 26: | Line 25: | ||
[[Operation Flashpoint: Easter Eggs|Easter Eggs]] (to name a link use [URL | name]) | [[Operation Flashpoint: Easter Eggs|Easter Eggs]] (to name a link use [URL | name]) | ||
[[:Category:Armed Assault]] (put colon in first column for category pages) | [[:Category:ArmA: Armed Assault|{{arma1}}]] (put colon in first column for category pages) | ||
===External Links (to other sites)=== | === External Links (to other sites) === | ||
http://en.wikipedia.org/wiki/Wikipedia:How_to_edit_a_page | http://en.wikipedia.org/wiki/Wikipedia:How_to_edit_a_page | ||
[http://meta.wikimedia.org/wiki/Help:Wikitext_examples More wikitext examples] (to name a link use [URL space name]) | [http://meta.wikimedia.org/wiki/Help:Wikitext_examples More wikitext examples] (to name a link use [URL space name]) | ||
<hr><hr> | |||
Notes on preprocessor directives in .sqf files (WIP for wiki page): | |||
Linky: http://www.cplusplus.com/doc/tutorial/preprocessor.html | |||
NOTE: all preprocessor directives are run BEFORE the script is run. So you can't expect it to read the value of variables, for example. Preprocessing basically just does find, replace, and paste operations in your code. | |||
-------- | |||
Macro definitions (#define, #undef): these work as described. Note that the two special operators (# and ##) work as well. | |||
-------- | |||
When including defines in defines, the # operator works after expanding all defines. For example: | |||
#define fn_myfunc compile preprocessfile 'myfile.sqf' | |||
#define addquotes(x) #x | |||
addquotes(call fn_myfunc) | |||
result is: "call compile preprocessfile 'myfile.sqf'" | |||
Multi-line notes: | |||
To spread a define across mult lines, add \ at the end of each line (save the last). Example: | |||
#define whatever \ | |||
dosomething; \ | |||
dosomething else | |||
Comments: | |||
Comments work at the end of single line defines, but not multi-line defines. Example: | |||
#define something "whatever" //comment | |||
(this works) | |||
#define something \ //comment | |||
"whatever" | |||
(this doesn't work!!!) | |||
Nested defines: | |||
Defines can be nested in each other, and they are all expanded. You can't seem to put a multi-line define inside of a multi-line define, nor can you pass a multi-line define in as a parameter of a macro. | |||
-------- | |||
Conditional inclusions (#ifdef, #ifndef, #if, #endif, #else and #elif) | |||
-------- | |||
#ifdef, #ifndef, #endif all work in configs, and I would assume in scripts as well. I haven't verified #else #elif or #if. | |||
--------- | |||
Line control (#line) | |||
Error directive (#error) | |||
Pragma directive (#pragma) | |||
--------- | |||
Doesn't seem to work? At least not in scripts. | |||
In scripts, using any unknown # directive seems to cause the entire file to be returned as empty when preprocessed. Ex: placing #asdf or #error, etc, in a script will make it turn into {} when preprocessed. When combined with #ifdef and #ifndef operators, this could be a useful feature. | |||
Need to verify what happens in configs with this! | |||
--------- | |||
Source file inclusion (#include) | |||
--------- | |||
This obviously works, and is very useful. For example, you can make a common header file for all your scripts. In this header you can #define constants, rather than having to use variables to store them. Also very useful for #defining a descriptive name for numbers such as IDCs and array indexes. | |||
I'm not sure about the difference between "" and <> includes. Normally I use "". | |||
Note that the path (at least with "") is relative to the directory of the file where you issue the #include. | |||
HOWEVER, if you put a \ slash at the beginning, the path will instead be relative to your vbs2.exe / arma.exe. In this way you can include files that are directly in your install directory. | |||
You can also #include stuff that is in addon / pbo files in this way. In this case, the path should be the path to the file when it is in your P: drive (i.e. before the pbo is packed), minus the P:. Example: "\vbs2\customer\vehicles\myvehicle\data\scripts\myscript.sqf" | |||
--------- | |||
Predefined macro names | |||
--------- | |||
__LINE__ and __FILE__ both WORK when used in .sqf! Very cool! | |||
The others don't work though. I need to check to see if these work in configs. | |||
Configs have the __EXEC and __EVAL macros predefined. These macros allow the use of variables and simple scripting expressions within configs (string concatenation, while loops, math operations, etc). See other wiki for documentation on these. These macros do NOT work in scripts! These macros work even if the config isn't cfgConverted. | |||
[[Category:Sandbox]] |
Latest revision as of 01:43, 20 July 2021
This is your 'Sandbox'.
It is your personal place to experiment with wiki code, keep notes, and to store unfinished articles you are working on.
Feel free to change, replace, or delete whatever is in here.
Please keep in mind to follow the rules you can find in the Guidelines, especially to sign your comments with --~~~~, and to write in English only.
Below are some basic commands that you should know before posting on the wiki.
The table of content you see at the just below this is automatically created from the section headers (lines surrounded by equal signs).
Formatting
- bold
- italic
- Indentation (one position per colon)
- italic
Links
Internal Links (pages on this wiki)
Operation Flashpoint: Easter Eggs (use full title for normal pages)
Easter Eggs (to name a link use [URL | name])
Armed Assault (put colon in first column for category pages)
External Links (to other sites)
http://en.wikipedia.org/wiki/Wikipedia:How_to_edit_a_page
More wikitext examples (to name a link use [URL space name])
Notes on preprocessor directives in .sqf files (WIP for wiki page):
Linky: http://www.cplusplus.com/doc/tutorial/preprocessor.html
NOTE: all preprocessor directives are run BEFORE the script is run. So you can't expect it to read the value of variables, for example. Preprocessing basically just does find, replace, and paste operations in your code.
Macro definitions (#define, #undef): these work as described. Note that the two special operators (# and ##) work as well.
When including defines in defines, the # operator works after expanding all defines. For example:
- define fn_myfunc compile preprocessfile 'myfile.sqf'
- define addquotes(x) #x
addquotes(call fn_myfunc) result is: "call compile preprocessfile 'myfile.sqf'"
Multi-line notes:
To spread a define across mult lines, add \ at the end of each line (save the last). Example:
- define whatever \
dosomething; \ dosomething else
Comments:
Comments work at the end of single line defines, but not multi-line defines. Example:
- define something "whatever" //comment
(this works)
- define something \ //comment
"whatever" (this doesn't work!!!)
Nested defines:
Defines can be nested in each other, and they are all expanded. You can't seem to put a multi-line define inside of a multi-line define, nor can you pass a multi-line define in as a parameter of a macro.
Conditional inclusions (#ifdef, #ifndef, #if, #endif, #else and #elif)
- ifdef, #ifndef, #endif all work in configs, and I would assume in scripts as well. I haven't verified #else #elif or #if.
Line control (#line) Error directive (#error) Pragma directive (#pragma)
Doesn't seem to work? At least not in scripts.
In scripts, using any unknown # directive seems to cause the entire file to be returned as empty when preprocessed. Ex: placing #asdf or #error, etc, in a script will make it turn into {} when preprocessed. When combined with #ifdef and #ifndef operators, this could be a useful feature.
Need to verify what happens in configs with this!
Source file inclusion (#include)
This obviously works, and is very useful. For example, you can make a common header file for all your scripts. In this header you can #define constants, rather than having to use variables to store them. Also very useful for #defining a descriptive name for numbers such as IDCs and array indexes.
I'm not sure about the difference between "" and <> includes. Normally I use "".
Note that the path (at least with "") is relative to the directory of the file where you issue the #include.
HOWEVER, if you put a \ slash at the beginning, the path will instead be relative to your vbs2.exe / arma.exe. In this way you can include files that are directly in your install directory.
You can also #include stuff that is in addon / pbo files in this way. In this case, the path should be the path to the file when it is in your P: drive (i.e. before the pbo is packed), minus the P:. Example: "\vbs2\customer\vehicles\myvehicle\data\scripts\myscript.sqf"
Predefined macro names
__LINE__ and __FILE__ both WORK when used in .sqf! Very cool!
The others don't work though. I need to check to see if these work in configs.
Configs have the __EXEC and __EVAL macros predefined. These macros allow the use of variables and simple scripting expressions within configs (string concatenation, while loops, math operations, etc). See other wiki for documentation on these. These macros do NOT work in scripts! These macros work even if the config isn't cfgConverted.