From a281a46ea26f820754efff85e30607239951cdb5 Mon Sep 17 00:00:00 2001 From: coderJeff Date: Wed, 22 May 2019 22:43:43 -0400 Subject: [PATCH 1/5] fbdoc: remove extra code --- doc/fbchkdoc/cmd_opts.bas | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/fbchkdoc/cmd_opts.bas b/doc/fbchkdoc/cmd_opts.bas index 5885eda271..349c2ec088 100644 --- a/doc/fbchkdoc/cmd_opts.bas +++ b/doc/fbchkdoc/cmd_opts.bas @@ -180,8 +180,6 @@ sub cmd_opts_init( byval opts_flags as const CMD_OPTS_ENABLE_FLAGS ) cmd_opt.manual = false '' -manual_dir given on command line cmd_opt.manual_dir = "" '' value of '-manual_dir DIR' given on command line - cmd_opt.db_user_is_set = false - '' resolved options app_opt.wiki_url = "" '' export: resolved wiki url From ac031c47bdc679901f2b7a1346bc4d7c5f8c14f9 Mon Sep 17 00:00:00 2001 From: coderJeff Date: Sat, 13 Jul 2019 11:42:29 -0400 Subject: [PATCH 2/5] fbdoc: putpage may fail if new page - wikicon->LoadPage() may fail if page is new - Use wikicon->GetPageID() to determine if attempt should be made to store new page --- doc/fbchkdoc/putpage.bas | 75 ++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/doc/fbchkdoc/putpage.bas b/doc/fbchkdoc/putpage.bas index b49a598e99..e8098e8b96 100644 --- a/doc/fbchkdoc/putpage.bas +++ b/doc/fbchkdoc/putpage.bas @@ -138,53 +138,54 @@ if( app_opt.pageCount > 0 ) then print "Unable to load" else print "OK" - if( wikicon->LoadPage( sPage, sBodyOld ) <> FALSE ) then - if( wikicon->GetPageID() > 0 ) then - if( wikicon->Login( app_opt.wiki_username, app_opt.wiki_password ) ) = FALSE then - print "Unable to login" + + '' wikicon->LoadPage() may return FALSE if the page does not + '' yet exist. Test the page ID instead to determine if it + '' is a new page + wikicon->LoadPage( sPage, sBodyOld ) + if( wikicon->GetPageID() > 0 ) then + if( wikicon->Login( app_opt.wiki_username, app_opt.wiki_password ) ) = FALSE then + print "Unable to login" + else + if( iComment > 0 ) then + if( iComment = 1 or sNoteDef = "" ) then + print "Enter note for '" + sPage + "' : "; + Line input sNote + if trim(sNote) = "" then sNote = "Auto-Update" + sNoteDef = sNote + else + sNote = sNoteDef + end if else - if( iComment > 0 ) then - if( iComment = 1 or sNoteDef = "" ) then - print "Enter note for '" + sPage + "' : "; - Line input sNote - if trim(sNote) = "" then sNote = "Auto-Update" - sNoteDef = sNote - else - sNote = sNoteDef - end if + if( sComment > "" ) then + sNote = sComment + elseif( sNoteDef > "" ) then + sNote = sNoteDef else - if( sComment > "" ) then - sNote = sComment - elseif( sNoteDef > "" ) then - sNote = sNoteDef - else - sNote = "" - end if + sNote = "" end if + end if - print "Storing '" + sPage + "' [" + sNote + "] : "; + print "Storing '" + sPage + "' [" + sNote + "] : "; - if( wikicon->StorePage( sBody, sNote ) = FALSE ) then - print "FAILED" - else - print "OK" - end if + if( wikicon->StorePage( sBody, sNote ) = FALSE ) then + print "FAILED" + else + print "OK" end if + end if + else + print "Unable to get existing page ID - will try to store as a new page .." + if( wikicon->Login( app_opt.wiki_username, app_opt.wiki_password ) ) = FALSE then + print "Unable to login" else - print "Unable to get existing page ID - will try to store as a new page .." - if( wikicon->Login( app_opt.wiki_username, app_opt.wiki_password ) ) = FALSE then - print "Unable to login" + print "Storing '" + sPage + "': "; + if( wikicon->StoreNewPage( sBody, sPage ) = FALSE ) then + print "FAILED" else - print "Storing '" + sPage + "': "; - if( wikicon->StoreNewPage( sBody, sPage ) = FALSE ) then - print "FAILED" - else - print "OK" - end if + print "OK" end if end if - else - print "Unable to existing page" end if end if next From 2383e2663f5f5c533a9049e16d839b22a4e51202 Mon Sep 17 00:00:00 2001 From: coderJeff Date: Thu, 11 Jul 2019 11:43:35 -0400 Subject: [PATCH 3/5] fbdoc: wiki snapshot 2019-07-11 --- doc/manual/cache/CatPgConsole.wakka | 4 +- doc/manual/cache/CatPgFile.wakka | 2 +- doc/manual/cache/CatPgFullIndex.wakka | 22 +-- doc/manual/cache/CatPgFunctIndex.wakka | 12 +- doc/manual/cache/CatPgStdDataTypes.wakka | 2 +- doc/manual/cache/CatPgUserDefTypes.wakka | 4 + doc/manual/cache/FBWikiFormatting.wakka | 4 + doc/manual/cache/GlossaryIndex.wakka | 2 + doc/manual/cache/KeyPgAbstract.wakka | 2 + doc/manual/cache/KeyPgAllocate.wakka | 1 + doc/manual/cache/KeyPgAny.wakka | 4 +- doc/manual/cache/KeyPgBase.wakka | 2 + doc/manual/cache/KeyPgBaseInit.wakka | 2 + doc/manual/cache/KeyPgCallocate.wakka | 4 +- doc/manual/cache/KeyPgCast.wakka | 2 +- doc/manual/cache/KeyPgClear.wakka | 2 +- doc/manual/cache/KeyPgCommon.wakka | 4 +- doc/manual/cache/KeyPgCptr.wakka | 2 +- doc/manual/cache/KeyPgCustomgfx.wakka | 2 +- doc/manual/cache/KeyPgDim.wakka | 9 +- doc/manual/cache/KeyPgDrawString.wakka | 2 +- doc/manual/cache/KeyPgDylibfree.wakka | 2 +- doc/manual/cache/KeyPgDylibload.wakka | 4 +- doc/manual/cache/KeyPgErase.wakka | 2 + doc/manual/cache/KeyPgExtends.wakka | 2 + doc/manual/cache/KeyPgExtendsWstring.wakka | 35 +++++ doc/manual/cache/KeyPgExtendsZstring.wakka | 134 ++++++++++++++++++ doc/manual/cache/KeyPgImplements.wakka | 2 + doc/manual/cache/KeyPgInputnum.wakka | 5 +- doc/manual/cache/KeyPgObject.wakka | 2 + doc/manual/cache/KeyPgOpAdd.wakka | 6 +- doc/manual/cache/KeyPgOpAt.wakka | 2 +- doc/manual/cache/KeyPgOpCombineAdd.wakka | 2 +- doc/manual/cache/KeyPgOpCombineSub.wakka | 2 +- doc/manual/cache/KeyPgOpIs.wakka | 2 + doc/manual/cache/KeyPgOpLetlist.wakka | 34 +++++ doc/manual/cache/KeyPgOpPtrIndex.wakka | 7 +- doc/manual/cache/KeyPgOpSubtract.wakka | 8 +- doc/manual/cache/KeyPgOpValueOf.wakka | 7 +- doc/manual/cache/KeyPgPointer.wakka | 33 ----- doc/manual/cache/KeyPgPtr.wakka | 21 ++- doc/manual/cache/KeyPgString.wakka | 3 +- doc/manual/cache/KeyPgType.wakka | 4 +- doc/manual/cache/KeyPgTypeof.wakka | 1 - doc/manual/cache/KeyPgVirtual.wakka | 2 + doc/manual/cache/KeyPgWstring.wakka | 5 + doc/manual/cache/KeyPgZstring.wakka | 5 +- doc/manual/cache/PrintToc.wakka | 12 +- doc/manual/cache/ProPgLiterals.wakka | 8 +- doc/manual/cache/ProPgPointers.wakka | 2 +- doc/manual/cache/ProPgProcedurePointers.wakka | 2 +- doc/manual/cache/ProPgPtrArithmetic.wakka | 2 +- doc/manual/cache/TutPointersData.wakka | 2 +- 53 files changed, 345 insertions(+), 105 deletions(-) create mode 100644 doc/manual/cache/KeyPgExtendsWstring.wakka create mode 100644 doc/manual/cache/KeyPgExtendsZstring.wakka delete mode 100644 doc/manual/cache/KeyPgPointer.wakka diff --git a/doc/manual/cache/CatPgConsole.wakka b/doc/manual/cache/CatPgConsole.wakka index 32ea59c8d4..b0c84be9b2 100644 --- a/doc/manual/cache/CatPgConsole.wakka +++ b/doc/manual/cache/CatPgConsole.wakka @@ -32,10 +32,10 @@ Procedures that work with the console. Gets the character or color attribute at a given location. <<>>{{anchor name="WRITING"}}{{fbdoc item="section" value="Writing Text to the Console"}} =={{fbdoc item="keyword" value="KeyPgPrint|PRINT"}}== - =={{fbdoc item="keyword" value="KeyPgPrint|?"}}== + =={{fbdoc item="keyword" value="KeyPgPrint|? (Shortcut for 'PRINT')"}}== Writes text to the console. =={{fbdoc item="keyword" value="KeyPgPrintusing|PRINT USING"}}== - =={{fbdoc item="keyword" value="KeyPgPrintusing|? USING"}}== + =={{fbdoc item="keyword" value="KeyPgPrintusing|? USING (Shortcut for 'PRINT USING')"}}== Writes formatted text to the console. =={{fbdoc item="keyword" value="KeyPgWrite|WRITE"}}== Writes a list of items to the console. diff --git a/doc/manual/cache/CatPgFile.wakka b/doc/manual/cache/CatPgFile.wakka index 58faa53530..b150defa80 100644 --- a/doc/manual/cache/CatPgFile.wakka +++ b/doc/manual/cache/CatPgFile.wakka @@ -70,7 +70,7 @@ Statements and procedures for working with files and devices. =={{fbdoc item="keyword" value="KeyPgLineinputPp|LINE INPUT #"}}== Reads a line of text from a file or device. =={{fbdoc item="keyword" value="KeyPgPrintPp|PRINT #"}}== - =={{fbdoc item="keyword" value="KeyPgPrintPp|? #"}}== + =={{fbdoc item="keyword" value="KeyPgPrintPp|? # (Shortcut for 'PRINT #')"}}== Writes text data to a file or device. =={{fbdoc item="keyword" value="KeyPgPutfileio|PUT #"}}== Writes arbitrary data to a file or device. diff --git a/doc/manual/cache/CatPgFullIndex.wakka b/doc/manual/cache/CatPgFullIndex.wakka index 8080f3148a..3df79665ae 100644 --- a/doc/manual/cache/CatPgFullIndex.wakka +++ b/doc/manual/cache/CatPgFullIndex.wakka @@ -1,10 +1,10 @@ {{fbdoc item="title" value="Alphabetical Keywords List"}}---- Alphabetical listing of keywords, macros and procedures. -[[CatPgOpIndex|Operators]] ##{{anchor name="dot|."}} {{anchor name="underscore|_"}} {{anchor name="hash|#"}} {{anchor name="dollar|$"}} {{anchor name="a|A"}} {{anchor name="b|B"}} {{anchor name="c|C"}} {{anchor name="d|D"}} {{anchor name="e|E"}} {{anchor name="f|F"}} {{anchor name="g|G"}} {{anchor name="h|H"}} {{anchor name="i|I"}} {{anchor name="k|K"}} {{anchor name="l|L"}} {{anchor name="m|M"}} {{anchor name="n|N"}} {{anchor name="o|O"}} {{anchor name="p|P"}} {{anchor name="r|R"}} {{anchor name="s|S"}} {{anchor name="t|T"}} {{anchor name="u|U"}} {{anchor name="v|V"}} {{anchor name="w|W"}} {{anchor name="x|X"}} {{anchor name="y|Y"}} {{anchor name="z|Z"}}## +##{{anchor name="op|Operators"}} {{anchor name="dot|."}} {{anchor name="underscore|_"}} {{anchor name="hash|#"}} {{anchor name="dollar|$"}} {{anchor name="query|?"}} {{anchor name="a|A"}} {{anchor name="b|B"}} {{anchor name="c|C"}} {{anchor name="d|D"}} {{anchor name="e|E"}} {{anchor name="f|F"}} {{anchor name="g|G"}} {{anchor name="h|H"}} {{anchor name="i|I"}} {{anchor name="k|K"}} {{anchor name="l|L"}} {{anchor name="m|M"}} {{anchor name="n|N"}} {{anchor name="o|O"}} {{anchor name="p|P"}} {{anchor name="r|R"}} {{anchor name="s|S"}} {{anchor name="t|T"}} {{anchor name="u|U"}} {{anchor name="v|V"}} {{anchor name="w|W"}} {{anchor name="x|X"}} {{anchor name="y|Y"}} {{anchor name="z|Z"}}## {{fbdoc item="back" value="DocToc|Table of Contents"}} -<<{{fbdoc item="section" value="Operators"}} +<<{{fbdoc item="section" value="Operators"}}{{anchor name="op"}} - [[CatPgOpIndex|See Operator List]] {{fbdoc item="section" value="."}}{{anchor name="dot"}} @@ -94,6 +94,11 @@ Alphabetical listing of keywords, macros and procedures. - {{fbdoc item="keyword" value="KeyPgMetaLang|$LANG"}} - {{fbdoc item="keyword" value="KeyPgMetaStatic|$STATIC"}} +{{fbdoc item="section" value="?"}}{{anchor name="query"}} + - {{fbdoc item="keyword" value="KeyPgPrint|? (Shortcut for 'PRINT')"}} + - {{fbdoc item="keyword" value="KeyPgPrintPp|? # (Shortcut for 'PRINT #')"}} + - {{fbdoc item="keyword" value="KeyPgPrintusing|? USING (Shortcut for 'PRINT USING')"}} + {{fbdoc item="section" value="A"}}{{anchor name="a"}} - {{fbdoc item="keyword" value="KeyPgAbs|ABS"}} - {{fbdoc item="keyword" value="KeyPgAbstract|ABSTRACT (member)"}} @@ -259,6 +264,8 @@ Alphabetical listing of keywords, macros and procedures. - {{fbdoc item="keyword" value="KeyPgExp|EXP"}} - {{fbdoc item="keyword" value="KeyPgExport|EXPORT"}} - {{fbdoc item="keyword" value="KeyPgExtends|EXTENDS"}} + - {{fbdoc item="keyword" value="KeyPgExtendsWstring|EXTENDS WSTRING"}} + - {{fbdoc item="keyword" value="KeyPgExtendsZstring|EXTENDS ZSTRING"}} - {{fbdoc item="keyword" value="KeyPgExtern|EXTERN"}} - {{fbdoc item="keyword" value="KeyPgExternBlock|EXTERN...END EXTERN"}} @@ -297,7 +304,7 @@ Alphabetical listing of keywords, macros and procedures. - {{fbdoc item="keyword" value="KeyPgHiword|HIWORD"}} - {{fbdoc item="keyword" value="KeyPgHour|HOUR"}} -{{fbdoc item="section" value="I"}}{{anchor name="i"}} +<<>>{{fbdoc item="section" value="I"}}{{anchor name="i"}} - {{fbdoc item="keyword" value="KeyPgIfthen|IF...THEN"}} - {{fbdoc item="keyword" value="KeyPgIif|IIF"}} - {{fbdoc item="keyword" value="KeyPgImageConvertRow|IMAGECONVERTROW"}} @@ -322,7 +329,7 @@ Alphabetical listing of keywords, macros and procedures. - {{fbdoc item="keyword" value="KeyPgIsDate|ISDATE"}} - {{fbdoc item="keyword" value="KeyPgIsredirected|ISREDIRECTED"}} -<<>>{{fbdoc item="section" value="K"}}{{anchor name="k"}} +{{fbdoc item="section" value="K"}}{{anchor name="k"}} - {{fbdoc item="keyword" value="KeyPgKill|KILL"}} {{fbdoc item="section" value="L"}}{{anchor name="l"}} @@ -426,17 +433,14 @@ Alphabetical listing of keywords, macros and procedures. - {{fbdoc item="keyword" value="KeyPgPmap|PMAP"}} - {{fbdoc item="keyword" value="KeyPgPoint|POINT"}} - {{fbdoc item="keyword" value="KeyPgPointCoord|POINTCOORD"}} - - {{fbdoc item="keyword" value="KeyPgPointer|POINTER"}} + - {{fbdoc item="keyword" value="KeyPgPtr|POINTER"}} - {{fbdoc item="keyword" value="KeyPgPoke|POKE"}} - {{fbdoc item="keyword" value="KeyPgPos|POS"}} - {{fbdoc item="keyword" value="KeyPgPreserve|PRESERVE"}} - {{fbdoc item="keyword" value="KeyPgPreset|PRESET"}} - {{fbdoc item="keyword" value="KeyPgPrint|PRINT"}} - - {{fbdoc item="keyword" value="KeyPgPrint|?"}} - {{fbdoc item="keyword" value="KeyPgPrintPp|PRINT #"}} - - {{fbdoc item="keyword" value="KeyPgPrintPp|? #"}} - {{fbdoc item="keyword" value="KeyPgPrintusing|PRINT USING"}} - - {{fbdoc item="keyword" value="KeyPgPrintusing|? USING"}} - {{fbdoc item="keyword" value="KeyPgPrivate|PRIVATE"}} - {{fbdoc item="keyword" value="KeyPgVisPrivate|PRIVATE: (Access Control)"}} - {{fbdoc item="keyword" value="KeyPgOpProcptr|PROCPTR"}} @@ -444,7 +448,7 @@ Alphabetical listing of keywords, macros and procedures. - {{fbdoc item="keyword" value="KeyPgVisProtected|PROTECTED: (Access Control)"}} - {{fbdoc item="keyword" value="KeyPgPset|PSET (Statement)"}} - {{fbdoc item="keyword" value="KeyPgPsetGfx|PSET (Graphics PUT)"}} - - {{fbdoc item="keyword" value="KeyPgPtr|PTR"}} + - {{fbdoc item="keyword" value="KeyPgPtr|PTR (Shortcut for 'POINTER')"}} - {{fbdoc item="keyword" value="KeyPgPublic|PUBLIC"}} - {{fbdoc item="keyword" value="KeyPgVisPublic|PUBLIC: (Access Control)"}} - {{fbdoc item="keyword" value="KeyPgPutgraphics|PUT (Graphics)"}} diff --git a/doc/manual/cache/CatPgFunctIndex.wakka b/doc/manual/cache/CatPgFunctIndex.wakka index a3c11a9ad3..5e2bb983b1 100644 --- a/doc/manual/cache/CatPgFunctIndex.wakka +++ b/doc/manual/cache/CatPgFunctIndex.wakka @@ -42,6 +42,8 @@ List of ""FreeBASIC"" keywords sorted by the function they perform. - {{fbdoc item="keyword" value="KeyPgOptionstatic|OPTION STATIC"}} {{fbdoc item="section" value="Console"}} + - {{fbdoc item="keyword" value="KeyPgPrint|? (Shortcut for 'PRINT')"}} + - {{fbdoc item="keyword" value="KeyPgPrintusing|? USING (Shortcut for 'PRINT USING')"}} - {{fbdoc item="keyword" value="KeyPgBeep|BEEP"}} - {{fbdoc item="keyword" value="KeyPgCls|CLS"}} - {{fbdoc item="keyword" value="KeyPgColor|COLOR"}} @@ -53,9 +55,7 @@ List of ""FreeBASIC"" keywords sorted by the function they perform. - {{fbdoc item="keyword" value="KeyPgOpenScrn|OPEN SCRN"}} - {{fbdoc item="keyword" value="KeyPgPos|POS"}} - {{fbdoc item="keyword" value="KeyPgPrint|PRINT"}} - - {{fbdoc item="keyword" value="KeyPgPrint|?"}} - {{fbdoc item="keyword" value="KeyPgPrintusing|PRINT USING"}} - - {{fbdoc item="keyword" value="KeyPgPrintusing|? USING"}} - {{fbdoc item="keyword" value="KeyPgScreenCons|SCREEN (Console)"}} - {{fbdoc item="keyword" value="KeyPgSpc|SPC"}} - {{fbdoc item="keyword" value="KeyPgTab|TAB"}} @@ -75,6 +75,8 @@ List of ""FreeBASIC"" keywords sorted by the function they perform. - {{fbdoc item="keyword" value="KeyPgDouble|DOUBLE"}} - {{fbdoc item="keyword" value="KeyPgEnum|ENUM"}} - {{fbdoc item="keyword" value="KeyPgExtends|EXTENDS"}} + - {{fbdoc item="keyword" value="KeyPgExtendsWstring|EXTENDS WSTRING"}} + - {{fbdoc item="keyword" value="KeyPgExtendsZstring|EXTENDS ZSTRING"}} - {{fbdoc item="keyword" value="KeyPgFunctionPtr|FUNCTION (Pointer)"}} - {{fbdoc item="keyword" value="KeyPgImplements|IMPLEMENTS"}} - {{fbdoc item="keyword" value="KeyPgInteger|INTEGER"}} @@ -145,6 +147,7 @@ List of ""FreeBASIC"" keywords sorted by the function they perform. - {{fbdoc item="keyword" value="KeyPgResumenext|RESUME NEXT"}} {{fbdoc item="section" value="Files"}} + - {{fbdoc item="keyword" value="KeyPgPrintPp|? # (Shortcut for 'Print #')"}} - {{fbdoc item="keyword" value="KeyPgAccess|ACCESS"}} - {{fbdoc item="keyword" value="KeyPgAppend|APPEND"}} - {{fbdoc item="keyword" value="KeyPgBinary|BINARY"}} @@ -164,7 +167,6 @@ List of ""FreeBASIC"" keywords sorted by the function they perform. - {{fbdoc item="keyword" value="KeyPgOpen|OPEN"}} - {{fbdoc item="keyword" value="KeyPgOutput|OUTPUT"}} - {{fbdoc item="keyword" value="KeyPgPrintPp|PRINT #"}} - - {{fbdoc item="keyword" value="KeyPgPrintPp|? #"}} - {{fbdoc item="keyword" value="KeyPgPutfileio|PUT # (File I/O)"}} - {{fbdoc item="keyword" value="KeyPgRandom|RANDOM"}} - {{fbdoc item="keyword" value="KeyPgReadFile|READ (File Access)"}} @@ -385,9 +387,9 @@ List of ""FreeBASIC"" keywords sorted by the function they perform. - {{fbdoc item="keyword" value="KeyPgWindowtitle|WINDOWTITLE"}} {{fbdoc item="section" value="Pointers"}} - - {{fbdoc item="keyword" value="KeyPgPointer|POINTER"}} + - {{fbdoc item="keyword" value="KeyPgPtr|POINTER"}} - {{fbdoc item="keyword" value="KeyPgOpProcptr|PROCPTR"}} - - {{fbdoc item="keyword" value="KeyPgPtr|PTR"}} + - {{fbdoc item="keyword" value="KeyPgPtr|PTR (Shortcut for 'POINTER')"}} - {{fbdoc item="keyword" value="KeyPgSadd|SADD"}} - {{fbdoc item="keyword" value="KeyPgOpStrptr|STRPTR"}} - {{fbdoc item="keyword" value="KeyPgOpVarptr|VARPTR"}} diff --git a/doc/manual/cache/CatPgStdDataTypes.wakka b/doc/manual/cache/CatPgStdDataTypes.wakka index a021ac6ade..9264559a82 100644 --- a/doc/manual/cache/CatPgStdDataTypes.wakka +++ b/doc/manual/cache/CatPgStdDataTypes.wakka @@ -46,7 +46,7 @@ Built-in data types <<>>{{anchor name="MODIFIERS"}}{{fbdoc item="section" value="Data Type Modifiers"}} =={{fbdoc item="keyword" value="KeyPgConstQualifier|CONST"}}== Specifies a read only type. - =={{fbdoc item="keyword" value="KeyPgPointer|POINTER"}} and {{fbdoc item="keyword" value="KeyPgPtr|PTR"}}== + =={{fbdoc item="keyword" value="KeyPgPtr|POINTER"}} and {{fbdoc item="keyword" value="KeyPgPtr|PTR (Shortcut for 'POINTER')"}}== Modifies types to be pointer types. =={{fbdoc item="keyword" value="KeyPgUnsigned|UNSIGNED"}}== Specifies an unsigned integer type. diff --git a/doc/manual/cache/CatPgUserDefTypes.wakka b/doc/manual/cache/CatPgUserDefTypes.wakka index f8450137c8..7a3f576361 100644 --- a/doc/manual/cache/CatPgUserDefTypes.wakka +++ b/doc/manual/cache/CatPgUserDefTypes.wakka @@ -20,6 +20,10 @@ User defined structure of overlapping data =={{fbdoc item="keyword" value="KeyPgExtends|EXTENDS"}}== Extends an user defined type to derive another + =={{fbdoc item="keyword" value="KeyPgExtendsWstring|EXTENDS WSTRING"}}== + Extends an user defined type to inherits Wstring behavior + =={{fbdoc item="keyword" value="KeyPgExtendsZstring|EXTENDS ZSTRING"}}== + Extends an user defined type to inherits Zstring behavior =={{fbdoc item="keyword" value="KeyPgImplements|IMPLEMENTS"}}== Not implemented. Keyword reserved. =={{fbdoc item="keyword" value="KeyPgField|FIELD"}}== diff --git a/doc/manual/cache/FBWikiFormatting.wakka b/doc/manual/cache/FBWikiFormatting.wakka index 89e1f2a38b..77ab7b536f 100644 --- a/doc/manual/cache/FBWikiFormatting.wakka +++ b/doc/manual/cache/FBWikiFormatting.wakka @@ -111,6 +111,10 @@ In all of the examples following, the markup line with the formatting codes is f Then link to that anchor with: ##""{{anchor name="item1|Jump to Item #1"}}""## {{anchor name="item1|Jump to Item #1"}} + + **Note about adding a new anchor:** + - Don't pretest the new anchor link through the "Preview" mode, otherwise that cancels all changes in progress done with "Edit" (check only the added text associated with the new anchor). + - But execute "Store" to first save the adding in progress and quit the "Edit" mode, and only then, we can test in "operational" the functioning of the new link. {{fbdoc item="section" value="Tables"}} The ""{{table}}"" action is recognized by the document generators, using the following format. diff --git a/doc/manual/cache/GlossaryIndex.wakka b/doc/manual/cache/GlossaryIndex.wakka index b5a3b69382..ca1da614c2 100644 --- a/doc/manual/cache/GlossaryIndex.wakka +++ b/doc/manual/cache/GlossaryIndex.wakka @@ -434,6 +434,8 @@ Brief definitions and explanations for words and phrases used in the ""FreeBASIC **static variable/object/array** A variable, object or array with **static storage**. + **Note:** Some times, we talk about 'static array/string' (as opposed to 'dynamic array/string'), but here, the 'static' term applies on the size of the array/string (fixed length as opposed to 'dynamic' term for a variable length) . + Thus this 'static/dynamic' term does not apply on the storage type for data. **sub** A procedure defined using ##[[KeyPgSub|Sub]]##, optionally taking parameters and not returning a value. diff --git a/doc/manual/cache/KeyPgAbstract.wakka b/doc/manual/cache/KeyPgAbstract.wakka index b1a9583b9f..047571a0b0 100644 --- a/doc/manual/cache/KeyPgAbstract.wakka +++ b/doc/manual/cache/KeyPgAbstract.wakka @@ -80,6 +80,8 @@ end sub - ##[[KeyPgVirtual|Virtual]]## - ##[[KeyPgType|Type]]## - ##[[KeyPgExtends|Extends]]## + - ##[[KeyPgExtendsZstring|Extends Zstring]]## + - ##[[KeyPgExtendsWstring|Extends Wstring]]## - ##[[KeyPgObject|Object]]## - ##[[KeyPgOverride|Override]]## diff --git a/doc/manual/cache/KeyPgAllocate.wakka b/doc/manual/cache/KeyPgAllocate.wakka index ac25a94ef4..3cadf74922 100644 --- a/doc/manual/cache/KeyPgAllocate.wakka +++ b/doc/manual/cache/KeyPgAllocate.wakka @@ -18,6 +18,7 @@ Allocates a block of memory from the free store Attempts to allocate, or reserve, ##//count//## number of bytes from the free store (heap). The newly allocated memory is not initialized. As the initial value of newly allocated memory is unspecified, **Allocate** must not be directly used with ##[[KeyPgString|String]]## or ##[[KeyPgType|UDT]]## containing string, because the string descriptor being not cleared (containing random data), that may induce corrupted string or more (trying to write to a random place in memory or trying to deallocate a random pointer). It is mandatory in that case (with string or UDT containing string) to use ##[[KeyPgCallocate|Callocate]]## (clearing memory), or ##[[KeyPgOpNew|New Expression]]## (calling constructor) in case of **UDT**, or at worst after **Allocate** to explicitly clear the descriptor (setting to 0) before the first string use. + For allocating memory for a ##[[KeyPgZstring|Zstring]]## or a ##[[KeyPgWstring|Wstring]]##, see the corresponding page. The pointer that is returned is an [[KeyPgAny|any]] [[KeyPgPtr|ptr]] and points to the start of the allocated memory. This pointer is guaranteed to be unique, even if ##//count//## is zero. diff --git a/doc/manual/cache/KeyPgAny.wakka b/doc/manual/cache/KeyPgAny.wakka index d2a0660d41..893b9f3150 100644 --- a/doc/manual/cache/KeyPgAny.wakka +++ b/doc/manual/cache/KeyPgAny.wakka @@ -2,7 +2,7 @@ The ##**Any**## keyword is used as a placeholder for a type or value in various ways. {{fbdoc item="syntax"}}## - [[KeyPgDim|Dim]] //identifier// [[KeyPgAs|As]] **Any** [[KeyPgPointer|Pointer]]|[[KeyPgPtr|Ptr]] + [[KeyPgDim|Dim]] //identifier// [[KeyPgAs|As]] **Any** [[KeyPgPtr|Pointer]]|[[KeyPgPtr|Ptr]] ##//or//## [[KeyPgDeclare|Declare]] [[KeyPgSub|Sub]]|[[KeyPgFunction|Function]] //identifier// ( [[KeyPgByref|Byref]] //identifier// [[KeyPgAs|As]] **Any** [ , ... ] ) ##//or//## @@ -20,7 +20,7 @@ The ##**Any**## keyword is used as a placeholder for a type or value in various ## {{fbdoc item="desc"}} - Pointers: - A special pointer type called the ##**Any** [[KeyPgPtr|Ptr]]## (or "##**Any** [[KeyPgPointer|Pointer]]##") allows pointing to any variable type. If you cast it to a ##//[[DataType]]// [[KeyPgPtr|Ptr]]##, it can be indexed or dereferenced to access the memory as an instance of ##//[[DataType]]//##. Pointer arithmetic is allowed on an ##**Any** Ptr##, and treats it like a ##[[KeyPgByte|Byte]] Ptr##: The pointer is changed by increments of ##1##. + A special pointer type called the ##**Any** [[KeyPgPtr|Ptr]]## (or "##**Any** [[KeyPgPtr|Pointer]]##") allows pointing to any variable type. If you cast it to a ##//[[DataType]]// [[KeyPgPtr|Ptr]]##, it can be indexed or dereferenced to access the memory as an instance of ##//[[DataType]]//##. Pointer arithmetic is allowed on an ##**Any** Ptr##, and treats it like a ##[[KeyPgByte|Byte]] Ptr##: The pointer is changed by increments of ##1##. A pure ##**Any** [[KeyPgPtr|Ptr]]## has no type checking by the compiler. It can be implicitly converted to and from other pointer types through assignment or parameter passing. diff --git a/doc/manual/cache/KeyPgBase.wakka b/doc/manual/cache/KeyPgBase.wakka index daaf101881..863293fe59 100644 --- a/doc/manual/cache/KeyPgBase.wakka +++ b/doc/manual/cache/KeyPgBase.wakka @@ -84,6 +84,8 @@ x.show() - ##[[KeyPgThis|This]]## - ##[[KeyPgType|Type]]## - ##[[KeyPgExtends|Extends]]## + - ##[[KeyPgExtendsZstring|Extends Zstring]]## + - ##[[KeyPgExtendsWstring|Extends Wstring]]## - ##[[KeyPgOptionbase|Option Base]]## {{fbdoc item="back" value="CatPgUserDefTypes|User Defined Types"}} \ No newline at end of file diff --git a/doc/manual/cache/KeyPgBaseInit.wakka b/doc/manual/cache/KeyPgBaseInit.wakka index 1ee2a4c769..a6a1a9a379 100644 --- a/doc/manual/cache/KeyPgBaseInit.wakka +++ b/doc/manual/cache/KeyPgBaseInit.wakka @@ -63,6 +63,8 @@ end constructor - ##[[KeyPgThis|This]]## - ##[[KeyPgType|Type]]## - ##[[KeyPgExtends|Extends]]## + - ##[[KeyPgExtendsZstring|Extends Zstring]]## + - ##[[KeyPgExtendsWstring|Extends Wstring]]## - ##[[KeyPgOptionbase|Option Base]]## {{fbdoc item="back" value="CatPgUserDefTypes|User Defined Types"}} \ No newline at end of file diff --git a/doc/manual/cache/KeyPgCallocate.wakka b/doc/manual/cache/KeyPgCallocate.wakka index fd5aff9055..9e8c7f8f27 100644 --- a/doc/manual/cache/KeyPgCallocate.wakka +++ b/doc/manual/cache/KeyPgCallocate.wakka @@ -17,7 +17,9 @@ Allocates memory for a certain number of elements from the free store and clears If successful, the address of the start of the allocated memory is returned. Otherwise, the null pointer (##0##) is returned. {{fbdoc item="desc"}} - ##**Callocate**## initializes the allocated memory with zeros. Consequently, ##**Callocate**## can be also directly used with ##[[KeyPgString|String]]## or ##[[KeyPgType|UDT]]## containing string, because the string descriptor is cleared (set to 0) first. + ##**Callocate**## initializes the allocated memory with zeros. + Consequently, ##**Callocate**## can be also directly used with ##[[KeyPgString|String]]## or ##[[KeyPgType|UDT]]## containing string, because the string descriptor is cleared (set to 0) first. + Similarly, ##**Callocate**## can also be used directly with ##[[KeyPgZstring|Zstring]]## or ##[[KeyPgWstring|Wstring]]## because string data is created with null characters. {{fbdoc item="ex"}} {{fbdoc item="filename" value="examples/manual/memory/callocate.bas"}}%%(freebasic) diff --git a/doc/manual/cache/KeyPgCast.wakka b/doc/manual/cache/KeyPgCast.wakka index 9011910cdf..b044c5a8b7 100644 --- a/doc/manual/cache/KeyPgCast.wakka +++ b/doc/manual/cache/KeyPgCast.wakka @@ -17,7 +17,7 @@ Converts an expression to a specified data type ##**Cast**## is more versatile because it can be used on built-in types that have a built-in ##[[KeyPgOperator|Cast operator]]##, but don't have a built-in keyword for it: e.g. ##**Cast**( //Byte//, //boolean// )##. It is also suitable for use in cases where the type of a variable is not fixed in the code - for example, it might be ##[[KeyPgPpdefine|Define]]##d earlier, or may be the ##[[KeyPgTypeof|Type of]]## a different variable or expression. - **Note:** If you want to use an operator specifically for converting to different types of ##[[KeyPgPointer|Pointer]]##s, consider using ##[[KeyPgCptr|Cptr]]## instead. + **Note:** If you want to use an operator specifically for converting to different types of ##[[KeyPgPtr|Pointer]]##s, consider using ##[[KeyPgCptr|Cptr]]## instead. **Upcasting:** In an inheritance structure, the upcasting is converting a derived type reference or pointer into a base type. In this special use, ##**Cast**## applied on a derived-type instance (##//expression//##) can be used to return a base-type (##//datatype//##) reference. diff --git a/doc/manual/cache/KeyPgClear.wakka b/doc/manual/cache/KeyPgClear.wakka index 76bd4b14e5..91ad89109a 100644 --- a/doc/manual/cache/KeyPgClear.wakka +++ b/doc/manual/cache/KeyPgClear.wakka @@ -18,7 +18,7 @@ Clears or initializes some memory {{fbdoc item="desc"}} ##**Clear**## sets one or more bytes in memory to a certain value (the default value is zero (##0##) if not specified). The starting address is taken from a reference to a variable or array element. - **NOTE:** In order to clear memory referenced by a ##[[KeyPgPointer|Pointer]]##, it must be dereferenced first. Otherwise, ##**Clear**## will try to clear the bytes at the **pointer variable**'s memory location. + **NOTE:** In order to clear memory referenced by a ##[[KeyPgPtr|Pointer]]##, it must be dereferenced first. Otherwise, ##**Clear**## will try to clear the bytes at the **pointer variable**'s memory location. {{fbdoc item="ex"}} {{fbdoc item="filename" value="examples/manual/array/clear.bas"}}%%(freebasic) diff --git a/doc/manual/cache/KeyPgCommon.wakka b/doc/manual/cache/KeyPgCommon.wakka index be5c917157..5397f67adb 100644 --- a/doc/manual/cache/KeyPgCommon.wakka +++ b/doc/manual/cache/KeyPgCommon.wakka @@ -39,7 +39,9 @@ Sub initme() foo(2) = foo(1)*2 End Sub %% -Output: +After compiling the two files like: +##fbc common1.bas common2.bas## +running ##common1## produces the output: %% 3.141592653589793 1.047197551196598 2.094395102393195 %% diff --git a/doc/manual/cache/KeyPgCptr.wakka b/doc/manual/cache/KeyPgCptr.wakka index a8ee47a21d..d71f0fbb82 100644 --- a/doc/manual/cache/KeyPgCptr.wakka +++ b/doc/manual/cache/KeyPgCptr.wakka @@ -7,7 +7,7 @@ Converts a pointer expression to a specified data type pointer {{fbdoc item="desc"}} Converts ##//expression//## to ##//""PointerDataType""//##. - ##//""PointerDataType""//## must be a ##[[KeyPgPointer|Pointer]]## type (e.g. a [[DataType]] ##[[KeyPgPtr|Ptr]]## or an ##[[KeyPgAny|Any]]## ##[[KeyPgPtr|Ptr]]##), or a ##[[KeyPgTypeAlias|Type (Alias)]]## to one. + ##//""PointerDataType""//## must be a ##[[KeyPgPtr|Pointer]]## type (e.g. a [[DataType]] ##[[KeyPgPtr|Ptr]]## or an ##[[KeyPgAny|Any]]## ##[[KeyPgPtr|Ptr]]##), or a ##[[KeyPgTypeAlias|Type (Alias)]]## to one. ##//expression//## may have a different pointer type or be an ##[[KeyPgInteger|Integer]]##. ~&//Note: Currently, FB does not actually enforce that ##//""PointerDataType""//## must be a pointer. This will likely change in future versions though. Currently, it may display a warning if you try to convert to a non-pointer (for any conversion type if you compile with the ##**[[CompilerOptw|-w pedantic]]**## compiler switch).// diff --git a/doc/manual/cache/KeyPgCustomgfx.wakka b/doc/manual/cache/KeyPgCustomgfx.wakka index b39a6ba4e0..11f13d2124 100644 --- a/doc/manual/cache/KeyPgCustomgfx.wakka +++ b/doc/manual/cache/KeyPgCustomgfx.wakka @@ -10,7 +10,7 @@ Parameter to the ##[[KeyPgPutgraphics|Put]]## graphics statement which selects a ##//custom_function_ptr//## name of the custom user defined function. ##//parameter//## - optional ##[[KeyPgPointer|pointer]]## to be passed to the custom function; if omitted, the default value is zero (##0##). + optional ##[[KeyPgPtr|pointer]]## to be passed to the custom function; if omitted, the default value is zero (##0##). {{fbdoc item="desc"}} ##**Custom**## selects a custom user defined function as the method for blitting an image buffer. diff --git a/doc/manual/cache/KeyPgDim.wakka b/doc/manual/cache/KeyPgDim.wakka index 32ff481651..63dddea153 100644 --- a/doc/manual/cache/KeyPgDim.wakka +++ b/doc/manual/cache/KeyPgDim.wakka @@ -52,16 +52,15 @@ dim px as double ptr = @x '$lang: "qb" -'' All variables beginning with A through N default to the INTEGER data type -'' All other variables will default to the SINGLE data type +'' All variables beginning with A through N will default to the INTEGER data type +'' All other variables default to the SINGLE data type DefInt I-N +Dim I, J, X, Y, T$, D As Double '' I and J are INTEGERs '' X and Y are SINGLEs '' T$ is STRING '' D is DOUBLE - -Dim I, J, X, Y, T$, D As Double %% {{fbdoc item="section" value="Arrays"}} @@ -90,7 +89,7 @@ Dim array(1 To 2, 6, 3 To 5) As Single For more information on arrays see [[ProPgArrays|Arrays Overview]]. - If the values used with ##**Dim**## to declare the dimensions of an array are all constants, the array will be created ##[[KeyPgOptionstatic|Static]]## (unless ##[[KeyPgOptiondynamic|Option Dynamic]]## is specified), while using one or more variables to declare the dimensions of an array makes it variable length, even if ##[[KeyPgOptionstatic|Option Static]]## is in effect. + If the values used with ##**Dim**## to declare the dimensions of an array are all constants, the array will be created fixed length (of ##[[KeyPgOptionstatic|Static]]## size, unless ##[[KeyPgOptiondynamic|Option Dynamic]]## is specified), while using one or more variables to declare the dimensions of an array makes it variable length, even if ##[[KeyPgOptionstatic|Option Static]]## is in effect. Arrays can be declared as variable length in several ways: Using ##**Dim**## with an empty set of indexes (##**Dim** x()##), using ##**Dim**## with indexes that are variables or using the keyword ##[[KeyPgRedim|Redim]]##, or using ##[[KeyPgAny|Any]]## in place of the array bounds, or declaring it past the metacommand ##[[KeyPgMetaDynamic|$Dynamic]]##. Variable length arrays can't use initializers. diff --git a/doc/manual/cache/KeyPgDrawString.wakka b/doc/manual/cache/KeyPgDrawString.wakka index 08ba74e232..7d4dd611ec 100644 --- a/doc/manual/cache/KeyPgDrawString.wakka +++ b/doc/manual/cache/KeyPgDrawString.wakka @@ -30,7 +30,7 @@ Graphics statement to render text to an image or screen. ##//blender//## custom blender function for the ##[[KeyPgCustomgfx|Custom]]## drawing method; see ##[[KeyPgPutgraphics|Put (Graphics)]]## statement description for details. This parameter only applies to the ##[[KeyPgCustomgfx|Custom]]## method. ##//parameter//## - optional ##[[KeyPgPointer|pointer]]## to be passed to the custom blender function; if omitted, the default value is zero (##0##). + optional ##[[KeyPgPtr|pointer]]## to be passed to the custom blender function; if omitted, the default value is zero (##0##). {{fbdoc item="desc"}} This graphics keyword prints a string to the screen with pixel positioning, transparent background, and can use an user-supplied font. **##Draw String##** does not update any text or graphics cursor. It doesn't wrap at the end of line. Tabs, carriage returns and other special characters have no special behavior in **##Draw String##**, and are treated as normal characters. diff --git a/doc/manual/cache/KeyPgDylibfree.wakka b/doc/manual/cache/KeyPgDylibfree.wakka index e26233ebcc..85307bed75 100644 --- a/doc/manual/cache/KeyPgDylibfree.wakka +++ b/doc/manual/cache/KeyPgDylibfree.wakka @@ -2,7 +2,7 @@ Unloads a dynamic link library from memory {{fbdoc item="syntax"}}## - [[KeyPgDeclare|declare]] [[KeyPgSub|sub]] **Dylibfree** ( [[KeyPgByval|byval]] //library// [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPointer|pointer]] ) + [[KeyPgDeclare|declare]] [[KeyPgSub|sub]] **Dylibfree** ( [[KeyPgByval|byval]] //library// [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|pointer]] ) ## {{fbdoc item="usage"}}## **Dylibfree**( //library// ) diff --git a/doc/manual/cache/KeyPgDylibload.wakka b/doc/manual/cache/KeyPgDylibload.wakka index 4fd17d2e5e..d0e152191d 100644 --- a/doc/manual/cache/KeyPgDylibload.wakka +++ b/doc/manual/cache/KeyPgDylibload.wakka @@ -2,7 +2,7 @@ Loads to a Dynamic Link Library (DLL) into memory at runtime {{fbdoc item="syntax"}}## - [[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Dylibload** ( [[KeyPgByref|byref]] //filename// [[KeyPgAs|as]] [[KeyPgString|string]] ) [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPointer|Pointer]] + [[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Dylibload** ( [[KeyPgByref|byref]] //filename// [[KeyPgAs|as]] [[KeyPgString|string]] ) [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|Pointer]] ## {{fbdoc item="usage"}}## //result// = **Dylibload** ( //filename// ) @@ -12,7 +12,7 @@ Loads to a Dynamic Link Library (DLL) into memory at runtime A ##[[KeyPgString|string]]## containing the filename of the library to load. {{fbdoc item="ret"}} - The ##[[KeyPgPointer|pointer]]## handle of the library loaded. Zero on error + The ##[[KeyPgPtr|pointer]]## handle of the library loaded. Zero on error {{fbdoc item="desc"}} ##[[KeyPgDylibload|Dylibload]]## is used to link at runtime libraries to your program. This function does the link and returns a handle that must be used with ##[[KeyPgDylibsymbol|Dylibsymbol]]## when calling a function in the library and with ##[[KeyPgDylibfree|Dylibfree]]## when releasing the library. diff --git a/doc/manual/cache/KeyPgErase.wakka b/doc/manual/cache/KeyPgErase.wakka index e382b0c33a..a26d3c0aa2 100644 --- a/doc/manual/cache/KeyPgErase.wakka +++ b/doc/manual/cache/KeyPgErase.wakka @@ -17,6 +17,8 @@ Statement to erase arrays Using ##**Erase**## on a variable-length array (array already sized) frees the memory allocated for the array elements, but the array remains declared at its same scope level (with the same datatype and number of dimensions). In case of objects, there is destruction before freeing memory. + + **Note:** ##**Erase**## can not be used on fixed-size arrays passed as parameters in a procedure. FreeBASIC can not prevent you from trying this at compile-time, but the results at run-time will be undefined (up to crashing). {{fbdoc item="ex"}} {{fbdoc item="filename" value="examples/manual/array/erase.bas"}}%%(freebasic) diff --git a/doc/manual/cache/KeyPgExtends.wakka b/doc/manual/cache/KeyPgExtends.wakka index a3231752fe..d8d75a7aff 100644 --- a/doc/manual/cache/KeyPgExtends.wakka +++ b/doc/manual/cache/KeyPgExtends.wakka @@ -227,5 +227,7 @@ Delete c - ##[[KeyPgVirtual|Virtual]]## - ##[[KeyPgAbstract|Abstract]]## - ##[[KeyPgOverride|Override]]## + - ##[[KeyPgExtendsZstring|Extends Zstring]]## + - ##[[KeyPgExtendsWstring|Extends Wstring]]## {{fbdoc item="back" value="CatPgUserDefTypes|User Defined Types"}} \ No newline at end of file diff --git a/doc/manual/cache/KeyPgExtendsWstring.wakka b/doc/manual/cache/KeyPgExtendsWstring.wakka new file mode 100644 index 0000000000..049d07377c --- /dev/null +++ b/doc/manual/cache/KeyPgExtendsWstring.wakka @@ -0,0 +1,35 @@ +{{fbdoc item="title" value="EXTENDS WSTRING"}}---- +Specifies a type which inherits a Wstring behavior + +{{fbdoc item="syntax"}}## + [[KeyPgType|Type]]|[[KeyPgUnion|Union]] //typename// **Extends Wstring** [, //base_typename//] + ... + End [[KeyPgType|Type]]|[[KeyPgUnion|Union]] +## +{{fbdoc item="desc"}} + ##**Extends Wstring**## declares ##//typename//## to inherit properties and behaviors of a ##[[KeyPgWstring|Wstring]]##. Purpose is to allow users to create custom string types (with i.e. dynamic memory management) that can integrate well in to existing fbc compiler built ins (good interoperability with fbc's ##[[KeyPgWstring|Wstring]]## type). + + This declaration of such a UDT with a suitable ##[[KeyPgOpCast|Cast]]## operator will instruct compiler to convert the UDT to a ##[[KeyPgWstring|Wstring]]## (in addition, other suitable operators as ##[[KeyPgOpLet|Let]]##, ##{{fbdoc item="keyword" value="KeyPgOpPtrIndex|[] (Pointer index)"}}##, ##[[KeyPgLen|Len]]##, ..., can be also declared). + + ##[[KeyPgWstring|Wstring]]## behaviour can be inherited directly, or indirectly and singly from a base-type. + ##[[KeyPgWstring|Wstring]]## behaviour can be inherited by a UDT also extending ##//base_typename//## (a kind of pseudo multiple-inheritance). + + **Note:** By declaring a type (directly or indirectly) as ##**Extends Wstring**## (in addition to defining a suitable ##[[KeyPgOpCast|Cast]]## operator only), this promotes it fully compatible even with ##[[KeyPgOpStrptr|Strptr]]##/##[[KeyPgSadd|Sadd]]##, ##[[KeyPgLset|Lset]]##/##[[KeyPgRset|Rset]]##, and ##[[KeyPgSelectcase|Select Case]]##, but currently not yet with the built in functions ##[[KeyPgVal|Val]]##/##[[KeyPgValint|Valint]]##/##[[KeyPgVallng|Vallng]]##/##[[KeyPgValuint|Valuint]]##/##[[KeyPgValulng|Valunlg]]## and ##[[KeyPgLeft|Left]]##/##[[KeyPgRight|Right]]##. + +{{fbdoc item="ex"}} + See ##[[KeyPgExtendsZstring|Extends Zstring]]## for similar examples. + +{{fbdoc item="lang"}} + - Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Extends __Wstring""**##, but unusable because no member procedure is allowed in this dialect. + +{{fbdoc item="diff"}} + - New to ""FreeBASIC"" + +{{fbdoc item="see"}} + - ##[[KeyPgType|Type]]## + - ##[[KeyPgUnion|Union]]## + - ##[[KeyPgExtends|Extends]]## + - ##[[KeyPgWstring|Wstring]]## + - ##[[KeyPgExtendsZstring|Extends Zstring]]## + +{{fbdoc item="back" value="CatPgUserDefTypes|User Defined Types"}} \ No newline at end of file diff --git a/doc/manual/cache/KeyPgExtendsZstring.wakka b/doc/manual/cache/KeyPgExtendsZstring.wakka new file mode 100644 index 0000000000..def82df5d3 --- /dev/null +++ b/doc/manual/cache/KeyPgExtendsZstring.wakka @@ -0,0 +1,134 @@ +{{fbdoc item="title" value="EXTENDS ZSTRING"}}---- +Specifies a type which inherits a Zstring behavior + +{{fbdoc item="syntax"}}## + [[KeyPgType|Type]]|[[KeyPgUnion|Union]] //typename// **Extends Zstring** [, //base_typename//] + ... + End [[KeyPgType|Type]]|[[KeyPgUnion|Union]] +## +{{fbdoc item="desc"}} + ##**Extends Zstring**## declares ##//typename//## to inherit properties and behaviors of a ##[[KeyPgZstring|Zstring]]##. Purpose is to allow users to create custom string types (with i.e. dynamic memory management) that can integrate well in to existing fbc compiler built ins (good interoperability with fbc's ##[[KeyPgZstring|Zstring]]## type). + + This declaration of such a UDT with a suitable ##[[KeyPgOpCast|Cast]]## operator will instruct compiler to convert the UDT to a ##[[KeyPgZstring|Zstring]]## (in addition, other suitable operators as ##[[KeyPgOpLet|Let]]##, ##{{fbdoc item="keyword" value="KeyPgOpPtrIndex|[] (Pointer index)"}}##, ##[[KeyPgLen|Len]]##, ..., can be also declared). + + ##[[KeyPgZstring|Zstring]]## behaviour can be inherited directly, or indirectly and singly from a base-type. + ##[[KeyPgZstring|Zstring]]## behaviour can be inherited by a UDT also extending ##//base_typename//## (a kind of pseudo multiple-inheritance). + + **Note:** By declaring a type (directly or indirectly) as ##**Extends Zstring**## (in addition to defining a suitable ##[[KeyPgOpCast|Cast]]## operator only), this promotes it fully compatible even with ##[[KeyPgOpStrptr|Strptr]]##/##[[KeyPgSadd|Sadd]]##, ##[[KeyPgLset|Lset]]##/##[[KeyPgRset|Rset]]##, and ##[[KeyPgSelectcase|Select Case]]##, but currently not yet with the built in functions ##[[KeyPgVal|Val]]##/##[[KeyPgValint|Valint]]##/##[[KeyPgVallng|Vallng]]##/##[[KeyPgValuint|Valuint]]##/##[[KeyPgValulng|Valunlg]]## and ##[[KeyPgLeft|Left]]##/##[[KeyPgRight|Right]]##. + +{{fbdoc item="ex"}} +{{fbdoc item="filename" value="examples/manual/udt/extendszstring1.bas"}}%%(freebasic) +Type myZstring Extends Zstring + Public: + Declare Constructor (Byref z As Const Zstring = "") + Declare Operator Cast () Byref As Const Zstring + Declare Operator Let (Byref z As Const Zstring) + Private: + Dim As String s +End Type + +Constructor myZstring (Byref z As Const Zstring = "") + This.s = z +End Constructor + +Operator myZstring.Cast () Byref As Const Zstring + Return *Strptr(This.s) +End Operator + +Operator myZstring.Let (Byref z As Const Zstring) + This.s = z +End Operator + +Dim As myZstring z = "FreeBASIC" +Print "'" & z & "'" + +z &= " compiler" +Print "'" & z & "'" + +Sleep +%% +{{fbdoc item="filename" value="examples/manual/udt/extendszstring2.bas"}}%%(freebasic) +Type vZstring Extends Zstring + Public: + Declare Constructor (Byval pz As Const Zstring Ptr = 0) + Declare Operator Cast () Byref As Zstring + Declare Operator Let (Byval pz As Const Zstring Ptr) + Declare Operator [] (Byval index As Integer) Byref As Ubyte + Declare Destructor () + Private: + Dim As Zstring Ptr p + Dim As Uinteger l +End Type + +Constructor vZstring (Byval pz As Const Zstring Ptr = 0) + This.l = Len(*pz) + This.p = Callocate(This.l + 1, Sizeof(Zstring)) + *This.p = *pz +End Constructor + +Operator vZstring.Cast () Byref As Zstring + Return *This.p +End Operator + +Operator vZstring.Let (Byval pz As Const Zstring Ptr) + If This.l < Len(*pz) Then + Deallocate(This.p) + This.l = Len(*pz) + This.p = Callocate(This.l + 1, Sizeof(Zstring)) + End If + *This.p = *pz +End Operator + +Operator vZstring.[] (Byval index As Integer) Byref As Ubyte + Return This.p[index] +End Operator + +Destructor vZstring () + Deallocate(This.p) +End Destructor + +Operator Len (Byref v As vZstring) As Integer + Return Len(Type(v)) '' found nothing better than this ('vZstring.l' being private) +End Operator + +Dim As vZstring v = "FreeBASIC" +Print "'" & v & "'", Len(v) + +Dim As Zstring * 256 z +z = *Strptr(v) '' 'error 24: Invalid data types' without 'Extends Zstring' +Print "'" & z & "'", Len(z) + +v &= Space(2) +Print "'" & v & "'", Len(v) +Rset v, "FreeBASIC" '' 'error 24: Invalid data types' without 'Extends Zstring' +Print "'" & v & "'", Len(v) '' ('Cast' must return a modifiable reference) + +Select Case v '' 'error 24: Invalid data types' without 'Extends Zstring' +Case Type(Trim(v) & " ") + Print "Left justified" +Case Type(" " & Trim(v)) + Print "Right justified" +End Select + +v[0] = Asc("-") +Print "'" & v & "'", Len(v) + +'Print "'" & Right(v, 5) & "'" '' 'Right' does not yet support types with 'Extends Zstring' +Print "'" & Right(Str(v), 5) & "'" '' workaround + +Sleep +%% +{{fbdoc item="lang"}} + - Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Extends __Zstring""**##, but unusable because no member procedure is allowed in this dialect. + +{{fbdoc item="diff"}} + - New to ""FreeBASIC"" + +{{fbdoc item="see"}} + - ##[[KeyPgType|Type]]## + - ##[[KeyPgUnion|Union]]## + - ##[[KeyPgExtends|Extends]]## + - ##[[KeyPgZstring|Zstring]]## + - ##[[KeyPgExtendsWstring|Extends Wstring]]## + +{{fbdoc item="back" value="CatPgUserDefTypes|User Defined Types"}} \ No newline at end of file diff --git a/doc/manual/cache/KeyPgImplements.wakka b/doc/manual/cache/KeyPgImplements.wakka index d7e5eb8c10..8a364f814d 100644 --- a/doc/manual/cache/KeyPgImplements.wakka +++ b/doc/manual/cache/KeyPgImplements.wakka @@ -20,5 +20,7 @@ Specifies an interface to be implemented by a user-defined type {{fbdoc item="see"}} - ##[[KeyPgType|Type]]## - ##[[KeyPgExtends|Extends]]## + - ##[[KeyPgExtendsZstring|Extends Zstring]]## + - ##[[KeyPgExtendsWstring|Extends Wstring]]## {{fbdoc item="back" value="CatPgUserDefTypes|User Defined Types"}} \ No newline at end of file diff --git a/doc/manual/cache/KeyPgInputnum.wakka b/doc/manual/cache/KeyPgInputnum.wakka index 8e5076e7e7..3164f6aac8 100644 --- a/doc/manual/cache/KeyPgInputnum.wakka +++ b/doc/manual/cache/KeyPgInputnum.wakka @@ -36,8 +36,11 @@ do loop until choice >= "1" and choice <= "3" %% +{{fbdoc item="lang"}} + - The string type suffix "$" is forbidden in the //[[CompilerOptlang|-lang fb]]// dialect. + {{fbdoc item="diff"}} - - None + - None in the //[[CompilerOptlang|-lang qb]]// dialect. {{fbdoc item="see"}} - ##[[KeyPgWinput|Winput()]]## diff --git a/doc/manual/cache/KeyPgObject.wakka b/doc/manual/cache/KeyPgObject.wakka index e5cf99bc9d..fba2ae5865 100644 --- a/doc/manual/cache/KeyPgObject.wakka +++ b/doc/manual/cache/KeyPgObject.wakka @@ -29,6 +29,8 @@ Built-in type providing run-time type information {{fbdoc item="see"}} - ##[[KeyPgExtends|Extends]]## + - ##[[KeyPgExtendsZstring|Extends Zstring]]## + - ##[[KeyPgExtendsWstring|Extends Wstring]]## - ##[[KeyPgOpIs|Operator Is]]## - ##[[KeyPgVirtual|Virtual]]## - ##[[KeyPgAbstract|Abstract]]## diff --git a/doc/manual/cache/KeyPgOpAdd.wakka b/doc/manual/cache/KeyPgOpAdd.wakka index 62e1093b76..2958678982 100644 --- a/doc/manual/cache/KeyPgOpAdd.wakka +++ b/doc/manual/cache/KeyPgOpAdd.wakka @@ -8,8 +8,8 @@ Sums two expressions [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **+** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] [[KeyPgSingle|single]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgSingle|single]] ) [[KeyPgAs|as]] [[KeyPgSingle|single]] [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **+** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] [[KeyPgDouble|double]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgDouble|double]] ) [[KeyPgAs|as]] [[KeyPgDouble|double]] - [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **+** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T// [[KeyPgPointer|Pointer]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgAs|as]] //T// [[KeyPgPointer|Pointer]] - [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **+** ( [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]], [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T// [[KeyPgPointer|Pointer]] ) [[KeyPgAs|as]] //T// [[KeyPgPointer|Pointer]] + [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **+** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T// [[KeyPgPtr|Pointer]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgAs|as]] //T// [[KeyPgPtr|Pointer]] + [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **+** ( [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]], [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T// [[KeyPgPtr|Pointer]] ) [[KeyPgAs|as]] //T// [[KeyPgPtr|Pointer]] [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **+** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T//, [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgAs|as]] //T// [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **+** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] //T// ) [[KeyPgAs|as]] //T// @@ -33,7 +33,7 @@ Sums two expressions When the left and right-hand side expressions are string values, **##Operator +## (Add)** concatenates the two strings and returns the result. - If an integral value ##//n//## is added to a ##//T// [[KeyPgPointer|Pointer]]## type, the operator performs pointer arithmetic on the address, returning the memory position of a ##//T//## value, ##//n//## indices away (assuming ##//n//## is within bounds of a contiguous array of ##//T//## values). This behaves differently from numeric addition, because the ##[[KeyPgInteger|Integer]]## value is scaled by ##[[KeyPgSizeof|Sizeof]]( //T// )##. + If an integral value ##//n//## is added to a ##//T// [[KeyPgPtr|Pointer]]## type, the operator performs pointer arithmetic on the address, returning the memory position of a ##//T//## value, ##//n//## indices away (assuming ##//n//## is within bounds of a contiguous array of ##//T//## values). This behaves differently from numeric addition, because the ##[[KeyPgInteger|Integer]]## value is scaled by ##[[KeyPgSizeof|Sizeof]]( //T// )##. Neither operand is modified in any way. diff --git a/doc/manual/cache/KeyPgOpAt.wakka b/doc/manual/cache/KeyPgOpAt.wakka index ca705f5848..db32929464 100644 --- a/doc/manual/cache/KeyPgOpAt.wakka +++ b/doc/manual/cache/KeyPgOpAt.wakka @@ -2,7 +2,7 @@ Returns the address of a string literal, variable, object or procedure {{fbdoc item="syntax"}}## - [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **@** ( [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] //T// ) [[KeyPgAs|as]] //T// [[KeyPgPointer|pointer]] + [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **@** ( [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] //T// ) [[KeyPgAs|as]] //T// [[KeyPgPtr|pointer]] ## {{fbdoc item="usage"}}## //result// = **@** //rhs// diff --git a/doc/manual/cache/KeyPgOpCombineAdd.wakka b/doc/manual/cache/KeyPgOpCombineAdd.wakka index c604165dcf..53fab28e82 100644 --- a/doc/manual/cache/KeyPgOpCombineAdd.wakka +++ b/doc/manual/cache/KeyPgOpCombineAdd.wakka @@ -4,7 +4,7 @@ Adds and assigns a value to a variable {{fbdoc item="syntax"}}## [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **+=** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T1//, [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] //T2// ) - [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **+=** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T// [[KeyPgPointer|ptr]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) + [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **+=** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T// [[KeyPgPtr|ptr]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **+=** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] [[KeyPgString|string]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgString|string]] ) [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **+=** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] [[KeyPgWstring|wstring]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgWstring|wstring]] ) diff --git a/doc/manual/cache/KeyPgOpCombineSub.wakka b/doc/manual/cache/KeyPgOpCombineSub.wakka index 5b089afbaf..658d8144cc 100644 --- a/doc/manual/cache/KeyPgOpCombineSub.wakka +++ b/doc/manual/cache/KeyPgOpCombineSub.wakka @@ -3,7 +3,7 @@ Subtracts and assigns a value to a variable {{fbdoc item="syntax"}}## [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **-=** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T1//, [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] //T2// ) - [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **-=** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T// [[KeyPgPointer|ptr]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) + [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **-=** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T// [[KeyPgPtr|ptr]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) ## {{fbdoc item="usage"}}## //lhs// **-=** //rhs// diff --git a/doc/manual/cache/KeyPgOpIs.wakka b/doc/manual/cache/KeyPgOpIs.wakka index f75c31c3c3..3b87848354 100644 --- a/doc/manual/cache/KeyPgOpIs.wakka +++ b/doc/manual/cache/KeyPgOpIs.wakka @@ -90,6 +90,8 @@ identify(@o) {{fbdoc item="see"}} - ##[[KeyPgExtends|Extends]]## + - ##[[KeyPgExtendsZstring|Extends Zstring]]## + - ##[[KeyPgExtendsWstring|Extends Wstring]]## - ##[[KeyPgObject|Object]]## - ##[[KeyPgIs|Is (Select Case)]]## - ##[[KeyPgTypeof|Typeof]]## diff --git a/doc/manual/cache/KeyPgOpLetlist.wakka b/doc/manual/cache/KeyPgOpLetlist.wakka index 5ba7bcdd2b..11d138c724 100644 --- a/doc/manual/cache/KeyPgOpLetlist.wakka +++ b/doc/manual/cache/KeyPgOpLetlist.wakka @@ -15,6 +15,8 @@ Assigns fields of a user defined type to a list of variables {{fbdoc item="desc"}} Assigns the values from the ##//UDT_var//## variable's fields to the list of variables. + When the ##//UDT//## ##[[KeyPgExtends|Extends]]## a Base, the first variable (##//variable1//##) assigned by the operator then corresponds to a Base instance (only the other variables are those to receive the values of the data fields of the ##//UDT//##). + Union is not supported. {{fbdoc item="ex"}} @@ -41,6 +43,38 @@ x = 5 y = 7 %% +{{fbdoc item="filename" value="examples/manual/operator/let-list2.bas"}}%%(freebasic) +Type Parent + Dim As Integer p1, p2 +End Type + +Type Child Extends Parent + Dim As Integer c1, c2 +End Type + +Type GrandChild Extends Child + Dim As Integer gc1, gc2 +End Type + +Dim As GrandChild gc = Type(1, 2, 3, 4, 5, 6) + +Dim As Integer i1, i2 +Dim As Integer j1, j2 +Dim As Parent p +Dim As Child c + +Let(c, i1, i2) = gc +Print c.p1, c.p2, c.c1, c.c2, i1, i2 + +Let(p, j1, j2) = gc +Print p.p1, p.p2, j1, j2 +%% +Output: +%% + 1 2 3 4 5 6 + 1 2 5 6 +%% + {{fbdoc item="lang"}} - Only available in the //[[CompilerOptlang|-lang fb]]// dialect. diff --git a/doc/manual/cache/KeyPgOpPtrIndex.wakka b/doc/manual/cache/KeyPgOpPtrIndex.wakka index 972a70f2ed..212ab27c18 100644 --- a/doc/manual/cache/KeyPgOpPtrIndex.wakka +++ b/doc/manual/cache/KeyPgOpPtrIndex.wakka @@ -2,7 +2,7 @@ Returns a reference to memory offset from an address {{fbdoc item="syntax"}}## - [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **[]** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T// [[KeyPgPointer|pointer]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgByrefFunction|byref]] [[KeyPgAs|as]] //T// + [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **[]** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T// [[KeyPgPtr|pointer]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgByrefFunction|byref]] [[KeyPgAs|as]] //T// ## {{fbdoc item="usage"}}## @@ -18,11 +18,14 @@ Returns a reference to memory offset from an address {{fbdoc item="desc"}} This operator returns a reference to a value some distance in memory from a base address. It is essentially shorthand for "##[[KeyPgOpValueOf|*]](//lhs// [[KeyPgOpAdd|+]] //rhs//)##" because the reference can be thought of as a pointer having as value the memory location "##(//lhs// [[KeyPgOpAdd|+]] //rhs//)##", and which is implicitly dereferenced; both do exactly the same thing. - Like pointer arithmetic, any type of ##[[KeyPgPointer|Pointer]]## can be indexed except for an ##[[KeyPgAny|Any]]## ##[[KeyPgPointer|Pointer]]##. Also, like pointer arithmetic, it is up to the user to make sure meaningful data is being accessed. + Like pointer arithmetic, any type of ##[[KeyPgPtr|Pointer]]## can be indexed except for an ##[[KeyPgAny|Any]]## ##[[KeyPgPtr|Pointer]]##. Also, like pointer arithmetic, it is up to the user to make sure meaningful data is being accessed. When indexing a '2-dimensional' pointer (i.e. a ##//T// Ptr Ptr##), the first (leftmost) index is applied before the second: For example, ##//Pt//[//I1//][//I2//]## = ##*(//Pt//[//I1//] + //I2//)## = ##*(*(//Pt// + //I1//) + //I2//)## In general, when using an '//n//-dimensional' pointer: ##//Pt//[//I1//][//I2//].....[//In//]##, the index order (from left to right) corresponds to the dereferencing order. + This operator must not be used in case of null pointer because reference is undefined (inducing runtime error). + Otherwise, the user must ensure that the offset value (##//rhs//##) is in a range that allows an access to valid memory. Outside this range, results are undefined. + This operator can be overloaded for user-defined types as a member ##[[KeyPgOperator|Operator]]## using the appropriate syntax. {{fbdoc item="ex"}} diff --git a/doc/manual/cache/KeyPgOpSubtract.wakka b/doc/manual/cache/KeyPgOpSubtract.wakka index 4287be914d..53adc3620b 100644 --- a/doc/manual/cache/KeyPgOpSubtract.wakka +++ b/doc/manual/cache/KeyPgOpSubtract.wakka @@ -8,8 +8,8 @@ Subtracts two expressions [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **-** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] [[KeyPgSingle|single]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgSingle|single]] ) [[KeyPgAs|as]] [[KeyPgSingle|single]] [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **-** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] [[KeyPgDouble|double]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgDouble|double]] ) [[KeyPgAs|as]] [[KeyPgDouble|double]] - [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **-** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T// [[KeyPgPointer|Pointer]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] //T// [[KeyPgPointer|Pointer]] ) [[KeyPgAs|as]] [[KeyPgInteger|integer]] - [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **-** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T// [[KeyPgPointer|Pointer]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgAs|as]] //T// [[KeyPgPointer|Pointer]] + [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **-** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T// [[KeyPgPtr|Pointer]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] //T// [[KeyPgPtr|Pointer]] ) [[KeyPgAs|as]] [[KeyPgInteger|integer]] + [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **-** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T// [[KeyPgPtr|Pointer]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgAs|as]] //T// [[KeyPgPtr|Pointer]] [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **-** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T//, [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] //T// ) [[KeyPgAs|as]] [[KeyPgInteger|integer]] [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **-** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T//, [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgAs|as]] //T// @@ -32,9 +32,9 @@ Subtracts two expressions {{fbdoc item="desc"}} When the left and right-hand side expressions are numeric values, **##Operator -## (Subtract)** returns the subtraction of the two values. - If the left and right-hand side expressions are both of the ##//T// [[KeyPgPointer|Pointer]]## type, for some type ##//T//##, the operator performs pointer subtraction on the address, returning the result. This is different from numeric subtraction because the difference is divided by ##[[KeyPgSizeof|Sizeof]]( //T// )##. + If the left and right-hand side expressions are both of the ##//T// [[KeyPgPtr|Pointer]]## type, for some type ##//T//##, the operator performs pointer subtraction on the address, returning the result. This is different from numeric subtraction because the difference is divided by ##[[KeyPgSizeof|Sizeof]]( //T// )##. - If an integral value ##//n//## is subtracted from a ##//T// [[KeyPgPointer|Pointer]]## type, the operator performs pointer arithmetic on the address, returning the memory position of a ##//T//## value, ##//n//## indices before (assuming ##//(-n)//## is within bounds of a contiguous array of ##//T//## values). This behaves differently from numeric subtraction, because the ##[[KeyPgInteger|Integer]]## value is scaled by ##[[KeyPgSizeof|Sizeof]]( //T// )##. + If an integral value ##//n//## is subtracted from a ##//T// [[KeyPgPtr|Pointer]]## type, the operator performs pointer arithmetic on the address, returning the memory position of a ##//T//## value, ##//n//## indices before (assuming ##//(-n)//## is within bounds of a contiguous array of ##//T//## values). This behaves differently from numeric subtraction, because the ##[[KeyPgInteger|Integer]]## value is scaled by ##[[KeyPgSizeof|Sizeof]]( //T// )##. Neither operand is modified in any way. diff --git a/doc/manual/cache/KeyPgOpValueOf.wakka b/doc/manual/cache/KeyPgOpValueOf.wakka index db4ef4d8dd..286a90f8b1 100644 --- a/doc/manual/cache/KeyPgOpValueOf.wakka +++ b/doc/manual/cache/KeyPgOpValueOf.wakka @@ -2,7 +2,7 @@ Dereferences a pointer {{fbdoc item="syntax"}}## - [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] ***** ( [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] //T// [[KeyPgPointer|pointer]] ) [[KeyPgByrefFunction|byref]] [[KeyPgAs|as]] //T// + [[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] ***** ( [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] //T// [[KeyPgPtr|pointer]] ) [[KeyPgByrefFunction|byref]] [[KeyPgAs|as]] //T// ## {{fbdoc item="usage"}}## @@ -19,10 +19,13 @@ Dereferences a pointer {{fbdoc item="desc"}} **##Operator *## (Value of)** returns a reference to the value stored at an address, and is often called the dereference operator. The operand is not modified in any way. - Any type of ##[[KeyPgPointer|Pointer]]## can be dereferenced except for an ##[[KeyPgAny|Any]]## ##[[KeyPgPointer|Pointer]]##. + Any type of ##[[KeyPgPtr|Pointer]]## can be dereferenced except for an ##[[KeyPgAny|Any]]## ##[[KeyPgPtr|Pointer]]##. As a reference, the result of this operator can be used on the left-hand side of assignments. + This operator must not be used in case of null pointer because reference is undefined (inducing runtime error). + Otherwise, the user must ensure that the pointer value induces access to a valid memory. Otherwise, results are undefined. + This operator can be overloaded for user-defined types. {{fbdoc item="ex"}} diff --git a/doc/manual/cache/KeyPgPointer.wakka b/doc/manual/cache/KeyPgPointer.wakka deleted file mode 100644 index f9a666af0e..0000000000 --- a/doc/manual/cache/KeyPgPointer.wakka +++ /dev/null @@ -1,33 +0,0 @@ -{{fbdoc item="title" value="POINTER"}}---- -A variable declaration type modifier - -{{fbdoc item="syntax"}}## - [[KeyPgDim|dim]] //symbolname// [[KeyPgAs|as]] [[DataType|DataType]] {**Pointer** | [[KeyPgPtr|ptr]]} -## -{{fbdoc item="desc"}} - Declares a pointer variable. The same as ##[[KeyPgPtr|Ptr]]##. - -{{fbdoc item="ex"}} -{{fbdoc item="filename" value="examples/manual/datatype/pointer.bas"}}%%(freebasic) -dim p as zstring pointer -dim text as string -text = "Hello World!" -p = strptr(text) + 6 -print text -print *p - -'' Output: -'' Hello World! -'' World! -%% - -{{fbdoc item="lang"}} - - Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Pointer""**##. - -{{fbdoc item="diff"}} - - New to ""FreeBASIC"" - -{{fbdoc item="see"}} - - ##[[KeyPgPtr|Ptr]]## - -{{fbdoc item="back" value="CatPgStdDataTypes|Standard Data Types"}} \ No newline at end of file diff --git a/doc/manual/cache/KeyPgPtr.wakka b/doc/manual/cache/KeyPgPtr.wakka index 474a518d53..1db6d54a49 100644 --- a/doc/manual/cache/KeyPgPtr.wakka +++ b/doc/manual/cache/KeyPgPtr.wakka @@ -1,11 +1,11 @@ -{{fbdoc item="title" value="PTR"}}---- +{{fbdoc item="title" value="(POINTER | PTR)"}}---- A variable declaration type modifier {{fbdoc item="syntax"}}## - [[KeyPgDim|dim]] //symbolname// [[KeyPgAs|as]] [[DataType|DataType]] {**Ptr** | [[KeyPgPointer|pointer]]} + [[KeyPgDim|dim]] //symbolname// [[KeyPgAs|as]] [[DataType|DataType]] {**Pointer** | **Ptr**} ## {{fbdoc item="desc"}} - Declares a pointer variable. The same as ##[[KeyPgPointer|Pointer]]##. + Declares a pointer variable. ##[[KeyPgOpAt|Operator @ (Address of)]]## operator or ##[[KeyPgOpVarptr|Varptr]]## are used to take the address of a variable. The ##[[KeyPgOpValueOf|Operator * (Value of)]]## operator is used to dereference the pointer, that is, access the actual value stored in the memory location the pointer is pointing at. @@ -28,15 +28,26 @@ Print Print "Pointer 'p' points to memory location:" Print p %% +{{fbdoc item="filename" value="examples/manual/datatype/pointer.bas"}}%%(freebasic) +dim p as zstring pointer +dim text as string +text = "Hello World!" +p = strptr(text) + 6 +print text +print *p + +'' Output: +'' Hello World! +'' World! +%% {{fbdoc item="lang"}} - - Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Ptr""**##. + - Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Pointer""**## or ##**""__Ptr""**##. {{fbdoc item="diff"}} - New to ""FreeBASIC"" {{fbdoc item="see"}} - - ##[[KeyPgPointer|Pointer]]## - ##[[KeyPgAllocate|Allocate]]## {{fbdoc item="back" value="CatPgStdDataTypes|Standard Data Types"}} \ No newline at end of file diff --git a/doc/manual/cache/KeyPgString.wakka b/doc/manual/cache/KeyPgString.wakka index 179e16d60c..12d6e771a7 100644 --- a/doc/manual/cache/KeyPgString.wakka +++ b/doc/manual/cache/KeyPgString.wakka @@ -93,6 +93,7 @@ silly_print( "Status: " + status ) - ##[[KeyPgOpStrptr|Strptr]]## - ##[[KeyPgOpVarptr|Varptr]]## - ##[[TblVarTypes|Standard Data Type Limits]]## - + - ##{{fbdoc item="keyword" value="KeyPgOpStringIndex|Operator [] (String index)"}}## + - ##[[CatPgOpString|String Operators]]## {{fbdoc item="back" value="CatPgStdDataTypes|Standard Data Types"}}{{fbdoc item="back" value="CatPgString|String Functions"}} \ No newline at end of file diff --git a/doc/manual/cache/KeyPgType.wakka b/doc/manual/cache/KeyPgType.wakka index 637da5106b..ddbd619db3 100644 --- a/doc/manual/cache/KeyPgType.wakka +++ b/doc/manual/cache/KeyPgType.wakka @@ -57,7 +57,7 @@ Declares a user-defined type. //Variable-length data// In ""FreeBASIC"", Type data structures must ultimately be fixed-size, such that the compiler knows how much memory to allocate for objects of that Type. Nevertheless, Types may contain variable-length (dynamic) string or array data members. However, the string's/array's data will not be embedded in the Type directly. Instead, the Type will only contain a ##[[KeyPgString|String]]##/array descriptor structure, which ""FreeBASIC"" uses behind the scenes to manage the variable-length string/array data. For sizing the structure of the array descriptor in the Type, a variable-length (dynamic) array data member must be always declared by using ##[[KeyPgAny|Any(s)]]## in place of the array bounds, in order to fix the amount of dimensions based on the number of Anys specified. - Variable-length array fields are considered as pseudo-objects when they are declared in a ##**Type**##, just like variable-length strings (the implicit copy constructor and the implicit let operator themselves support [re]sizing and copying such arrays). + Variable-length array fields are considered as pseudo-objects when they are declared in a ##**Type**##, just like variable-length strings (the implicit copy constructor and the implicit let operator themselves support [re]sizing and copying such arrays, or their erasing). Because of that, saving such a Type into a file will write out the descriptor, not the actual string/array data. In order to embed strings/arrays into Types directly, fixed-length strings/arrays must be used. @@ -184,6 +184,8 @@ Sleep - ##[[KeyPgAlias|Alias (Name)]]## - ##[[KeyPgField|Field]]## - ##[[KeyPgExtends|Extends]]## + - ##[[KeyPgExtendsZstring|Extends Zstring]]## + - ##[[KeyPgExtendsWstring|Extends Wstring]]## - ##[[KeyPgWith|With]]## - [[ProPgDataConversion|Coercion and Conversion]] diff --git a/doc/manual/cache/KeyPgTypeof.wakka b/doc/manual/cache/KeyPgTypeof.wakka index a1736b8159..9a5e7db98d 100644 --- a/doc/manual/cache/KeyPgTypeof.wakka +++ b/doc/manual/cache/KeyPgTypeof.wakka @@ -16,7 +16,6 @@ Returns the type of a variable. ##**Typeof**## also supports passing any intrinsic data type, or user-defined type, not only variables defined as those types. Also supported are expressions, the type is inferred from the expression (much like ##[[KeyPgVar|Var]]##). When a variable from a given namespace is accessed with the namespace's name prefix, wrap the argument to ##**Typeof**## with parentheses to force it to be seen as an expression. For example ##Typeof((namespace_name.variable))##. - If there is both a user defined type and a variable visible with the same name in the current scope, the user defined type takes precedence over the variable. To ensure that the ##**Typeof**## takes the variable instead of the user defined type, wrap the argument to ##**Typeof**## with parentheses to force it to be seen as an expression. For example ##Typeof((variable))##. diff --git a/doc/manual/cache/KeyPgVirtual.wakka b/doc/manual/cache/KeyPgVirtual.wakka index f0f48e5248..25cb945674 100644 --- a/doc/manual/cache/KeyPgVirtual.wakka +++ b/doc/manual/cache/KeyPgVirtual.wakka @@ -158,6 +158,8 @@ Sleep - ##[[KeyPgType|Type]]## - ##[[KeyPgObject|Object]]## - ##[[KeyPgExtends|Extends]]## + - ##[[KeyPgExtendsZstring|Extends Zstring]]## + - ##[[KeyPgExtendsWstring|Extends Wstring]]## - ##[[KeyPgAbstract|Abstract]]## - ##[[KeyPgOverride|Override]]## diff --git a/doc/manual/cache/KeyPgWstring.wakka b/doc/manual/cache/KeyPgWstring.wakka index f3300ef7f0..616a386f7e 100644 --- a/doc/manual/cache/KeyPgWstring.wakka +++ b/doc/manual/cache/KeyPgWstring.wakka @@ -19,6 +19,10 @@ Standard data type: wide character string The ""FreeBASIC"" text file functions can read and write Unicode files in different encodings, provided the ##[[KeyPgEncoding|encoding]]## is specified when the file is opened. The text is automatically converted to the internal encoding at read and converted back to the file encoding at write. ##[[KeyPgSizeof|sizeof]]##( ##**Wstring**## ) returns the number of bytes used by a ##**Wstring**## character in the current platform. + + When allocating dynamic memory for a ##**Wstring**##, the safest is to use ##[[KeyPgCallocate|Callocate]]## (or at worst, to use ##[[KeyPgAllocate|Allocate]]## followed by an immediate assignment of the string data, as in the second example), in order to avoid creating string data without any null character (the terminal character for a ##**Wstring**##). + + **Note :** When any operand of a binary operator (as assignment, equal, +, *, ...) consists in dereferencing a '##Wstring Ptr##' pointer ('##pw##'), this can give a '##Wstring##' string or a '##Numeric##' variable, depending on the other operand. If the other operand is numeric, so the dereferenced '##Wstring Ptr##' pointer ('##*pw##') will be treated as a '##Numeric##' reference to the one character pointed. If a '##Wstring##' pointer indexing '##[]##' operator is used as dereferencing syntax ('##pw[n]##'), it is basically a short-cut version of the '##String##' indexing '##[]##' operator ('##(*pw)[n]##'). {{fbdoc item="ex"}} {{fbdoc item="filename" value="examples/manual/datatype/wstring.bas"}}%%(freebasic) @@ -61,5 +65,6 @@ print len(*str2) 'returns 12, the length of the string it points to - ##[[KeyPgWoct|Woct]]## - ##[[KeyPgWinput|Winput()]]## - ##[[TblVarTypes|Standard Data Type Limits]]## + - ##[[KeyPgExtendsWstring|Extends Wstring]]## {{fbdoc item="back" value="CatPgStdDataTypes|Standard Data Types"}}{{fbdoc item="back" value="CatPgString|String Functions"}} \ No newline at end of file diff --git a/doc/manual/cache/KeyPgZstring.wakka b/doc/manual/cache/KeyPgZstring.wakka index 17a14ab264..fa0d0f38cd 100644 --- a/doc/manual/cache/KeyPgZstring.wakka +++ b/doc/manual/cache/KeyPgZstring.wakka @@ -19,7 +19,9 @@ Standard data type: 8 bit character string This type is provided for easy interfacing with C libraries and to also replace the fixed-length strings, that can't be managed through pointers. Any string type argument may be directly passed to a procedure referring to a parameter declared as ##**Zstring** [[KeyPgPtr|ptr]]##. The compiler performs itself an automatic conversion (without warning message) between any string type argument and the ##**Zstring** [[KeyPgPtr|ptr]]## type parameter. - **Note :** When any operand of a binary operator (as assignment, equal, +, *, ...) consists in dereferencing a '##Zstring Ptr##' pointer ('##pz##'), this can give a '##Zstring##' string or a '##Ubyte##' character, depending on the other operand. If the other operand is numeric, so the dereferenced '##Zstring Ptr##' pointer ('##*pz##') will be treated as a '##Ubyte##' reference to the one character pointed. If a '##Zstring##' pointer indexing '##[]##' operator is used as dereferencing syntax ('##pz[n]##'), it is basically a short-cut version of the '##String##' indexing '##[]##' operator ('##(*pz)[n]##'). + When allocating dynamic memory for a ##**Zstring**##, the safest is to use ##[[KeyPgCallocate|Callocate]]## (or at worst, to use ##[[KeyPgAllocate|Allocate]]## followed by an immediate assignment of the string data, as in the second example), in order to avoid creating string data without any null character (the terminal character for a ##**Zstring**##). + + **Note :** When any operand of a binary operator (as assignment, equal, +, *, ...) consists in dereferencing a '##Zstring Ptr##' pointer ('##pz##'), this can give a '##Zstring##' string or a '##Ubyte##' variable, depending on the other operand. If the other operand is numeric, so the dereferenced '##Zstring Ptr##' pointer ('##*pz##') will be treated as a '##Ubyte##' reference to the one character pointed. If a '##Zstring##' pointer indexing '##[]##' operator is used as dereferencing syntax ('##pz[n]##'), it is basically a short-cut version of the '##String##' indexing '##[]##' operator ('##(*pz)[n]##'). {{fbdoc item="ex"}} {{fbdoc item="filename" value="examples/manual/datatype/zstring.bas"}}%%(freebasic) @@ -47,5 +49,6 @@ print len(*str2) 'returns 12, the size of the string it contains - ##[[KeyPgString|String]]## - ##[[KeyPgWstring|Wstring]]## - ##[[TblVarTypes|Standard Data Type Limits]]## + - ##[[KeyPgExtendsZstring|Extends Zstring]]## {{fbdoc item="back" value="CatPgStdDataTypes|Standard Data Types"}}{{fbdoc item="back" value="CatPgString|String Functions"}} \ No newline at end of file diff --git a/doc/manual/cache/PrintToc.wakka b/doc/manual/cache/PrintToc.wakka index 58807971ea..c55843e08e 100644 --- a/doc/manual/cache/PrintToc.wakka +++ b/doc/manual/cache/PrintToc.wakka @@ -91,6 +91,11 @@ [[KeyPgMetaLang|$LANG]] [[KeyPgMetaStatic|$STATIC]] + {{fbdoc item="subsect" value="?"}} + [[KeyPgPrint|? (Shortcut for 'PRINT')]] + [[KeyPgPrintPp|? # (Shortcut for 'PRINT #')]] + [[KeyPgPrintusing|? USING (Shortcut for 'PRINT USING')]] + {{fbdoc item="subsect" value="A"}} [[KeyPgAbs|ABS]] [[KeyPgAbstract|ABSTRACT (member)]] @@ -417,17 +422,14 @@ [[KeyPgPmap|PMAP]] [[KeyPgPoint|POINT]] [[KeyPgPointCoord|POINTCOORD]] - [[KeyPgPointer|POINTER]] + [[KeyPgPtr|POINTER]] [[KeyPgPoke|POKE]] [[KeyPgPos|POS]] [[KeyPgPreserve|PRESERVE]] [[KeyPgPreset|PRESET]] [[KeyPgPrint|PRINT]] - [[KeyPgPrint|?]] [[KeyPgPrintPp|PRINT #]] - [[KeyPgPrintPp|? #]] [[KeyPgPrintusing|PRINT USING]] - [[KeyPgPrintusing|? USING]] [[KeyPgPrivate|PRIVATE]] [[KeyPgVisPrivate|PRIVATE: (Access Control)]] [[KeyPgOpProcptr|PROCPTR]] @@ -435,7 +437,7 @@ [[KeyPgVisProtected|PROTECTED: (Access Control)]] [[KeyPgPset|PSET (Statement)]] [[KeyPgPsetGfx|PSET (Graphics PUT)]] - [[KeyPgPtr|PTR]] + [[KeyPgPtr|PTR (Shortcut for 'POINTER')]] [[KeyPgPublic|PUBLIC]] [[KeyPgVisPublic|PUBLIC: (Access Control)]] [[KeyPgPutgraphics|PUT (Graphics)]] diff --git a/doc/manual/cache/ProPgLiterals.wakka b/doc/manual/cache/ProPgLiterals.wakka index c140cd9812..eb9ab5c022 100644 --- a/doc/manual/cache/ProPgLiterals.wakka +++ b/doc/manual/cache/ProPgLiterals.wakka @@ -63,11 +63,11 @@ Dim d as ulongint = &b1010101ULL %% {{fbdoc item="section" value="Floating Point Literals"}} - Floating point numbers are specified in decimal digits, may be positive or negative, have a fractional portion, and optionally an exponent. The format of a floating point literal is as follows: + Floating point numbers are specified in decimal digits, may be positive or negative, have a fractional portion, and optionally an exponent. The format of a floating point literal is as follows (without space or parenthesis added): - ##""number[.[fraction]][((D|E) [+|-] exponent)|(D|E)|][suffix]""## + ##""number[.[fraction]][(D|E)[+|-][exponent]][suffix]""## //or// - ##"".fraction[((D|E) [+|-] exponent)|(D|E)|][suffix]""## + ##"".fraction[(D|E)[+|-][exponent]][suffix]""## By default, floating point numbers that do not have either an exponent or a suffix are considered as a double precision floating point value, except in the //[[CompilerOptlang|-lang qb]]// dialect, where numbers of 7 digits or fewer are considered to be single precision. {{fbdoc item="filename" value="examples/manual/proguide/literals/floats.bas"}}%%(freebasic) @@ -76,7 +76,7 @@ Dim b as double = -123.0 %% The letter "##D##" or "##E##", placed after the number/fraction part, allows the number to be given an exponent. The exponent may be specified as either positive or negative with a plus ("##+##") or minus ("##-##") sign. Exponents that do not have a sign are positive. - An exponent is not required after the letter, so the letter can be used on its own just to specify the type. "##D##" specifies a double-precision floating-point number. "##E##" specifies a floating-point number using the default precision. When the letter is used on its own in combination with a suffix (see below) the type denoted by the suffix overrules the type specified by the letter. + An exponent value is not required after the letter (or even after the sign), so the letter can be used on its own just to specify the type. "##D##" specifies a double-precision floating-point number. "##E##" specifies a floating-point number using the default precision. When the letter is used on its own in combination with a suffix (see below) the type denoted by the suffix overrules the type specified by the letter. {{fbdoc item="filename" value="examples/manual/proguide/literals/dblsuff.bas"}}%%(freebasic) Dim a as double = -123.0d diff --git a/doc/manual/cache/ProPgPointers.wakka b/doc/manual/cache/ProPgPointers.wakka index 9275a75695..3bd3e16dab 100644 --- a/doc/manual/cache/ProPgPointers.wakka +++ b/doc/manual/cache/ProPgPointers.wakka @@ -2,7 +2,7 @@ Data types whose values are addresses in memory. {{fbdoc item="section" value="Declaration"}} - Pointers are [[ProPgVariables|Variables]] whose values are addresses in memory, and they are said to 'point' to this memory. The type of data that is pointed to depends on the type of pointer (an ##[[KeyPgInteger|Integer]] [[KeyPgPointer|Pointer]]## points to ##[[KeyPgInteger|Integer]]## data). Pointers are declared like any other variable, with the suffix "##pointer##" or "##ptr##" following the type name. + Pointers are [[ProPgVariables|Variables]] whose values are addresses in memory, and they are said to 'point' to this memory. The type of data that is pointed to depends on the type of pointer (an ##[[KeyPgInteger|Integer]] [[KeyPgPtr|Pointer]]## points to ##[[KeyPgInteger|Integer]]## data). Pointers are declared like any other variable, with the suffix "##pointer##" or "##ptr##" following the type name. {{fbdoc item="section" value="Assigning pointer variables"}} A pointer is a memory address and the value of the pointer itself is that memory address. To assign a pointer variable is to assign it a memory address to something. One way to assign a pointer a memory address is to take the address of some other variable in the program using ##[[KeyPgOpAt|Operator @]]## (Address of). diff --git a/doc/manual/cache/ProPgProcedurePointers.wakka b/doc/manual/cache/ProPgProcedurePointers.wakka index 729bee8705..afd6476f11 100644 --- a/doc/manual/cache/ProPgProcedurePointers.wakka +++ b/doc/manual/cache/ProPgProcedurePointers.wakka @@ -163,7 +163,7 @@ Delete Cptr(B Ptr, pab) {{fbdoc item="see"}} - ##[[KeyPgSub|Sub]]## - ##[[KeyPgFunction|Function]]## - - ##[[KeyPgPointer|Pointer]]## + - ##[[KeyPgPtr|Pointer]]## - ##[[KeyPgOpAt|Operator @ (Address of)]]## - ##[[KeyPgOpProcptr|ProcPtr operator]]## diff --git a/doc/manual/cache/ProPgPtrArithmetic.wakka b/doc/manual/cache/ProPgPtrArithmetic.wakka index 1fc2e0149c..7b3b008604 100644 --- a/doc/manual/cache/ProPgPtrArithmetic.wakka +++ b/doc/manual/cache/ProPgPtrArithmetic.wakka @@ -20,7 +20,7 @@ dim p as integer ptr = new integer[2] *p = 1 *(p + 1) = 2 %% - will assign the values "##1##" and "##2##" to each integer in the array pointer to by ##//p//##. Since ##//p//## is an ##[[KeyPgInteger|Integer]] [[KeyPgPointer|Pointer]]##, the expression "##*(p + 1)##" is saying to dereference an ##[[KeyPgInteger|Integer]]## four/eight (4/8 on 32/64bit systems) bytes from ##//p//##; the "##1##" indicates a distance of "##1 * the size of an [[KeyPgInteger|Integer]]##", or four/eight (4/8 on 32/64bit systems) bytes. + will assign the values "##1##" and "##2##" to each integer in the array pointer to by ##//p//##. Since ##//p//## is an ##[[KeyPgInteger|Integer]] [[KeyPgPtr|Pointer]]##, the expression "##*(p + 1)##" is saying to dereference an ##[[KeyPgInteger|Integer]]## four/eight (4/8 on 32/64bit systems) bytes from ##//p//##; the "##1##" indicates a distance of "##1 * the size of an [[KeyPgInteger|Integer]]##", or four/eight (4/8 on 32/64bit systems) bytes. Subtraction follows the exact same principle. Remember, //a// - //b// = //a// + -//b//. diff --git a/doc/manual/cache/TutPointersData.wakka b/doc/manual/cache/TutPointersData.wakka index 90bd1c69b8..7ae265a8a6 100644 --- a/doc/manual/cache/TutPointersData.wakka +++ b/doc/manual/cache/TutPointersData.wakka @@ -91,7 +91,7 @@ Deallocate aptr Sleep %%## -In this program we dimension two variables, an [[KeyPgInteger|integer]] and an [[KeyPgInteger|integer]] [[KeyPgPointer|pointer]], aptr. Aptr will point to our memory buffer that will contain two integers. The [[KeyPgAllocate|allocate]] function requires the size of the buffer we need, so we multiply the size of an [[KeyPgInteger|integer]] by 2 to reserve 8/16 bytes of memory (on 32/64bit systems, each integer will take 4/8 bytes of space (on 32/64bit systems). +In this program we dimension two variables, an [[KeyPgInteger|integer]] and an [[KeyPgInteger|integer]] [[KeyPgPtr|pointer]], aptr. Aptr will point to our memory buffer that will contain two integers. The [[KeyPgAllocate|allocate]] function requires the size of the buffer we need, so we multiply the size of an [[KeyPgInteger|integer]] by 2 to reserve 8/16 bytes of memory (on 32/64bit systems, each integer will take 4/8 bytes of space (on 32/64bit systems). After the allocation process, aptr contains the address of the first byte of our memory buffer. Storing the first integer is simply a matter of using the dereference operator and setting the value to 1. To print out the value, we again just use *aptr. From e5f4728885b35c8e78a9d5b0fb0d1395d126b6b3 Mon Sep 17 00:00:00 2001 From: coderJeff Date: Sat, 13 Jul 2019 15:38:15 -0400 Subject: [PATCH 4/5] fbdoc: update examples/manual from wiki --- examples/manual/check/KeyPgDim_2.bas | 7 +-- examples/manual/operator/let-list2.bas | 32 ++++++++++ examples/manual/udt/extendszstring1.bas | 36 ++++++++++++ examples/manual/udt/extendszstring2.bas | 77 +++++++++++++++++++++++++ 4 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 examples/manual/operator/let-list2.bas create mode 100644 examples/manual/udt/extendszstring1.bas create mode 100644 examples/manual/udt/extendszstring2.bas diff --git a/examples/manual/check/KeyPgDim_2.bas b/examples/manual/check/KeyPgDim_2.bas index 694104c4fd..e8197fecb8 100644 --- a/examples/manual/check/KeyPgDim_2.bas +++ b/examples/manual/check/KeyPgDim_2.bas @@ -10,13 +10,12 @@ '$lang: "qb" -'' All variables beginning with A through N default to the INTEGER data type -'' All other variables will default to the SINGLE data type +'' All variables beginning with A through N will default to the INTEGER data type +'' All other variables default to the SINGLE data type DefInt I-N +Dim I, J, X, Y, T$, D As Double '' I and J are INTEGERs '' X and Y are SINGLEs '' T$ is STRING '' D is DOUBLE - -Dim I, J, X, Y, T$, D As Double diff --git a/examples/manual/operator/let-list2.bas b/examples/manual/operator/let-list2.bas new file mode 100644 index 0000000000..db134f3a0b --- /dev/null +++ b/examples/manual/operator/let-list2.bas @@ -0,0 +1,32 @@ +'' examples/manual/operator/let-list2.bas +'' +'' NOTICE: This file is part of the FreeBASIC Compiler package and can't +'' be included in other distributions without authorization. +'' +'' See Also: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgOpLetlist +'' -------- + +Type Parent + Dim As Integer p1, p2 +End Type + +Type Child Extends Parent + Dim As Integer c1, c2 +End Type + +Type GrandChild Extends Child + Dim As Integer gc1, gc2 +End Type + +Dim As GrandChild gc = Type(1, 2, 3, 4, 5, 6) + +Dim As Integer i1, i2 +Dim As Integer j1, j2 +Dim As Parent p +Dim As Child c + +Let(c, i1, i2) = gc +Print c.p1, c.p2, c.c1, c.c2, i1, i2 + +Let(p, j1, j2) = gc +Print p.p1, p.p2, j1, j2 diff --git a/examples/manual/udt/extendszstring1.bas b/examples/manual/udt/extendszstring1.bas new file mode 100644 index 0000000000..c2c087cedf --- /dev/null +++ b/examples/manual/udt/extendszstring1.bas @@ -0,0 +1,36 @@ +'' examples/manual/udt/extendszstring1.bas +'' +'' NOTICE: This file is part of the FreeBASIC Compiler package and can't +'' be included in other distributions without authorization. +'' +'' See Also: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgExtendsZstring +'' -------- + +Type myZstring Extends ZString + Public: + Declare Constructor (ByRef z As Const ZString = "") + Declare Operator Cast () ByRef As Const ZString + Declare Operator Let (ByRef z As Const ZString) + Private: + Dim As String s +End Type + +Constructor myZstring (ByRef z As Const ZString = "") + This.s = z +End Constructor + +Operator myZstring.Cast () ByRef As Const ZString + Return *StrPtr(This.s) +End Operator + +Operator myZstring.Let (ByRef z As Const ZString) + This.s = z +End Operator + +Dim As myZstring z = "FreeBASIC" +Print "'" & z & "'" + +z &= " compiler" +Print "'" & z & "'" + +Sleep diff --git a/examples/manual/udt/extendszstring2.bas b/examples/manual/udt/extendszstring2.bas new file mode 100644 index 0000000000..dd94e9519a --- /dev/null +++ b/examples/manual/udt/extendszstring2.bas @@ -0,0 +1,77 @@ +'' examples/manual/udt/extendszstring2.bas +'' +'' NOTICE: This file is part of the FreeBASIC Compiler package and can't +'' be included in other distributions without authorization. +'' +'' See Also: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgExtendsZstring +'' -------- + +Type vZstring Extends ZString + Public: + Declare Constructor (ByVal pz As Const ZString Ptr = 0) + Declare Operator Cast () ByRef As ZString + Declare Operator Let (ByVal pz As Const ZString Ptr) + Declare Operator [] (ByVal index As Integer) ByRef As UByte + Declare Destructor () + Private: + Dim As ZString Ptr p + Dim As UInteger l +End Type + +Constructor vZstring (ByVal pz As Const ZString Ptr = 0) + This.l = Len(*pz) + This.p = CAllocate(This.l + 1, SizeOf(ZString)) + *This.p = *pz +End Constructor + +Operator vZstring.Cast () ByRef As ZString + Return *This.p +End Operator + +Operator vZstring.Let (ByVal pz As Const ZString Ptr) + If This.l < Len(*pz) Then + Deallocate(This.p) + This.l = Len(*pz) + This.p = CAllocate(This.l + 1, SizeOf(ZString)) + End If + *This.p = *pz +End Operator + +Operator vZstring.[] (ByVal index As Integer) ByRef As UByte + Return This.p[index] +End Operator + +Destructor vZstring () + Deallocate(This.p) +End Destructor + +Operator Len (ByRef v As vZstring) As Integer + Return Len(Type(v)) '' found nothing better than this ('vZstring.l' being private) +End Operator + +Dim As vZstring v = "FreeBASIC" +Print "'" & v & "'", Len(v) + +Dim As ZString * 256 z +z = *StrPtr(v) '' 'error 24: Invalid data types' without 'Extends Zstring' +Print "'" & z & "'", Len(z) + +v &= Space(2) +Print "'" & v & "'", Len(v) +RSet v, "FreeBASIC" '' 'error 24: Invalid data types' without 'Extends Zstring' +Print "'" & v & "'", Len(v) '' ('Cast' must return a modifiable reference) + +Select Case v '' 'error 24: Invalid data types' without 'Extends Zstring' +Case Type(Trim(v) & " ") + Print "Left justified" +Case Type(" " & Trim(v)) + Print "Right justified" +End Select + +v[0] = Asc("-") +Print "'" & v & "'", Len(v) + +'Print "'" & Right(v, 5) & "'" '' 'Right' does not yet support types with 'Extends Zstring' +Print "'" & Right(Str(v), 5) & "'" '' workaround + +Sleep From db0b8340ea9b90c5d11bfc1a0df94b57c53c24a7 Mon Sep 17 00:00:00 2001 From: coderJeff Date: Sat, 13 Jul 2019 16:13:12 -0400 Subject: [PATCH 5/5] fbdoc: wiki snapshot 2019-07-13 --- doc/manual/cache/CatPgCompOpt.wakka | 16 +++++++++++-- doc/manual/cache/CompilerCmdLine.wakka | 2 +- doc/manual/cache/CompilerOptearray.wakka | 20 ++++++++++++++++ doc/manual/cache/CompilerOpteassert.wakka | 22 +++++++++++++++++ doc/manual/cache/CompilerOptedebug.wakka | 25 ++++++++++++++++++++ doc/manual/cache/CompilerOptedebuginfo.wakka | 20 ++++++++++++++++ doc/manual/cache/CompilerOptelocation.wakka | 22 +++++++++++++++++ doc/manual/cache/CompilerOptenullptr.wakka | 20 ++++++++++++++++ doc/manual/cache/CompilerOptexx.wakka | 7 +++++- doc/manual/cache/CompilerOptg.wakka | 16 +++++++++++-- doc/manual/cache/DevDebuggingFb.wakka | 2 +- doc/manual/cache/KeyPgAssert.wakka | 10 ++++---- doc/manual/cache/KeyPgDdfbdebug.wakka | 7 ++++-- doc/manual/cache/KeyPgDdfberr.wakka | 8 +++++-- 14 files changed, 182 insertions(+), 15 deletions(-) create mode 100644 doc/manual/cache/CompilerOptearray.wakka create mode 100644 doc/manual/cache/CompilerOpteassert.wakka create mode 100644 doc/manual/cache/CompilerOptedebug.wakka create mode 100644 doc/manual/cache/CompilerOptedebuginfo.wakka create mode 100644 doc/manual/cache/CompilerOptelocation.wakka create mode 100644 doc/manual/cache/CompilerOptenullptr.wakka diff --git a/doc/manual/cache/CatPgCompOpt.wakka b/doc/manual/cache/CatPgCompOpt.wakka index 9102796824..1267aaab28 100644 --- a/doc/manual/cache/CatPgCompOpt.wakka +++ b/doc/manual/cache/CatPgCompOpt.wakka @@ -23,10 +23,22 @@ Command line compiler options for the fbc compiler: - Create a DLL, including the import library {{fbdoc item="keyword" value="CompilerOpte|-e"}} - Add error checking + {{fbdoc item="keyword" value="CompilerOptearray|-earray"}} + - Enable array bounds checking + {{fbdoc item="keyword" value="CompilerOpteassert|-eassert"}} + - Enable assert() and assertwarn() checking + {{fbdoc item="keyword" value="CompilerOptedebug|-edebug"}} + - Enable ##[[KeyPgDdfbdebug|__FB_DEBUG__]]## + {{fbdoc item="keyword" value="CompilerOptedebuginfo|-edebuginfo"}} + - Add debug information + {{fbdoc item="keyword" value="CompilerOptelocation|-elocation"}} + - Enable full error location reporting + {{fbdoc item="keyword" value="CompilerOptenullptr|-enullptr"}} + - Enable null-pointer checking {{fbdoc item="keyword" value="CompilerOptex|-ex"}} - Add error checking with RESUME support {{fbdoc item="keyword" value="CompilerOptexx|-exx"}} - - Same as -ex, plus array bounds and non-null-pointer checking + - Same as -ex, plus array bounds, null-pointer, and error location reporting {{fbdoc item="keyword" value="CompilerOptexport|-export"}} - Export symbols for dynamic linkage {{fbdoc item="keyword" value="CompilerOptforcelang|-forcelang "}} @@ -36,7 +48,7 @@ Command line compiler options for the fbc compiler: {{fbdoc item="keyword" value="CompilerOptfpu|-fpu < type >"}} - Set the floating point arithmetics unit (default: FPU) {{fbdoc item="keyword" value="CompilerOptg|-g"}} - - Add debug info + - Add debug info, enable""##__FB_DEBUG__##"", and enable asserts {{fbdoc item="keyword" value="CompilerOptgen|-gen < backend >"}} - Sets the compiler backend (default is 'gas') {{fbdoc item="keyword" value="CompilerOpti|-i < name >"}} diff --git a/doc/manual/cache/CompilerCmdLine.wakka b/doc/manual/cache/CompilerCmdLine.wakka index 334850b1fa..3a418ecd04 100644 --- a/doc/manual/cache/CompilerCmdLine.wakka +++ b/doc/manual/cache/CompilerCmdLine.wakka @@ -72,7 +72,7 @@ Using the **fbc** command-line. =={{fbdoc item="keyword" value="CompilerOptex|-ex"}}== Add error checking with RESUME support =={{fbdoc item="keyword" value="CompilerOptexx|-exx"}}== - Same as ##-ex##, plus array bounds and non-null-pointer checking + Same as ##-ex##, plus array bounds, null-pointer, and error location reporting =={{fbdoc item="keyword" value="CompilerOptWa|-Wa < opt >"}}== Pass options to GAS (separated by commas) =={{fbdoc item="keyword" value="CompilerOptWc|-Wc < opt >"}}== diff --git a/doc/manual/cache/CompilerOptearray.wakka b/doc/manual/cache/CompilerOptearray.wakka new file mode 100644 index 0000000000..f7900738f0 --- /dev/null +++ b/doc/manual/cache/CompilerOptearray.wakka @@ -0,0 +1,20 @@ +{{fbdoc item="title" value="Compiler Option: -earray"}}---- +Enable array bounds checking + +{{fbdoc item="syntax"}}## + **-earray** +## +{{fbdoc item="desc"}} + Add array bounds error checking in generated run-time code. A run-time error is generated if an array index attempts to access an array element that is outside the bounds of the array. + + ##**-earray**## is automatically implied by the ##[[CompilerOptexx|-exx]]## option. + + ##[[KeyPgDdfberr|__FB_ERR__]]## can be used to determine in user source code if the ##**-earray**## option was specified or implied on the command line. + +{{fbdoc item="see"}} + - ##[[KeyPgDdfberr|__FB_ERR__]]## + - [[CompilerOptexx|Compiler Option: -exx]] + - [[ProPgErrorHandling|Error Handling]] + - [[CompilerCmdLine|Using the Command Line]] + +{{fbdoc item="back" value="CatPgCompOpt|Compiler Options"}} \ No newline at end of file diff --git a/doc/manual/cache/CompilerOpteassert.wakka b/doc/manual/cache/CompilerOpteassert.wakka new file mode 100644 index 0000000000..40bd2e240b --- /dev/null +++ b/doc/manual/cache/CompilerOpteassert.wakka @@ -0,0 +1,22 @@ +{{fbdoc item="title" value="Compiler Option: -eassert"}}---- +Enable ##assert()## and ##assertwarn()## checking + +{{fbdoc item="syntax"}}## + **-eassert** +## +{{fbdoc item="desc"}} + The ##-eassert## compiler option enables ##[[KeyPgAssert|Assert]]## and ##[[KeyPgAssertwarn|AssertWarn]]## code generation. + + ##**-eassert**## is automatically implied by the ##[[CompilerOptg|-g]]## option. + + ##[[KeyPgDdfberr|__FB_ERR__]]## can be used to determine in user source code if the ##**-eassert**## option was specified or implied on the command line. + +{{fbdoc item="see"}} + - ##[[KeyPgDdfberr|__FB_ERR__]]## + - ##[[KeyPgAssert|Assert]]## + - ##[[KeyPgAssertwarn|AssertWarn]]## + - [[CompilerOptg|Compiler Option: -g]] + - [[DebuggerRunning|Debugging]] + - [[CompilerCmdLine|Using the Command Line]] + +{{fbdoc item="back" value="CatPgCompOpt|Compiler Options"}} \ No newline at end of file diff --git a/doc/manual/cache/CompilerOptedebug.wakka b/doc/manual/cache/CompilerOptedebug.wakka new file mode 100644 index 0000000000..ad928f5b13 --- /dev/null +++ b/doc/manual/cache/CompilerOptedebug.wakka @@ -0,0 +1,25 @@ +{{fbdoc item="title" value="Compiler Option: -edebug"}}---- +Enable ##""__FB_DEBUG__""## + +{{fbdoc item="syntax"}}## + **-edebug** +## +{{fbdoc item="desc"}} + The ##**-edebug**## compiler option defines the intrinsic macro ##[[KeyPgDdfbdebug|__FB_DEBUG__]]## to enable user debug code. + + The intrinsic macro ##[[KeyPgDdfbdebug|__FB_DEBUG__]]## is set to non-zero (-1) if the option was specified, and set to zero (0) otherwise. + + ##**-edebug**## is automatically implied by the ##[[CompilerOptg|-g]]## option. + + ##[[KeyPgDdfberr|__FB_ERR__]]## can be used to determine in user source code if the ##**-edebug**## option was specified or implied on the command line. + +{{fbdoc item="see"}} + - ##[[KeyPgDdfbdebug|__FB_DEBUG__]]## + - ##[[KeyPgDdfberr|__FB_ERR__]]## + - [[CompilerOpteassert|Compiler Option: -eassert]] + - [[CompilerOptedebuginfo|Compiler Option: -debuginfo]] + - [[CompilerOptg|Compiler Option: -g]] + - [[DebuggerRunning|Debugging]] + - [[CompilerCmdLine|Using the Command Line]] + +{{fbdoc item="back" value="CatPgCompOpt|Compiler Options"}} \ No newline at end of file diff --git a/doc/manual/cache/CompilerOptedebuginfo.wakka b/doc/manual/cache/CompilerOptedebuginfo.wakka new file mode 100644 index 0000000000..422db99a71 --- /dev/null +++ b/doc/manual/cache/CompilerOptedebuginfo.wakka @@ -0,0 +1,20 @@ +{{fbdoc item="title" value="Compiler Option: -edebuginfo"}}---- +Add debug information + +{{fbdoc item="syntax"}}## + **-edebuginfo** +## +{{fbdoc item="desc"}} + The ##**-edebuginfo**## compiler inserts debugging symbols into output files, to use with GDB-compatible debuggers. + + ##**-edebuginfo**## is automatically implied by the ##[[CompilerOptg|-g]]## option. + + ##[[KeyPgDdfberr|__FB_ERR__]]## can be used to determine in user source code if the ##**-edebugingo**## option was specified or implied on the command line. + +{{fbdoc item="see"}} + - ##[[KeyPgDdfberr|__FB_ERR__]]## + - [[CompilerOptg|Compiler Option: -g]] + - [[DebuggerRunning|Debugging]] + - [[CompilerCmdLine|Using the Command Line]] + +{{fbdoc item="back" value="CatPgCompOpt|Compiler Options"}} \ No newline at end of file diff --git a/doc/manual/cache/CompilerOptelocation.wakka b/doc/manual/cache/CompilerOptelocation.wakka new file mode 100644 index 0000000000..8d9faa4b27 --- /dev/null +++ b/doc/manual/cache/CompilerOptelocation.wakka @@ -0,0 +1,22 @@ +{{fbdoc item="title" value="Compiler Option: -elocation"}}---- +Enable full error location reporting + +{{fbdoc item="syntax"}}## + **-elocation** +## +{{fbdoc item="desc"}} + The ##**-elocation**## compiler option enables full location reporting in run-time code generation. + + ##**-elocation**## is automatically implied by the ##[[CompilerOptexx|-exx]]## option. + + ##[[KeyPgDdfberr|__FB_ERR__]]## can be used to determine in user source code if the ##**-elocation**## option was specified or implied on the command line. + + //Note: the intent of this option is for a future fbc feature to optimize out some of the error tracking code associated with error location reporting. When implemented, only ##-exx## or ##-elocation## will enable the full error location reporting and will be optimized away otherwise.// + +{{fbdoc item="see"}} + - ##[[KeyPgDdfberr|__FB_ERR__]]## + - [[CompilerOptexx|Compiler Option: -exx]] + - [[ProPgErrorHandling|Error Handling]] + - [[CompilerCmdLine|Using the Command Line]] + +{{fbdoc item="back" value="CatPgCompOpt|Compiler Options"}} \ No newline at end of file diff --git a/doc/manual/cache/CompilerOptenullptr.wakka b/doc/manual/cache/CompilerOptenullptr.wakka new file mode 100644 index 0000000000..2f39b1fc83 --- /dev/null +++ b/doc/manual/cache/CompilerOptenullptr.wakka @@ -0,0 +1,20 @@ +{{fbdoc item="title" value="Compiler Option: -enullptr"}}---- +Enable null-pointer checking + +{{fbdoc item="syntax"}}## + **-enullptr** +## +{{fbdoc item="desc"}} + The ##-enullptr## compiler option enables null-pointer error checking in run-time code generation. A run-time error is generated if an attempt is made to dereference a null-pointer to a value, or call a null function pointer. + + ##**-enullptr**## is automatically implied by the ##[[CompilerOptexx|-exx]]## option. + + ##[[KeyPgDdfberr|__FB_ERR__]]## can be used to determine in user source code if the ##**-enullptr**## option was specified or implied on the command line. + +{{fbdoc item="see"}} + - ##[[KeyPgDdfberr|__FB_ERR__]]## + - [[CompilerOptexx|Compiler Option: -exx]] + - [[ProPgErrorHandling|Error Handling]] + - [[CompilerCmdLine|Using the Command Line]] + +{{fbdoc item="back" value="CatPgCompOpt|Compiler Options"}} \ No newline at end of file diff --git a/doc/manual/cache/CompilerOptexx.wakka b/doc/manual/cache/CompilerOptexx.wakka index 84f2eff479..b2dde24603 100644 --- a/doc/manual/cache/CompilerOptexx.wakka +++ b/doc/manual/cache/CompilerOptexx.wakka @@ -5,11 +5,16 @@ Add error checking with ##[[KeyPgResume|Resume]]## support and array bounds and **-exx** ## {{fbdoc item="desc"}} - The ##-exx## compiler option adds error checking with ##[[KeyPgResume|Resume]]## support, plus array bounds and non-null-pointer checking (including the procedure pointers). + The ##**-exx**## compiler option adds error checking with ##[[KeyPgResume|Resume]]## support, plus array bounds and null-pointer checking (including the procedure pointers). + + Use of the ##**-exx**## option automatically implies ##-e##, ##-exx##, ##-earray##, ##-elocation##, and ##-enullptr##, error checking and code generation options. {{fbdoc item="see"}} - ##[[KeyPgDdfberr|__FB_ERR__]]## - [[CompilerOpte|Compiler Option: -e]] + - [[CompilerOptearray|Compiler Option: -earray]] + - [[CompilerOptelocation|Compiler Option: -elocation]] + - [[CompilerOptenullptr|Compiler Option: -enullptr]] - [[CompilerOptex|Compiler Option: -ex]] - [[ProPgErrorHandling|Error Handling]] - [[CompilerCmdLine|Using the Command Line]] diff --git a/doc/manual/cache/CompilerOptg.wakka b/doc/manual/cache/CompilerOptg.wakka index c8856d3a75..8a7276d34b 100644 --- a/doc/manual/cache/CompilerOptg.wakka +++ b/doc/manual/cache/CompilerOptg.wakka @@ -1,16 +1,28 @@ {{fbdoc item="title" value="Compiler Option: -g"}}---- -Add debug information +Add debug information, define ##""__FB_DEBUG__""##, and enable asserts {{fbdoc item="syntax"}}## **-g** ## {{fbdoc item="desc"}} - The ##-g## compiler option inserts debugging symbols into output files, to use with GDB-compatible debuggers. + The ##**-g**## compiler option inserts debugging symbols into output files, to use with GDB-compatible debuggers. The intrinsic macro ##[[KeyPgDdfbdebug|__FB_DEBUG__]]## is set to non-zero (-1) if the option was specified, and set to zero (0) otherwise. + + ##[[KeyPgAssert|Assert]]## and ##[[KeyPgAssertwarn|AssertWarn]]## macros are enabled. + + Use of ##**-g**## automatically implies ##[[CompilerOptedebug|-edebug]]##, ##[[CompilerOptedebuginfo|-edebuginfo]]##, and ##[[CompilerOpteassert|-eassert]]##, command line options. + + ##[[KeyPgDdfberr|__FB_ERR__]]## can be used to determine in user source code if the ##**-g**## option was specified or implied on the command line. {{fbdoc item="see"}} - ##[[KeyPgDdfbdebug|__FB_DEBUG__]]## + - ##[[KeyPgDdfberr|__FB_ERR__]]## + - ##[[KeyPgAssert|Assert]]## + - ##[[KeyPgAssertwarn|AssertWarn]]## + - [[CompilerOpteassert|Compiler Option: -eassert]] + - [[CompilerOptedebug|Compiler Option: -debug]] + - [[CompilerOptedebuginfo|Compiler Option: -debuginfo]] - [[DebuggerRunning|Debugging]] - [[CompilerCmdLine|Using the Command Line]] diff --git a/doc/manual/cache/DevDebuggingFb.wakka b/doc/manual/cache/DevDebuggingFb.wakka index 81fdd7f7cb..c34edcee08 100644 --- a/doc/manual/cache/DevDebuggingFb.wakka +++ b/doc/manual/cache/DevDebuggingFb.wakka @@ -1,6 +1,6 @@ {{fbdoc item="title" value="Debugging FB"}}---- -For debugging and development it's a good idea to build the compiler with -g and -exx to enable assertions, plus array boundary and non-null-pointer checks. For the rtlib/gfxlib2 code, -DDEBUG enables the assertions. Just update config.mk and (re)build. Example config.mk settings: +For debugging and development it's a good idea to build the compiler with -g and -exx to enable assertions, plus array boundary and null-pointer checks. For the rtlib/gfxlib2 code, -DDEBUG enables the assertions. Just update config.mk and (re)build. Example config.mk settings: %%FBFLAGS := -g -exx CFLAGS := -g -O0 -DDEBUG diff --git a/doc/manual/cache/KeyPgAssert.wakka b/doc/manual/cache/KeyPgAssert.wakka index 5218cff967..6722688a4a 100644 --- a/doc/manual/cache/KeyPgAssert.wakka +++ b/doc/manual/cache/KeyPgAssert.wakka @@ -12,11 +12,11 @@ Debugging macro that halts program execution if an expression is evaluated to ## Any valid conditional/numeric expression. If ##//expression//## evaluates to ##0## (i.e. "false"), execution is halted. {{fbdoc item="desc"}} - The ##**ASSERT**## macro is intended for use in debugging and works only if the ##-g## option is selected in the FBC command line. In this case it prints an error message and stops the program execution if ##//expression//## evaluates to ##0##. + The ##**ASSERT**## macro is intended for use in debugging and works only if the ##[[CompilerOpteassert|-g]]## or [[CompilerOpteassert|-eassert]]## option is specified on the ##fbc## command line. In this case it prints an error message and stops the program execution if ##//expression//## evaluates to ##0##. - Its normal use is to check the correct value of the variables during debugging. + Its normal use is to check the correct value of the variables or expressions during debugging. - If ##-g## is not passed to fbc, the macro does not generate any code, and has no effect. + If ##[[CompilerOpteassert|-g]]## and [[CompilerOpteassert|-eassert]]## are not passed to fbc, the macro does not generate any code, and has no effect. Note: If an ##**ASSERT**## fails while the program is in a graphics ##[[KeyPgScreengraphics|Screen]]##, the error message will not be visible as it will be printed to the graphics screen, which will be closed immediately after. @@ -30,7 +30,7 @@ end sub foo -'' If -g is used this code stops with: test.bas(3): assertion failed at FOO: a=1 +'' If -g or -eassert is used, this code stops with: test.bas(3): assertion failed at FOO: a=1 %% {{fbdoc item="lang"}} @@ -42,5 +42,7 @@ foo {{fbdoc item="see"}} - ##[[KeyPgPpassert|#assert]]## - ##[[KeyPgAssertwarn|ASSERTWARN]]## + - [[CompilerOpteassert|Compiler Option: -eassert]] + - [[CompilerOptg|Compiler Option: -g]] {{fbdoc item="back" value="CatPgMisc|Miscellaneous"}} \ No newline at end of file diff --git a/doc/manual/cache/KeyPgDdfbdebug.wakka b/doc/manual/cache/KeyPgDdfbdebug.wakka index 220fff3940..3d2842df02 100644 --- a/doc/manual/cache/KeyPgDdfbdebug.wakka +++ b/doc/manual/cache/KeyPgDdfbdebug.wakka @@ -5,9 +5,11 @@ Intrinsic define (macro value) set by the compiler ""__FB_DEBUG__"" ## {{fbdoc item="desc"}} - ##""__FB_DEBUG__""## indicates if the the generate debug information option '-g' was specified on the command line at the time of compilation. + ##""__FB_DEBUG__""## indicates if the the generate debug information option ##[[CompilerOptg|-g]]## or the enable intrinsic define ##""__FB_DEBUG__""## option ##[[CompilerOptedebug|Compiler Option: -edebug]]## was specified on the command line at the time of compilation. - Returns non-zero (-1) if the option was specified. Returns zero (0) otherwise. + Returns non-zero (-1) if either option was specified. Returns zero (0) otherwise. + + ##[[KeyPgDdfberr|__FB_ERR__]]## can be used to determine in user source code if the ##-g## or ##-edebug## option was specified or implied on the command line. {{fbdoc item="ex"}} {{fbdoc item="filename" value="examples/manual/defines/fbdebug.bas"}}%%(freebasic) @@ -24,6 +26,7 @@ Intrinsic define (macro value) set by the compiler {{fbdoc item="see"}} - ##[[KeyPgDdfberr|__FB_ERR__]]## - ##[[KeyPgDdfbmt|__FB_MT__]]## + - [[CompilerOptedebug|Compiler Option: -edebug]] - [[CompilerOptg|Compiler Option: -g]] {{fbdoc item="back" value="CatPgDddefines|Intrinsic Defines"}} \ No newline at end of file diff --git a/doc/manual/cache/KeyPgDdfberr.wakka b/doc/manual/cache/KeyPgDdfberr.wakka index 8ad10dcd04..c6e380510b 100644 --- a/doc/manual/cache/KeyPgDdfberr.wakka +++ b/doc/manual/cache/KeyPgDdfberr.wakka @@ -7,8 +7,12 @@ Intrinsic define (macro value) set by the compiler {{fbdoc item="desc"}} ##""__FB_ERR__""## indicates if //[[CompilerOpte|-e]]//, //[[CompilerOptex|-ex]]//, or //[[CompilerOptexx|-exx]]// was specified on the compiler command line at the time of compilation of a module. - Returns one of the following values: - {{table columns="2" cellpadding="1" cells="value;description;0;'-e', '-ex', '-exx' not specified;1;'-e' was specified;3;'-ex' was specified;7;'-exx' was specified"}} + ##""__FB_ERR__""## indicates if //[[CompilerOptearray|-earray]]//, //[[CompilerOptenullptr|-enullptr]]//, or //[[CompilerOptelocation|-elocation]]// was specified on the compiler command line, or implied by use of //[[CompilerOptexx|-exx]]//, at the time of compilation of a module. + + ##""__FB_ERR__""## indicates if //[[CompilerOptedebug|-edebug]]//, //[[CompilerOptedebuginfo|-edebuginfo]]//, or //[[CompilerOpteassert|-eassert]]// was specified on the compiler command line, or implied by use of //[[CompilerOptg|-g]]//, at the time of compilation of a module. + + Returns bit-wise ##OR## of the following values: + {{table columns="2" cellpadding="1" cells="value;description;0;'-e', '-ex', '-exx' and other error options not specified;1;'-e' was specified;3;'-ex' was specified (implies '-e');7;'-exx' was specified (implies '-e, -exx');8;'-earray' was specified (or implied by '-exx');16;'-enullptr' was specified (or implied by '-exx');32;'-eassert' was specified (or implied by '-g');64;'-edebuginfo' was specified (or implied by '-g');128;'-edebug' was specified (or implied by '-g');256;'-elocation' was specified (or implied by '-exx')"}} ##""__FB_ERR__""## is always defined.