BlankPage: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
No edit summary
Tag: Reverted
No edit summary
 
(20 intermediate revisions by the same user not shown)
Line 68: Line 68:
</gallery>
</gallery>
<!-- additional availability notes go below here -->
<!-- additional availability notes go below here -->
* The capability to load from ''memory'' was introduced in '''QB64-PE''' ''v3.5.0''.
* The capability to load from ''memory'' was introduced in '''QB64-PE v3.5.0'''.




Line 81: Line 81:
{{CodeEnd}}
{{CodeEnd}}
{{Small|This template allows for a short author credit.}}
{{Small|This template allows for a short author credit.}}
{{PreStart}}
'''Note:''' To avoid the annoying task of manually inserting the templates
in your code examples, since v3.7.0 you may simply write your example
in the IDE and later use the menu "File > Export As > Wiki example" to
export a completely prepared code block, which you can paste "as is"
into the Wiki page.


Oh, and by the way, this ''preformatted text block'' is also new. Generally
it's the same as a ''fixed text block'' shown above, but it uses horizontal
scrollers instead of stretching the text box and it has a more plain
appearance. If you want avoid the horizontal scroller, then restrict
yourself to a line length of max. 72 characters.
{{PreEnd}}


: The output block is available for the SCREEN 0 background colors 0-7
: The output block is available for the SCREEN 0 background colors 0-7
Line 91: Line 103:


