Wiki improvements

Forum for discussion about the documentation project.
Post Reply
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Wiki improvements

Post by paul doe »

fxm wrote:Would some people be interested in such an article?
Certainly useful, yes.

I was thinking on publishing FreeBasic reference implementations for all the Object-Oriented Design Patterns proposed by the GoF, along with some other useful ones, for people interested in OOP. Can I do it in the 'Documentation' forum?
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Wiki improvements

Post by fxm »

Yes, you are free to create a new topic for your article in the documentation forum.
Then, I will add it to the articles index post.

If your article consists of several posts written one after the other, I advise you to indicate at the end of the last post in progress that the article is not yet finished and that no user must answer for the moment (otherwise, I could clean after, but brutally by removing the posts inserted by others).
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Wiki improvements

Post by paul doe »

fxm wrote:If your article consists of several posts written one after the other, I advise you to indicate at the end of the last post in progress that the article is not yet finished and that no user must answer for the moment (otherwise, I could clean after, but brutally by removing the posts inserted by others).
I was thinking of creating three topics: one for Creational patterns, one for Structural patterns, and one for Behavioral patterns. Then, in the opening post, publish a brief introduction on the topic, followed by the implementations on another post (I create the posts in another program that allows me to split them as needed, so don't worry about it). And then, discussion about the patterns might follow. Is this agreeable?
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Wiki improvements

Post by fxm »

paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Wiki improvements

Post by paul doe »

Very well. I'll work on it.
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Wiki improvements

Post by badidea »

I noticed that some of the 'FAQ pages' are quite outdated (https://freebasic.net/wiki/wikka.php?wakka=FaqPgWin32) or very minimal (https://freebasic.net/wiki/wikka.php?wakka=FaqPgLinux).
Would it be useful to update these pages, or can we assume that these pages aren't viewed much and instead direct people to the forum for questions?
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Wiki improvements

Post by badidea »

Wiki page https://freebasic.net/wiki/wikka.php?wakka=KeyPgAsc says asc returns ulong, this must be uinteger right?
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Wiki improvements

Post by fxm »

You are right for a [z]string, but not for a wstring (on Windows).
I will modify the documentation.
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Wiki improvements

Post by fxm »

badidea wrote:Wiki page https://freebasic.net/wiki/wikka.php?wakka=KeyPgAsc says asc returns ulong, this must be uinteger right?
fxm wrote:You are right for a [z]string, but not for a wstring (on Windows).
Can anyone check the two configurations (with [z]string and wstring) on ​​Linux?
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Wiki improvements

Post by badidea »

I'm getting confused now:

Code: Select all

dim as string * 2 myString = "x"
dim as zstring * 2 myZString = "y"
dim as wstring * 2 myWString = "z"

#print typeof("a")
#print typeof(myString)
#print typeof(myZString)
#print typeof(myWString)

#print typeof(asc("a"))
#print typeof(asc(myString))
#print typeof(asc(myZString))
#print typeof(asc(myWString))
Output FBC32/64 linux:

Code: Select all

ZSTRING * 2
STRING * 2
ZSTRING * 2
WSTRING * 2
UINTEGER
ULONG
ULONG
ULONG
I think I understand, asc("a") is converted to a constant. Like #print typeof(123)
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Wiki improvements

Post by Tourist Trap »

badidea wrote:
Edit:
I made some typos in my last tests. And what happened is that #print typeof(asc()) returns UINTEGER. Same with "a", with noticeable difference, no compilation error. If we use 123 in asc(123), then the result of #print is INTEGER (and a compilation error).

I think that the default ASC function returns UINTEGER, unless it matches some other overloaded versions. If the litteral is passed as a CHR(value), then ASC(CHR) is also of Uinteger type, as well as for WCHR.
Last edited by Tourist Trap on Jan 06, 2019 15:03, edited 2 times in total.
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Wiki improvements

Post by fxm »

On Win 10 64 and fbc (1.06) 32/64 bit, I get the same results than badidea on Linux:
- uinteger return type when passing a literal as argument,
- ulong return type when passing a variable as argument (string, zstring or wstring).

@admin,
- Is this return type difference between literal argument and variable argument desired for the function 'asc()''?
- What about these following sentences from documentation?
If str is a String or a ZString, the UByte value at that position is returned. This will be a 7-bit ASCII code, or even a 8-bit character value from some code-page, depending on the string data stored in str.

If str is a WString, the UShort (Windows) or ULong (Linux) value at that position is returned. This will be a 16bit value on Windows (WStrings use UTF16 there), or a 32bit value on Linux (WStrings use UTF32 there).
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Wiki improvements

Post by coderJeff »

I would say it depends on what you want to do with ASC() to decide if it is desirable or undesirable. Otherwise, I would guess it probably doesn't matter. For ASC("a"), not really passing a literal argument "a" to ASC() function; it's an alternative way of writing 97u. Therefore, ASC("a") itself is also a literal, not a function call. For ASC(variable), it is a function call, and ULONG is largest minimum size needed for all platforms & string types.

Does ASC seem wrong? It's a UBYTE, USHORT, or ULONG value returned in a ULONG result, if runtime. The new information would be to add the value is returned in UINTEGER result, if literal.

I think this code shows the all the uses. Also some that are not supported, in the comments. Plus string[index] types.

Code: Select all

const #print compile-time ASC literal (constant)
scope
	#print - all UINTEGER
	var n1 = 97u
	#print typeof( 97u )
	#print typeof( n1 )
	
	var c1 = asc( "a" )
	#print typeof( asc("a") )
	#print typeof( c1 )
	
	var n2 = &h3040u
	#print typeof( &h3040u )
	#print typeof( n2 )
	
	var c2 = asc( !"\u3040" )
	#print typeof( asc( !"\u3040" ) )
	#print typeof( c2 )

	const s as string = "a"
	'' const zstring * 2 = "a"           '' not supported
	'' const wstring * 2 =  !"\u3040"    '' not supported

	var c3 = asc( s )
	#print typeof( asc(s) )
	#print typeof( c1 )

end scope
#print

#print run-time ASC conversion (non-constant)
scope
	#print - all ULONG
	#print - same rtlib function return type on all targets 
	dim s as string = "a"
	dim z as zstring * 2 = "a"
	dim w as wstring * 2 = !"\u3040"

	var c1 = asc( s )
	#print typeof( asc(s) )
	#print typeof( c1 )
	
	var c2 = asc( z )
	#print typeof( asc(z) )
	#print typeof( c2 )

	var c3 = asc( w )
	#print typeof( asc(w) )
	#print typeof( c3 )
end scope
#print

#print compile-time string[index] (constant)
scope
	#print - not supported
	const s as string = "a"
	'' const zstring * 2 = "a"           '' not supported
	'' const wstring * 2 =  !"\u3040"    '' not supported

	'' var c1 = s[0]                     '' not supported
	'' #print typeof( s[0] )             '' not supported                              
	'' #print typeof( c1 )
end scope
#print

#print run-time string[index] (non-constant)
scope
	#print - UBYTE, USHORT, or ULONG
	#print - depends on string type 
	dim s as string = "a"
	dim z as zstring * 2 = "a"
	dim w as wstring * 2 = !"\u3040"

	var c1 = s[0]
	#print typeof( s[0] )
	#print typeof( c1 )
	
	var c2 = z[0]
	#print typeof( z[0] )
	#print typeof( c2 )

	var c3 = w[0]
	#print typeof( w[0] )
	#print typeof( c3 )
end scope
#print
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Wiki improvements

Post by fxm »

coderJeff wrote:The new information would be to add the value is returned in UINTEGER result, if literal.
Sentence added second in the "Return Value" paragraph of ASC documentation:
Return Value:
The raw character value stored at position in str.
If both str and position can be evaluated at compile time (like Asc("a") or Asc(chr(97)) or Asc("abc", 2) ...), the value is returned in a uinteger result, otherwise in a ulong result.
  • KeyPgAsc → fxm [Added a sentence when all arguments are evaluable at compile time]
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Wiki improvements

Post by badidea »

The wiki page on keyboard scancodes (https://freebasic.net/wiki/wikka.php?wakka=GfxScancodes), lists the following:

Code: Select all

'' Extra scancodes not compatible with DOS scancodes
SC_LWIN         &h7D
SC_RWIN         &h7E
SC_MENU         &h7F
When I run this:

Code: Select all

#include "fbgfx.bi"
print hex(fb.SC_LWIN)
print hex(fb.SC_RWIN)
print hex(fb.SC_MENU)
I get this however:

Code: Select all

5B
5C
5D
Error on wiki? Or with my linux FBC 1.05.0 version?
Post Reply