{{PageSeeAlso}}
{{PageSeeAlso}}
* [https://qb64phoenix.com/forum/showthread.php?tid=1066 Featured in our "Keyword of the Day" series]
* [[Keyword Reference - Alphabetical]]
* [[Keyword Reference - Alphabetical]]
* [[Keyword Reference - By usage]]
* [[Keyword Reference - By usage]]
Line 96: Line 109:


{{PageNavigation}}
{{PageNavigation}}
{{CodeStart}}
{{Cm|BlankPage|$CHECKING}}:{{Cl|BlankPage|OFF}}
{{Text|<nowiki>'</nowiki>|#919191}}{{Cm|BlankPage|$STATIC}}
{{Text|<nowiki>'$CHECKING:OFF</nowiki>|#919191}}
{{Text|<nowiki>''$CHECKING:OFF</nowiki>|#919191}}
{{Text|<nowiki>'+---------------+---------------------------------------------------+</nowiki>|#919191}}
{{Text|<nowiki>'| ###### ###### |    .--. .        .-.                            |</nowiki>|#919191}}
{{Text|<nowiki>'| ##  ## ##  # |    |  )|        (  ) o                        |</nowiki>|#919191}}
{{Text|<nowiki>'| ##  ##  ##    |    |--' |--. .-.  `-.  .  .-...--.--. .-.        |</nowiki>|#919191}}
{{Text|<nowiki>'| ######  ##  |    |  \ |  |(  )(  ) | (  ||  |  |(  )      |</nowiki>|#919191}}
{{Text|<nowiki>'| ##      ##    |    '  `'  `-`-'  `-'-' `-`-`|'  '  `-`-'`-      |</nowiki>|#919191}}
{{Text|<nowiki>'| ##    ##  # |                            ._.'                  |</nowiki>|#919191}}
{{Text|<nowiki>'| ##    ###### |  Sources & Documents placed in the Public Domain. |</nowiki>|#919191}}
{{Text|<nowiki>'+---------------+---------------------------------------------------+</nowiki>|#919191}}
{{Text|<nowiki>'|                                                                  |</nowiki>|#919191}}
{{Text|<nowiki>'| === MakeCARR.bas ===                                              |</nowiki>|#919191}}
{{Text|<nowiki>'|                                                                  |</nowiki>|#919191}}
{{Text|<nowiki>'| == Create a C/C++ array out of the given file, so you can embed  |</nowiki>|#919191}}
{{Text|<nowiki>'| == it in your program and write it back when needed.              |</nowiki>|#919191}}
{{Text|<nowiki>'|                                                                  |</nowiki>|#919191}}
{{Text|<nowiki>'| == Two files are created, the .h file, which contains the array(s)|</nowiki>|#919191}}
{{Text|<nowiki>'| == and some functions, and a respective .bm file which needs to  |</nowiki>|#919191}}
{{Text|<nowiki>'| == be $INCLUDEd with your program and does provide the FUNCTION  |</nowiki>|#919191}}
{{Text|<nowiki>'| == to write back the array(s) into any file. All used functions  |</nowiki>|#919191}}
{{Text|<nowiki>'| == are standard library calls, no API calls are involved, so the  |</nowiki>|#919191}}
{{Text|<nowiki>'| == writeback should work on all QB64 supported platforms.        |</nowiki>|#919191}}
{{Text|<nowiki>'|                                                                  |</nowiki>|#919191}}
{{Text|<nowiki>'| == Make sure to adjust the path for the .h file for your personal |</nowiki>|#919191}}
{{Text|<nowiki>'| == needs in the created .bm files (DECLARE LIBRARY), if required. |</nowiki>|#919191}}
{{Text|<nowiki>'| == You may specify default paths right below this header.        |</nowiki>|#919191}}
{{Text|<nowiki>'|                                                                  |</nowiki>|#919191}}
{{Text|<nowiki>'| == This program needs the 'lzwpacker.bm' file available from the  |</nowiki>|#919191}}
{{Text|<nowiki>'| == Libraries Collection here:                                    |</nowiki>|#919191}}
{{Text|<nowiki>'| ==      http://qb64phoenix.com/forum/forumdisplay.php?fid=23      |</nowiki>|#919191}}
{{Text|<nowiki>'| == as it will try to pack the given file to keep the array(s) as  |</nowiki>|#919191}}
{{Text|<nowiki>'| == small as possible. If compression is successful, then your    |</nowiki>|#919191}}
{{Text|<nowiki>'| == program also must $INCLUDE 'lzwpacker.bm' to be able to unpack |</nowiki>|#919191}}
{{Text|<nowiki>'| == the file data again for write back. MakeCARR.bas is printing  |</nowiki>|#919191}}
{{Text|<nowiki>'| == a reminder message in such a case.                            |</nowiki>|#919191}}
{{Text|<nowiki>'|                                                                  |</nowiki>|#919191}}
{{Text|<nowiki>'+-------------------------------------------------------------------+</nowiki>|#919191}}
{{Text|<nowiki>'| Done by RhoSigma, R.Heyder, provided AS IS, use at your own risk. |</nowiki>|#919191}}
{{Text|<nowiki>'| Find me in the QB64 Forum or mail to support@rhosigma-cw.net for  |</nowiki>|#919191}}
{{Text|<nowiki>'| any questions or suggestions. Thanx for your interest in my work. |</nowiki>|#919191}}
{{Text|<nowiki>'+-------------------------------------------------------------------+</nowiki>|#919191}}
{{Cm|BlankPage|$NOPREFIX}}
{{Text|<nowiki>'$NOPREFIX</nowiki>|#919191}}
{{Text|<nowiki>''$NOPREFIX</nowiki>|#919191}}
$DYNAMIC
{{Text|<nowiki>'</nowiki>|#919191}}{{Cm|BlankPage|$DYNAMIC}}
{{Text|<nowiki>''$DYNAMIC</nowiki>|#919191}}
{{Text|<nowiki>'REM $DYNAMIC</nowiki>|#919191}}
{{Cl|BlankPage|REM}} ${{Cl|BlankPage|DYNAMIC}}
{{Cl|BlankPage|REM}} {{Text|<nowiki>'$DYNAMIC</nowiki>|#919191}}
{{Text|<nowiki>'--- if you wish, set any default paths, end with a backslash ---</nowiki>|#919191}}
srcPath$ = {{Text|<nowiki>""</nowiki>|#FFB100}} {{Text|<nowiki>'source path</nowiki>|#919191}}
tarPath$ = {{Text|<nowiki>""</nowiki>|#FFB100}} {{Text|<nowiki>'target path</nowiki>|#919191}}
{{Text|<nowiki>'-----</nowiki>|#919191}}
{{Cl|BlankPage|IF}} srcPath$ <> {{Text|<nowiki>""</nowiki>|#FFB100}} {{Cl|BlankPage|THEN}}
    {{Cl|BlankPage|COLOR}} {{Text|15|#F580B1}}: {{Cl|BlankPage|PRINT}} {{Text|<nowiki>"Default source path: "</nowiki>|#FFB100}}: {{Cl|BlankPage|COLOR}} {{Text|7|#F580B1}}: {{Cl|BlankPage|PRINT}} srcPath$: {{Cl|BlankPage|PRINT}}
{{Cl|BlankPage|END}} {{Cl|BlankPage|IF}}
{{Cl|BlankPage|IF}} tarPath$ <> {{Text|<nowiki>""</nowiki>|#FFB100}} {{Cl|BlankPage|THEN}}
    {{Cl|BlankPage|COLOR}} {{Text|15|#F580B1}}: {{Cl|BlankPage|PRINT}} {{Text|<nowiki>"Default target path: "</nowiki>|#FFB100}}: {{Cl|BlankPage|COLOR}} {{Text|7|#F580B1}}: {{Cl|BlankPage|PRINT}} tarPath$: {{Cl|BlankPage|PRINT}}
{{Cl|BlankPage|END}} {{Cl|BlankPage|IF}}
I& = {{Cl|BlankPage|SCREENIMAGE}}
{{Text|<nowiki>'--- collect inputs (relative paths allowed, based on default paths) ---</nowiki>|#919191}}
source:
{{Cl|BlankPage|LINE}} {{Cl|BlankPage|INPUT}} {{Text|<nowiki>"Source Filename: "</nowiki>|#FFB100}}; src$ {{Text|<nowiki>'any file you want to put into a C/C++ array</nowiki>|#919191}}
{{Cl|BlankPage|IF}} src$ = {{Text|<nowiki>""</nowiki>|#FFB100}} {{Cl|BlankPage|GOTO}} source
target:
{{Cl|BlankPage|LINE}} {{Cl|BlankPage|INPUT}} {{Text|<nowiki>"Target Basename: "</nowiki>|#FFB100}}; tar$ {{Text|<nowiki>'write stuff into this file(s) (.h/.bm is added)</nowiki>|#919191}}
{{Cl|BlankPage|IF}} tar$ = {{Text|<nowiki>""</nowiki>|#FFB100}} {{Cl|BlankPage|GOTO}} target
{{Text|<nowiki>'-----</nowiki>|#919191}}
{{Cl|BlankPage|ON}} {{Cl|BlankPage|ERROR}} {{Cl|BlankPage|GOTO}} abort
{{Cl|BlankPage|OPEN}} {{Text|<nowiki>"I"</nowiki>|#FFB100}}, #1, srcPath$ + src$: {{Cl|BlankPage|CLOSE}} #1 {{Text|<nowiki>'file exist check</nowiki>|#919191}}
{{Cl|BlankPage|OPEN}} {{Text|<nowiki>"O"</nowiki>|#FFB100}}, #2, tarPath$ + tar$ + {{Text|<nowiki>".bm"</nowiki>|#FFB100}}: {{Cl|BlankPage|CLOSE}} #2 {{Text|<nowiki>'path exist check</nowiki>|#919191}}
{{Cl|BlankPage|ON}} {{Cl|BlankPage|ERROR}} {{Cl|BlankPage|GOTO}} {{Text|0|#F580B1}}
{{Text|<nowiki>'--- separate source filename part ---</nowiki>|#919191}}
{{Cl|BlankPage|FOR}} po% = {{Cl|BlankPage|LEN}}(src$) {{Cl|BlankPage|TO}} {{Text|1|#F580B1}} {{Cl|BlankPage|STEP}} {{Text|-1|#F580B1}}
    {{Cl|BlankPage|IF}} {{Cl|BlankPage|MID$}}(src$, po%, {{Text|1|#F580B1}}) = {{Text|<nowiki>"\"</nowiki>|#FFB100}} {{Cl|BlankPage|OR}} {{Cl|BlankPage|MID$}}(src$, po%, {{Text|1|#F580B1}}) = {{Text|<nowiki>"/"</nowiki>|#FFB100}} {{Cl|BlankPage|THEN}}
        srcName$ = {{Cl|BlankPage|MID$}}(src$, po% + {{Text|1|#F580B1}})
        {{Cl|BlankPage|EXIT}} {{Cl|BlankPage|FOR}}
    {{Cl|BlankPage|ELSEIF}} po% = {{Text|1|#F580B1}} {{Cl|BlankPage|THEN}}
        srcName$ = src$
    {{Cl|BlankPage|END}} {{Cl|BlankPage|IF}}
{{Cl|BlankPage|NEXT}} po%
{{Text|<nowiki>'--- separate target filename part ---</nowiki>|#919191}}
{{Cl|BlankPage|FOR}} po% = {{Cl|BlankPage|LEN}}(tar$) {{Cl|BlankPage|TO}} {{Text|1|#F580B1}} {{Cl|BlankPage|STEP}} {{Text|-1|#F580B1}}
    {{Cl|BlankPage|IF}} {{Cl|BlankPage|MID$}}(tar$, po%, {{Text|1|#F580B1}}) = {{Text|<nowiki>"\"</nowiki>|#FFB100}} {{Cl|BlankPage|OR}} {{Cl|BlankPage|MID$}}(tar$, po%, {{Text|1|#F580B1}}) = {{Text|<nowiki>"/"</nowiki>|#FFB100}} {{Cl|BlankPage|THEN}}
        tarName$ = {{Cl|BlankPage|MID$}}(tar$, po% + {{Text|1|#F580B1}})
        {{Cl|BlankPage|EXIT}} {{Cl|BlankPage|FOR}}
    {{Cl|BlankPage|ELSEIF}} po% = {{Text|1|#F580B1}} {{Cl|BlankPage|THEN}}
        tarName$ = tar$
    {{Cl|BlankPage|END}} {{Cl|BlankPage|IF}}
{{Cl|BlankPage|NEXT}} po%
{{Cl|BlankPage|MID$}}(tarName$, {{Text|1|#F580B1}}, {{Text|1|#F580B1}}) = {{Cl|BlankPage|UCASE$}}({{Cl|BlankPage|MID$}}(tarName$, {{Text|1|#F580B1}}, {{Text|1|#F580B1}})) {{Text|<nowiki>'capitalize 1st letter</nowiki>|#919191}}
{{Text|<nowiki>'---------------------------------------------------------------------</nowiki>|#919191}}
{{Text|<nowiki>' Depending on the source file's size, one or more array(s) are</nowiki>|#919191}}
{{Text|<nowiki>' created. This is because some C/C++ compilers seem to have problems</nowiki>|#919191}}
{{Text|<nowiki>' with arrays with more than 65535 elements. This does not affect the</nowiki>|#919191}}
{{Text|<nowiki>' write back, as the write function will take this behavior into account.</nowiki>|#919191}}
{{Text|<nowiki>'---------------------------------------------------------------------</nowiki>|#919191}}
{{Text|<nowiki>'--- init ---</nowiki>|#919191}}
{{Cl|BlankPage|OPEN}} {{Text|<nowiki>"B"</nowiki>|#FFB100}}, #1, srcPath$ + src$
filedata$ = {{Cl|BlankPage|SPACE$}}({{Cl|BlankPage|LOF}}({{Text|1|#F580B1}}))
{{Cl|BlankPage|GET}} #1, , filedata$
{{Cl|BlankPage|CLOSE}} #1
rawdata$ = LzwPack$(filedata$, {{Text|20|#F580B1}})
{{Cl|BlankPage|IF}} rawdata$ <> {{Text|<nowiki>""</nowiki>|#FFB100}} {{Cl|BlankPage|THEN}}
    {{Cl|BlankPage|OPEN}} {{Text|<nowiki>"O"</nowiki>|#FFB100}}, #1, tarPath$ + tar$ + {{Text|<nowiki>".lzw"</nowiki>|#FFB100}}
    {{Cl|BlankPage|CLOSE}} #1
    {{Cl|BlankPage|OPEN}} {{Text|<nowiki>"B"</nowiki>|#FFB100}}, #1, tarPath$ + tar$ + {{Text|<nowiki>".lzw"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PUT}} #1, , rawdata$
    {{Cl|BlankPage|CLOSE}} #1
    packed% = {{Text|-1|#F580B1}}
    {{Cl|BlankPage|OPEN}} {{Text|<nowiki>"B"</nowiki>|#FFB100}}, #1, tarPath$ + tar$ + {{Text|<nowiki>".lzw"</nowiki>|#FFB100}}
{{Cl|BlankPage|ELSE}}
    packed% = {{Text|0|#F580B1}}
    {{Cl|BlankPage|OPEN}} {{Text|<nowiki>"B"</nowiki>|#FFB100}}, #1, srcPath$ + src$
{{Cl|BlankPage|END}} {{Cl|BlankPage|IF}}
fl& = {{Cl|BlankPage|LOF}}({{Text|1|#F580B1}})
cntL& = {{Cl|BlankPage|INT}}(fl& / {{Text|32|#F580B1}})
cntV& = {{Cl|BlankPage|INT}}(cntL& / {{Text|8180|#F580B1}})
cntB& = (fl& - (cntL& * {{Text|32|#F580B1}}))
{{Text|<nowiki>'--- .h include file ---</nowiki>|#919191}}
{{Cl|BlankPage|OPEN}} {{Text|<nowiki>"O"</nowiki>|#FFB100}}, #2, tarPath$ + tar$ + {{Text|<nowiki>".h"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"// ============================================================"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"// === This file was created with MakeCARR.bas by RhoSigma, ==="</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"// === use it in conjunction with its respective .bm file.  ==="</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"// ============================================================"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>""</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"// --- Array(s) representing the contents of file "</nowiki>|#FFB100}}; srcName$
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"// ---------------------------------------------------------------------"</nowiki>|#FFB100}}
{{Text|<nowiki>'--- read LONGs ---</nowiki>|#919191}}
tmpI$ = {{Cl|BlankPage|SPACE$}}({{Text|32|#F580B1}})
{{Cl|BlankPage|FOR}} vc& = {{Text|0|#F580B1}} {{Cl|BlankPage|TO}} cntV&
    {{Cl|BlankPage|IF}} vc& = cntV& {{Cl|BlankPage|THEN}} numL& = (cntL& {{Cl|BlankPage|MOD}} {{Text|8180|#F580B1}}): {{Cl|BlankPage|ELSE}} numL& = {{Text|8180|#F580B1}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"static const uint32_t "</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"L"</nowiki>|#FFB100}}; {{Cl|BlankPage|LTRIM$}}({{Cl|BlankPage|STR$}}(vc&)); {{Text|<nowiki>"[] = {"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    "</nowiki>|#FFB100}}; {{Cl|BlankPage|LTRIM$}}({{Cl|BlankPage|STR$}}(numL& * {{Text|8|#F580B1}})); {{Text|<nowiki>","</nowiki>|#FFB100}}
    {{Cl|BlankPage|FOR}} z& = {{Text|1|#F580B1}} {{Cl|BlankPage|TO}} numL&
        {{Cl|BlankPage|GET}} #1, , tmpI$: offI% = {{Text|1|#F580B1}}
        tmpO$ = {{Text|<nowiki>"    "</nowiki>|#FFB100}} + {{Cl|BlankPage|STRING$}}({{Text|88|#F580B1}}, {{Text|<nowiki>","</nowiki>|#FFB100}}): offO% = {{Text|5|#F580B1}}
        {{Cl|BlankPage|DO}}
            tmpL& = {{Cl|BlankPage|CVL}}({{Cl|BlankPage|MID$}}(tmpI$, offI%, {{Text|4|#F580B1}})): offI% = offI% + {{Text|4|#F580B1}}
            {{Cl|BlankPage|MID$}}(tmpO$, offO%, {{Text|10|#F580B1}}) = {{Text|<nowiki>"0x"</nowiki>|#FFB100}} + {{Cl|BlankPage|RIGHT$}}({{Text|<nowiki>"00000000"</nowiki>|#FFB100}} + {{Cl|BlankPage|HEX$}}(tmpL&), {{Text|8|#F580B1}})
            offO% = offO% + {{Text|11|#F580B1}}
        {{Cl|BlankPage|LOOP}} {{Cl|BlankPage|UNTIL}} offO% > {{Text|92|#F580B1}}
        {{Cl|BlankPage|IF}} z& < numL& {{Cl|BlankPage|THEN}} {{Cl|BlankPage|PRINT}} #2, tmpO$: {{Cl|BlankPage|ELSE}} {{Cl|BlankPage|PRINT}} #2, {{Cl|BlankPage|LEFT$}}(tmpO$, {{Text|91|#F580B1}})
    {{Cl|BlankPage|NEXT}} z&
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"};"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>""</nowiki>|#FFB100}}
{{Cl|BlankPage|NEXT}} vc&
{{Text|<nowiki>'--- read remaining BYTEs ---</nowiki>|#919191}}
{{Cl|BlankPage|IF}} cntB& > {{Text|0|#F580B1}} {{Cl|BlankPage|THEN}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"static const uint8_t "</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"B[] = {"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    "</nowiki>|#FFB100}}; {{Cl|BlankPage|LTRIM$}}({{Cl|BlankPage|STR$}}(cntB&)); {{Text|<nowiki>","</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    "</nowiki>|#FFB100}};
    {{Cl|BlankPage|FOR}} x% = {{Text|1|#F580B1}} {{Cl|BlankPage|TO}} cntB&
        {{Cl|BlankPage|GET}} #1, , tmpB%%
        {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"0x"</nowiki>|#FFB100}} + {{Cl|BlankPage|RIGHT$}}({{Text|<nowiki>"00"</nowiki>|#FFB100}} + {{Cl|BlankPage|HEX$}}(tmpB%%), {{Text|2|#F580B1}});
        {{Cl|BlankPage|IF}} x% <> {{Text|16|#F580B1}} {{Cl|BlankPage|THEN}}
            {{Cl|BlankPage|IF}} x% <> cntB& {{Cl|BlankPage|THEN}} {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>","</nowiki>|#FFB100}};
        {{Cl|BlankPage|ELSE}}
            {{Cl|BlankPage|IF}} x% <> cntB& {{Cl|BlankPage|THEN}}
                {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>","</nowiki>|#FFB100}}
                {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    "</nowiki>|#FFB100}};
            {{Cl|BlankPage|END}} {{Cl|BlankPage|IF}}
        {{Cl|BlankPage|END}} {{Cl|BlankPage|IF}}
    {{Cl|BlankPage|NEXT}} x%
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>""</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"};"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>""</nowiki>|#FFB100}}
{{Cl|BlankPage|END}} {{Cl|BlankPage|IF}}
{{Text|<nowiki>'--- some functions ---</nowiki>|#919191}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"// --- Saved full qualified output path and filename, so we've no troubles"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"// --- when cleaning up, even if the current working folder was changed"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"// --- during program runtime."</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"// ---------------------------------------------------------------------"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"char "</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Name[8192]; // it's a safe size for any current OS"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>""</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"// --- Cleanup function to delete the written file, called by the atexit()"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"// --- handler at program termination time, if requested by user."</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"// ---------------------------------------------------------------------"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"void Kill"</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Data(void)"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"{"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    remove("</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Name);"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"}"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>""</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"// --- Function to write the array(s) back into a file, will return the"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"// --- full qualified output path and filename on success, otherwise an"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"// --- empty string is returned (access/write errors, file truncated)."</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"// ---------------------------------------------------------------------"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"const char *Write"</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Data(const char *FileName, int16_t AutoClean)"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"{"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    FILE  *han = NULL; // file handle"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    int32_t num = NULL; // written elements"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>""</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    #ifdef QB64_WINDOWS"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    if (!_fullpath("</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Name, FileName, 8192)) return "</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>";"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    #else"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    if (!realpath(FileName, "</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Name)) return "</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>";"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    #endif"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>""</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    if (!(han = fopen("</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Name, "</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>"wb"</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>"))) return "</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>";"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    if (AutoClean) atexit(Kill"</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Data);"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>""</nowiki>|#FFB100}}
{{Cl|BlankPage|FOR}} vc& = {{Text|0|#F580B1}} {{Cl|BlankPage|TO}} cntV&
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    num = fwrite(&"</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"L"</nowiki>|#FFB100}}; {{Cl|BlankPage|LTRIM$}}({{Cl|BlankPage|STR$}}(vc&)); {{Text|<nowiki>"[1], 4, "</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"L"</nowiki>|#FFB100}}; {{Cl|BlankPage|LTRIM$}}({{Cl|BlankPage|STR$}}(vc&)); {{Text|<nowiki>"[0], han);"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    if (num != "</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"L"</nowiki>|#FFB100}}; {{Cl|BlankPage|LTRIM$}}({{Cl|BlankPage|STR$}}(vc&)); {{Text|<nowiki>"[0]) {fclose(han); return "</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>";}"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>""</nowiki>|#FFB100}}
{{Cl|BlankPage|NEXT}} vc&
{{Cl|BlankPage|IF}} cntB& > {{Text|0|#F580B1}} {{Cl|BlankPage|THEN}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    num = fwrite(&"</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"B[1], 1, "</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"B[0], han);"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    if (num != "</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"B[0]) {fclose(han); return "</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>";}"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>""</nowiki>|#FFB100}}
{{Cl|BlankPage|END}} {{Cl|BlankPage|IF}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    fclose(han);"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    return "</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Name;"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"}"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>""</nowiki>|#FFB100}}
{{Text|<nowiki>'--- ending ---</nowiki>|#919191}}
{{Cl|BlankPage|CLOSE}} #2
{{Cl|BlankPage|CLOSE}} #1
{{Text|<nowiki>'--- .bm include file ---</nowiki>|#919191}}
{{Cl|BlankPage|OPEN}} {{Text|<nowiki>"O"</nowiki>|#FFB100}}, #2, tarPath$ + tar$ + {{Text|<nowiki>".bm"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'============================================================"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'=== This file was created with MakeCARR.bas by RhoSigma, ==="</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'=== you must $INCLUDE this at the end of your program.  ==="</nowiki>|#FFB100}}
{{Cl|BlankPage|IF}} packed% {{Cl|BlankPage|THEN}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'=== ---------------------------------------------------- ==="</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'=== If your program is NOT a GuiTools based application, ==="</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'=== then it must also $INCLUDE: 'lzwpacker.bm' available ==="</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'=== from the Libraries Collection here:                  ==="</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'=== http://qb64phoenix.com/forum/forumdisplay.php?fid=23 ==="</nowiki>|#FFB100}}
{{Cl|BlankPage|END}} {{Cl|BlankPage|IF}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'============================================================"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>""</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'-----------------"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'--- Important ---"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'-----------------"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' If you need to move around this .bm file and its respective .h file"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' to fit in your project, then make sure the path in the DECLARE LIBRARY"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' statement below does match the actual .h file location. It's best to"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' specify a relative path assuming your QB64 installation folder as root."</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'---------------------------------------------------------------------"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>""</nowiki>|#FFB100}}
{{Text|<nowiki>'--- writeback function ---</nowiki>|#919191}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'"</nowiki>|#FFB100}}; {{Cl|BlankPage|STRING$}}({{Cl|BlankPage|LEN}}(tarName$) + {{Text|19|#F580B1}}, {{Text|<nowiki>"-"</nowiki>|#FFB100}})
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'--- Write"</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Array$ ---"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'"</nowiki>|#FFB100}}; {{Cl|BlankPage|STRING$}}({{Cl|BlankPage|LEN}}(tarName$) + {{Text|19|#F580B1}}, {{Text|<nowiki>"-"</nowiki>|#FFB100}})
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' This function will write the array(s) you've created with MakeCARR.bas"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' back to disk and so it rebuilds the original file."</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' After the writeback call, only use the returned realFile$ to access the"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' written file. It's the full qualified absolute path and filename, which"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' is made by expanding your maybe given relative path and an maybe altered"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' filename (number added) in order to avoid the overwriting of an already"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' existing file with the same name in the given location. By this means"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' you'll always have safe access to the file, no matter how your current"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' working folder changes during runtime."</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' If you wish, the written file can automatically be deleted for you when"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' your program will end, so you don't need to do the cleanup yourself."</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'----------"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' SYNTAX:"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'  realFile$ = Write"</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Array$ (wantFile$, autoDel%)"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'----------"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' INPUTS:"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'  --- wantFile$ ---"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'    The filename you would like to write the array(s) to, can contain"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'    a full or relative path."</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'  --- autoDel% ---"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'    Shows whether you want the auto cleanup (see description above) at"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'    the program end or not (-1 = delete file, 0 = don't delete file)."</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'----------"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"' RESULT:"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'  --- realFile$ ---"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'    - On success this is the full qualified path and filename finally"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'      used after all applied checks, use only this returned filename"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'      to access the written file."</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'    - On failure (write/access) this will be an empty string, so you"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'      should check for this before trying to access/open the file."</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'---------------------------------------------------------------------"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"FUNCTION Write"</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Array$ (file$, clean%)"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'--- declare C/C++ function ---"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"DECLARE LIBRARY "</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); tarPath$; tar$; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>" 'Do not add .h here !!"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    FUNCTION Write"</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Data$ (FileName$, BYVAL AutoClean%)"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"END DECLARE"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'--- option _explicit requirements ---"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"DIM po%, body$, ext$, num%"</nowiki>|#FFB100}};
{{Cl|BlankPage|IF}} packed% {{Cl|BlankPage|THEN}} {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>", real$, ff%, rawdata$, filedata$"</nowiki>|#FFB100}}: {{Cl|BlankPage|ELSE}} {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>""</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'--- separate filename body & extension ---"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"FOR po% = LEN(file$) TO 1 STEP -1"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    IF MID$(file$, po%, 1) = "</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>"."</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>" THEN"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"        body$ = LEFT$(file$, po% - 1)"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"        ext$ = MID$(file$, po%)"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"        EXIT FOR"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    ELSEIF MID$(file$, po%, 1) = "</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>"\"</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>" OR MID$(file$, po%, 1) = "</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>"/"</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>" OR po% = 1 THEN"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"        body$ = file$"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"        ext$ = "</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}})
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"        EXIT FOR"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    END IF"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"NEXT po%"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'--- avoid overwriting of existing files ---"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"num% = 1"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"WHILE _FILEEXISTS(file$)"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    file$ = body$ + "</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>"("</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>" + LTRIM$(STR$(num%)) + "</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>")"</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>" + ext$"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    num% = num% + 1"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"WEND"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"'--- write array & set result ---"</nowiki>|#FFB100}}
{{Cl|BlankPage|IF}} {{Cl|BlankPage|NOT}} packed% {{Cl|BlankPage|THEN}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"Write"</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Array$ = Write"</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Data$(file$ + CHR$(0), clean%)"</nowiki>|#FFB100}}
{{Cl|BlankPage|ELSE}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"real$ = Write"</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Data$(file$ + CHR$(0), clean%)"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"IF real$ <> "</nowiki>|#FFB100}}; {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Cl|BlankPage|CHR$}}({{Text|34|#F580B1}}); {{Text|<nowiki>" THEN"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    ff% = FREEFILE"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    OPEN real$ FOR BINARY AS ff%"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    rawdata$ = SPACE$(LOF(ff%))"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    GET #ff%, , rawdata$"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    filedata$ = LzwUnpack$(rawdata$)"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    PUT #ff%, 1, filedata$"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"    CLOSE ff%"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"END IF"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"Write"</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Array$ = real$"</nowiki>|#FFB100}}
{{Cl|BlankPage|END}} {{Cl|BlankPage|IF}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>"END FUNCTION"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} #2, {{Text|<nowiki>""</nowiki>|#FFB100}}
{{Text|<nowiki>'--- ending ---</nowiki>|#919191}}
{{Cl|BlankPage|CLOSE}} #2
{{Text|<nowiki>'--- finish message ---</nowiki>|#919191}}
{{Cl|BlankPage|COLOR}} {{Text|10|#F580B1}}: {{Cl|BlankPage|PRINT}}: {{Cl|BlankPage|PRINT}} {{Text|<nowiki>"file successfully processed..."</nowiki>|#FFB100}}
{{Cl|BlankPage|COLOR}} {{Text|9|#F580B1}}: {{Cl|BlankPage|PRINT}}: {{Cl|BlankPage|PRINT}} {{Text|<nowiki>"You must $INCLUDE the created file (target name + .bm extension) at"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} {{Text|<nowiki>"the end of your program and call the function 'Write"</nowiki>|#FFB100}}; tarName$; {{Text|<nowiki>"Array$(...)'"</nowiki>|#FFB100}}
{{Cl|BlankPage|PRINT}} {{Text|<nowiki>"in an appropriate place to write the file back to disk."</nowiki>|#FFB100}}
{{Cl|BlankPage|IF}} packed% {{Cl|BlankPage|THEN}}
    {{Cl|BlankPage|COLOR}} {{Text|12|#F580B1}}: {{Cl|BlankPage|PRINT}}: {{Cl|BlankPage|PRINT}} {{Text|<nowiki>"Your program must also $INCLUDE 'lzwpacker.bm' available from"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} {{Text|<nowiki>"the Libraries Collection here:"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} {{Text|<nowiki>"    http://qb64phoenix.com/forum/forumdisplay.php?fid=23"</nowiki>|#FFB100}}
    {{Cl|BlankPage|PRINT}} {{Text|<nowiki>"to be able to write back the just processed file."</nowiki>|#FFB100}}
    {{Cl|BlankPage|KILL}} tarPath$ + tar$ + {{Text|<nowiki>".lzw"</nowiki>|#FFB100}}
{{Cl|BlankPage|END}} {{Cl|BlankPage|IF}}
done:
{{Cl|BlankPage|COLOR}} {{Text|7|#F580B1}}
{{Cl|BlankPage|END}}
{{Text|<nowiki>'--- error handler ---</nowiki>|#919191}}
abort:
{{Cl|BlankPage|COLOR}} {{Text|12|#F580B1}}: {{Cl|BlankPage|PRINT}}: {{Cl|BlankPage|PRINT}} {{Text|<nowiki>"something is wrong with path/file access, check your inputs and try again..."</nowiki>|#FFB100}}
{{Cl|BlankPage|RESUME}} done
{{Text|<nowiki>'</nowiki>|#919191}}{{Cm|BlankPage|$INCLUDE}}: {{Text|<nowiki>'QB64Library\LZW-Compress\lzwpacker.bm'</nowiki>|#919191}}
{{CodeEnd}}

Latest revision as of 00:11, 24 August 2024

The _BlankPage serves as a skeleton for new Wiki pages.


Syntax

_BlankSub arg1[, arg2]
result% = _BlankFunc(arg1[, arg2])


Parameters

  • arg1 is a mandatory argument
  • the arg2 is optional


Description

To use this skeleton click on the Edit tab above the page, then copy the raw text of this page and paste it into your new page. Change/remove sections as needed. Use this for italic and this for bold text style. To color your writings use the Text template. It takes either a color name or a #RRGGBB 32bit color, if the color part is omitted it will default to gray.

You can inline simple code one liners like w = _WIDTH

  • an askerisk marks a list point
    • two askerisks will indent the list
      • three askerisks will indent even more
This is a definition list
The first description can follow right after a colon
or in a new line
more descriptions can follow
  • using list bullets with an askerisk
as already seen in the syntax above, you may use desciptions without a defininition too
you may also nest descriptions
but at some point it's cluttering the page so please use it sparingly
This is a nice piece of paper for quotes and similar things. In case of short code snippets you may use the "Cb" (code blue) template to highlight and link keywords to the Wiki pages.

FOR x = 1 TO 5
   PRINT "Hello World!"
NEXT x
END

As you see, this Text block is suitable for preformatted text, but note that the browser is still allowed to wrap too long lines. If you really need your preformatted text to be shown as is, then use a fixed text block instaed, see below.
Use this fixed text block for preformatted text, which is not even allowed to wrap long lines, such as tables etc..
As you see this very long line goes far over the display width, so please limit youself to the available space to not clutter the display too much.

Notes

  • This may be a sub-section for further notes like special behavior, required prerequisites etc.
  • If used/required, then this should always be a sub-section under the Description main section

Errors

  • If used/required, then this also should be a sub-section under the Description main section
  • This is not intended for the regular errors a SUB/FUNCTION could throw, those should be handled in the main description section.
    • Rather use it for subtle things, known mis-behavior, tendency for stack overflows and seg faults etc.


Availability

  • The capability to load from memory was introduced in QB64-PE v3.5.0.


Examples

Example 1
Each example should have a short description.
'Place your code example here
'The "Cl" (code link) template can be used to link keywords to its
'respective Wiki page. Those words will also get highlighted.
COLOR 15,4
PRINT "Hello World!"
This template allows for a short author credit.
Note: To avoid the annoying task of manually inserting the templates
in your code examples, since v3.7.0 you may simply write your example
in the IDE and later use the menu "File > Export As > Wiki example" to
export a completely prepared code block, which you can paste "as is"
into the Wiki page.

Oh, and by the way, this preformatted text block is also new. Generally
it's the same as a fixed text block shown above, but it uses horizontal
scrollers instead of stretching the text box and it has a more plain
appearance. If you want avoid the horizontal scroller, then restrict
yourself to a line length of max. 72 characters.
The output block is available for the SCREEN 0 background colors 0-7
Inside the output block use the "Ot" (output text) template for coloring
Hello World!


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link