none
Did you find any trivia about Small Basic? RRS feed

  • Question

  • Vijaye wrote an article Did you know? for tips about Small Basic.  And I rewrote it as a TechNet Wiki article.  But today, I'd like to start this article for trivia about Small Basic.  These information is not so important but the facts of Small Basic.

    I found two trivia.

    1. You can create index "" into an array as following syntax.
      arry[""] = "data"
    2. You can't create index "" with following syntax.
      arry = "=data;"

    If you find any trivia, please post them to this thread.

    Thank you.


    Nonki Takahashi


    Wednesday, May 28, 2014 2:09 PM
    Moderator

Answers

  • I saw this colour setting a while ago, can be useful.

    Also for trivia, the SB compiler is smart enough to parse and complete the odd statement.

    GraphicsWindow.BrushColor = "Transparent 
    Shapes.AddEllipse(50, 50)

    I liked Vijae's tip on double clicking compiler errors. Can't wait to try that!

    That index tip Nonki could be useful.


    Thursday, May 29, 2014 8:29 AM
    Moderator
  • My third one.

    3. Comma is not needed between parameters of operations.

    GoToLoop found this trivia in http://social.msdn.microsoft.com/Forums/en-US/09714ba0-27c6-4777-b81c-c11778db6a64/string-to-array?forum=smallbasic .


    Nonki Takahashi

    Thursday, May 29, 2014 4:43 PM
    Moderator
  • I also remind the forth one.

    4.

    Small Basic has following compile error. 

    1,29: The variable 'a' is used, but its value is not assigned.  Are you sure you have spelled it correctly?

    But following code can be run.

    b = a
    a = 1

    The first 'a' is not assigned but is treated as null text "".

    ---

    I found that these trivia may be from lenient or tolerant behavior of Small Basic. 


    Nonki Takahashi

    Thursday, May 29, 2014 5:18 PM
    Moderator
  • @ JJ

    Sounds thrilling JJ, but i'm afraid there's less philosophical on that level in SB :-)

    SB does know what b IS:
    --------------------------------
    In your assignment  b ← b + 0 * b
    The (left) b is initialized by number/value 0,
    0 * whatuwant ->  always 0 again  and
    0 + ""  (0 + empty/nothing/nix/rien/nada/niente/"")  ->  stays the same 0, so finally b = 0.

    or

    b = "" + 0 * ""        ' SB treats the whole right term as a number, because of the 0  (similar to "" + 5 * ""  or  "" + "" * "" if you like)
    TextWindow.WriteLine(b)

    or

    anything = anything + 0 * anything
    TextWindow.WriteLine(anything)

    b = b    ' here b initially is empty/"" and is assigned to b, b ← b
    TextWindow.WriteLine("|"+b+"|")

    Trivias:

    1.) Shapes.AddText needs GW initialisation first

    ' GraphicsWindow.Show()
    Shapes.AddText("Some Text")    ' crashes if GW is not initialized anyhow before

    2.) In a String one can add (multiple) "" if not at start or end so that 3 " would be in serie (like """...), eg:
    TextWindow.WriteLine("String can contain (multiple) "" if "" are not at the beginning or end of string")

    3.) Ref. to Nonkis article Shapes.GetOpacity() Causes Cast Error:we can create (semi)transp Shapes with Opacity using GW.BrushColor = "#AARRGGBB"  (AA <> 0xFF). Only for Shapes that use GW.BrushColor and GW.PenColor, GW.PenWidth etc. (not exactly same as Opacity Method and can't not work for eg. Shapes.AddImage), like:

    ' GraphicsWindow.PenColor = "#7F6A5ACD"   '  or

    ' GraphicsWindow.PenWidth = 0   ' ... before

    GraphicsWindow.BrushColor = "#7F6A5ACD"    ' Semitransp. SlateBlue
    rect = Shapes.AddRectangle(100, 100)

    So Opacity for this kind of Shapes should be detectable by any GetShapeColor/GetPixelColor (?) Method, that returns a format like #AARRGGBB, from the #AA alpha value (where 0xFF = 255 = 100%). But did'nt find a similar useable function in all the Extension.xml 's so long. Would be a half workaround to crashing GetOpacity method. Maybe someone finds a suitable extension method for that.

    4.) Most of Shapes Methods also work for Controls and vice versa, like:

    Shapes.Animate(Controls.AddButton("Button",0,0), GraphicsWindow.Width, GraphicsWindow.Height, 5000)

    5.) sure more to come




    Saturday, May 31, 2014 11:52 AM
    Answerer
  • I reminded other trivia:

    5. Name (variable, subroutine, ...) started with _ doesn't appear in intellisense list.  I read this one somewhere.

    6. The same name can be used for all variable subroutine and label as different ones.


    Nonki Takahashi

    Thursday, June 5, 2014 3:35 PM
    Moderator
  • It works if you have a syntax error when you try to run the program.

    It doesn't worh if you have an exception e.g. divide by 0


    Jan [ WhTurner ] The Netherlands


    Oh, I reminded another one.

    7. Dividing by 0 becomes 0.


    Nonki Takahashi

    Thursday, June 5, 2014 3:41 PM
    Moderator

All replies

  • I saw this colour setting a while ago, can be useful.

    Also for trivia, the SB compiler is smart enough to parse and complete the odd statement.

    GraphicsWindow.BrushColor = "Transparent 
    Shapes.AddEllipse(50, 50)

    I liked Vijae's tip on double clicking compiler errors. Can't wait to try that!

    That index tip Nonki could be useful.


    Thursday, May 29, 2014 8:29 AM
    Moderator
  • My third one.

    3. Comma is not needed between parameters of operations.

    GoToLoop found this trivia in http://social.msdn.microsoft.com/Forums/en-US/09714ba0-27c6-4777-b81c-c11778db6a64/string-to-array?forum=smallbasic .


    Nonki Takahashi

    Thursday, May 29, 2014 4:43 PM
    Moderator
  • I saw this colour setting a while ago, can be useful.

    Also for trivia, the SB compiler is smart enough to parse and complete the odd statement.

    GraphicsWindow.BrushColor = "Transparent 
    Shapes.AddEllipse(50, 50)

    I liked Vijae's tip on double clicking compiler errors. Can't wait to try that!

    That index tip Nonki could be useful.



    Not need to close " ... Wow!

    Nonki Takahashi

    Thursday, May 29, 2014 4:46 PM
    Moderator
  • I also remind the forth one.

    4.

    Small Basic has following compile error. 

    1,29: The variable 'a' is used, but its value is not assigned.  Are you sure you have spelled it correctly?

    But following code can be run.

    b = a
    a = 1

    The first 'a' is not assigned but is treated as null text "".

    ---

    I found that these trivia may be from lenient or tolerant behavior of Small Basic. 


    Nonki Takahashi

    Thursday, May 29, 2014 5:18 PM
    Moderator
  • b = b+b*0
    TextWindow.WriteLine(b)

    lol

    SB doesn't know what b IS or ISN'T.

    Yet if I ask it to multiply it by anything it tells me that is a value of zero. Who told it that?

    So nothing has a value of zero? But not always! Sometimes NOTHING = NOTHING

    TextWindow.WriteLine(b)
    b = a
    a = b

    5 * nothing = 0  NOT nothing

    Does zero trump nothing?  How?  Nothing could be something. We just don't know.


    Thursday, May 29, 2014 9:17 PM
    Moderator
  • from the  Did you know?  thread:

    "* Double clicking on the compiler errors will take you to the actual error."

    I couldn't get it to respond to a dbl click.

    Where do you click and does this work for SB 1.0?


    This would be a top feature!



    Saturday, May 31, 2014 10:03 AM
    Moderator
  • It works if you have a syntax error when you try to run the program.

    It doesn't worh if you have an exception e.g. divide by 0


    Jan [ WhTurner ] The Netherlands


    Saturday, May 31, 2014 10:16 AM
    Answerer
  • @ JJ

    Sounds thrilling JJ, but i'm afraid there's less philosophical on that level in SB :-)

    SB does know what b IS:
    --------------------------------
    In your assignment  b ← b + 0 * b
    The (left) b is initialized by number/value 0,
    0 * whatuwant ->  always 0 again  and
    0 + ""  (0 + empty/nothing/nix/rien/nada/niente/"")  ->  stays the same 0, so finally b = 0.

    or

    b = "" + 0 * ""        ' SB treats the whole right term as a number, because of the 0  (similar to "" + 5 * ""  or  "" + "" * "" if you like)
    TextWindow.WriteLine(b)

    or

    anything = anything + 0 * anything
    TextWindow.WriteLine(anything)

    b = b    ' here b initially is empty/"" and is assigned to b, b ← b
    TextWindow.WriteLine("|"+b+"|")

    Trivias:

    1.) Shapes.AddText needs GW initialisation first

    ' GraphicsWindow.Show()
    Shapes.AddText("Some Text")    ' crashes if GW is not initialized anyhow before

    2.) In a String one can add (multiple) "" if not at start or end so that 3 " would be in serie (like """...), eg:
    TextWindow.WriteLine("String can contain (multiple) "" if "" are not at the beginning or end of string")

    3.) Ref. to Nonkis article Shapes.GetOpacity() Causes Cast Error:we can create (semi)transp Shapes with Opacity using GW.BrushColor = "#AARRGGBB"  (AA <> 0xFF). Only for Shapes that use GW.BrushColor and GW.PenColor, GW.PenWidth etc. (not exactly same as Opacity Method and can't not work for eg. Shapes.AddImage), like:

    ' GraphicsWindow.PenColor = "#7F6A5ACD"   '  or

    ' GraphicsWindow.PenWidth = 0   ' ... before

    GraphicsWindow.BrushColor = "#7F6A5ACD"    ' Semitransp. SlateBlue
    rect = Shapes.AddRectangle(100, 100)

    So Opacity for this kind of Shapes should be detectable by any GetShapeColor/GetPixelColor (?) Method, that returns a format like #AARRGGBB, from the #AA alpha value (where 0xFF = 255 = 100%). But did'nt find a similar useable function in all the Extension.xml 's so long. Would be a half workaround to crashing GetOpacity method. Maybe someone finds a suitable extension method for that.

    4.) Most of Shapes Methods also work for Controls and vice versa, like:

    Shapes.Animate(Controls.AddButton("Button",0,0), GraphicsWindow.Width, GraphicsWindow.Height, 5000)

    5.) sure more to come




    Saturday, May 31, 2014 11:52 AM
    Answerer
  • Thanks pl.  Fascinating!  I look forward to learning more about compiling and interpreting.

    With the Shapes thing. It's like the shape needs something to "target" i.e. the gw

    Saturday, May 31, 2014 12:21 PM
    Moderator
  • b = b
    TextWindow.WriteLine(b)

    Now b is Nothing And b.

    It's nothing because it returns nothing.

    Nothing is something. That something is nothing.

    b = b
    TextWindow.WriteLine(b)

    If b = "" Then
      TextWindow.WriteLine("True")
    EndIf

    What is nothing b is

    I think it's logical that nothing is something.
    Saturday, May 31, 2014 12:26 PM
    Moderator
  • It's like computers deal with dark matter and the space grid.
    Saturday, May 31, 2014 12:38 PM
    Moderator
  • Would like to see how a roman Computer would have worked :-? (just kiddin') as they didn't have the 0 then: viii, ix, X (dec. 10 ?), xi, xii, .. So the nothing (0) is more important than it might seem. And yes: all is something :-)

    Saturday, May 31, 2014 1:22 PM
    Answerer
  • It works if you have a syntax error when you try to run the program.

    It doesn't worh if you have an exception e.g. divide by 0


    Jan [ WhTurner ] The Netherlands


    Yes, a syntax error is something like:

    Sorry, we found some errors...
    3,22: The vairable 'a' is used, but its value is not assigned.  Are you sure to have spelled it correctly?


    Nonki Takahashi

    Monday, June 2, 2014 2:14 PM
    Moderator
  • Thanks Jan & Nonki.

    Just tried it and it worked. That's good trivia!

    They could've put an instruction in like: "Double click to go to the error".

    Now I know there's a difference b/w "compiler error" and "exception"

    Monday, June 2, 2014 3:03 PM
    Moderator
  • @ JJ

    Sounds thrilling JJ, but i'm afraid there's less philosophical on that level in SB :-)

    SB does know what b IS:
    --------------------------------
    In your assignment  b ← b + 0 * b
    The (left) b is initialized by number/value 0,
    0 * whatuwant ->  always 0 again  and
    0 + ""  (0 + empty/nothing/nix/rien/nada/niente/"")  ->  stays the same 0, so finally b = 0.

    or

    b = "" + 0 * ""        ' SB treats the whole right term as a number, because of the 0  (similar to "" + 5 * ""  or  "" + "" * "" if you like)
    TextWindow.WriteLine(b)

    or

    anything = anything + 0 * anything
    TextWindow.WriteLine(anything)

    b = b    ' here b initially is empty/"" and is assigned to b, b ← b
    TextWindow.WriteLine("|"+b+"|")

    Trivias:

    1.) Shapes.AddText needs GW initialisation first

    ' GraphicsWindow.Show()
    Shapes.AddText("Some Text")    ' crashes if GW is not initialized anyhow before

    2.) In a String one can add (multiple) "" if not at start or end so that 3 " would be in serie (like """...), eg:
    TextWindow.WriteLine("String can contain (multiple) "" if "" are not at the beginning or end of string")

    3.) Ref. to Nonkis article Shapes.GetOpacity() Causes Cast Error:we can create (semi)transp Shapes with Opacity using GW.BrushColor = "#AARRGGBB"  (AA <> 0xFF). Only for Shapes that use GW.BrushColor and GW.PenColor, GW.PenWidth etc. (not exactly same as Opacity Method and can't not work for eg. Shapes.AddImage), like:

    ' GraphicsWindow.PenColor = "#7F6A5ACD"   '  or

    ' GraphicsWindow.PenWidth = 0   ' ... before

    GraphicsWindow.BrushColor = "#7F6A5ACD"    ' Semitransp. SlateBlue
    rect = Shapes.AddRectangle(100, 100)

    So Opacity for this kind of Shapes should be detectable by any GetShapeColor/GetPixelColor (?) Method, that returns a format like #AARRGGBB, from the #AA alpha value (where 0xFF = 255 = 100%). But did'nt find a similar useable function in all the Extension.xml 's so long. Would be a half workaround to crashing GetOpacity method. Maybe someone finds a suitable extension method for that.

    4.) Most of Shapes Methods also work for Controls and vice versa, like:

    Shapes.Animate(Controls.AddButton("Button",0,0), GraphicsWindow.Width, GraphicsWindow.Height, 5000)

    5.) sure more to come





    Thanks, Pappa Lapub for your entries about trivia.

    Nonki Takahashi

    Thursday, June 5, 2014 3:27 PM
    Moderator
  • I reminded other trivia:

    5. Name (variable, subroutine, ...) started with _ doesn't appear in intellisense list.  I read this one somewhere.

    6. The same name can be used for all variable subroutine and label as different ones.


    Nonki Takahashi

    Thursday, June 5, 2014 3:35 PM
    Moderator
  • It works if you have a syntax error when you try to run the program.

    It doesn't worh if you have an exception e.g. divide by 0


    Jan [ WhTurner ] The Netherlands


    Oh, I reminded another one.

    7. Dividing by 0 becomes 0.


    Nonki Takahashi

    Thursday, June 5, 2014 3:41 PM
    Moderator
  • Yo man, exactly Nonki !

    i think you mean the internal name for the "_turtleLine#" and the "_turtle" (TurtleShape, the picture of the Turtle), Demo here Feb2014 Challenge and Center userdefined image for LDShapes.SetTurtleImage.

    eg: Shapes.SetOpacity("_turtle",value) or Shapes.Zoom("_turtle",faktorX,faktorY)

    Shapes.Remove("_turtleLine"+number) or LDShapes.PenColour("_turtleLine1","Blue") or Shapes.Move("_turtleLine1", x, y)  works as well.

    As well as maybe all other internal object names like "Button#", "TextBox#", "ImageList#" etc. If you look at the german SmallbasicLibrary.De.xml in LitDev's Ext download, they are all listed there.

    And right, i think they can also be listed under trivias.

    PS: Just found the next one, i think:

    8.) TAB does not show in GraphicsWindow.Title and TextWindow.Title, eg.

    TAB = Text.GetCharacter(9)

    GraphicsWindow.Title = "TextA" + TAB + "TextB"

    ' TextWindow.Title = "TextA" + TAB + "TextB"

    Thursday, June 5, 2014 5:49 PM
    Answerer
  • Don't know if real trivia, anyway remarkable:

    'String concatenation  (concatenate text string + num value/calculation result)

    TextWindow.WriteLine("Output: " + 5 -1)     ' ->    -1
    TextWindow.WriteLine("Output: " -1 + 5)     ' ->    4

    TextWindow.WriteLine("Output: " + 5 + -1)   ' ->    Output: 5-1
    TextWindow.WriteLine("Output: " + 5 + 1)    ' ->    Output: 51
    TextWindow.WriteLine("Output: " + (5 - 1))  ' ->    Output: 4

    Thursday, July 10, 2014 9:27 PM
    Answerer
  • I like trivial pursuit, top thread Nonki...

    Following on from PL's pearls.. How funny's this?

    TextWindow.WriteLine("hello: " -4----1)

    Thursday, July 10, 2014 9:53 PM
    Moderator
  • Hi JJ,

    guess same as

    TextWindow.WriteLine("hello: " -4+1)

    Thursday, July 10, 2014 10:05 PM
    Answerer
  • In almost any language:

    "hello: " -4+1

    should crash and burn - the fact it doesn't collapse badly in SB or compiles at all is really a bug.

    What actually happens is that the results is formed with each operator in turn (unless bracketed), the first steps is:

    • "hello: " -4

    Obviously this makes no sense - shouldn't compile - the results is that it just ignores the string (sets it to 0) and gives '-4' which can then be acted on by +1 and give -3.

    If I try to divide a string by a number I also get rubbish, showing that if the arithmetic cannot be done the string is replaced with 0.  Only the + operator makes any sense when one operand is a string.

    TextWindow.WriteLine("hello: "+4)
    TextWindow.WriteLine("hello: "-4)
    TextWindow.WriteLine("hello: "/4)
    TextWindow.WriteLine("hello: "*4)
    
    TextWindow.WriteLine(4+"hello: ")
    TextWindow.WriteLine(4-"hello: ")
    TextWindow.WriteLine(4/"hello: ")
    TextWindow.WriteLine(4*"hello: ")

    Note dividing by zero also fails to crash (as it should or even better stop with an error IMO) and results in 0.

    So in the desire to prevent crashing, the SB compiler allows the programmer to create nonsense - sometimes a crash is good as it points us to code errors.

    TextWindow.WriteLine("apples"*"oranges")

    Thursday, July 10, 2014 10:29 PM
    Moderator
  • re setting stuff to 0.

    That's what I don't like about the TW.ReadNumber() operation.

    It accepts a non numerical input, i.e. type nothing and press enter and it returns 0.

    Or type . and it returns a period.

    ALSO

    back to trivia, did anyone notice that an * appears at the top of the editing page when a change has not been saved. Like in VS.

    Thursday, July 10, 2014 11:07 PM
    Moderator
  • GraphicsWindow.DrawEllipse and .FillEllipse support neg. values for width/height which flips at y/x axis.

    GraphicsWindow.DrawBoundText(x,y,0,text)    ' width of 0 for full length of text, works like .DrawText.

    Probably further methods that support values of 0 and/or < 0.

    Monday, September 1, 2014 7:06 PM
    Answerer
  • This is my guess.  Top three alphabets of Program ID don't contain A, E, I, O, U, and Y.  I never seen these 6 characters in Program ID's.

    Nonki Takahashi

    Sunday, September 14, 2014 3:23 AM
    Moderator
  • lol = text.readnumber

    if lol = 0 then

    textwindow.writeline("LoL")

    else

    endif

    enter leads to the number 0(not any other number) and not else

    Sunday, September 14, 2014 4:13 AM
  • What a good observation, Nonki.

    My guess is that:

    1. that would be the most effective (simplest) way to prevent the possibility of "offensive" 3 letter words forming without requiring post-parsing;
    2. prevent the formation of a word that could form an inaccurate/misleading description of a program; and
    3. give discretion to the owners of the Program Listing service to allocate personalised ID's without the risk of randomised discrimination.

    This would be a good trick for all programmers to have in their toolbox.

    http://en.wikipedia.org/wiki/English_words_without_vowels





    Sunday, September 14, 2014 5:53 AM
    Moderator
  • It's interesting...

    Nature favours simplicity. It naturally avoids selecting the unnecessary and thereby allows the unnecessary/over complex to wither and die.

    So the strongest code could be that that contains no unnecessariness and provides the simplest method to achieve a task.

    Often in nature a naturally selected single construct is used in many applications and allows for many more.

    Perhaps an organic example is the double helix and an inorganic example is binary.

    And on the topic of languages (I believe one of the google founders speaks a "timeless" indigenous language). Indigenous languages have a unique simplicity yet there's nothing useful that they can't express.

    The aboriginal word for "useless" is que-ar, (I can't spell it). To be called useless by an elder means that you are at risk of extinction. The old people become the most useful and powerful because they are entrusted and gifted with knowledge of nature.

    I can see an absolute diminishing polarity between "timeless" indigenous knowledge and the magnificent discoveries being made in science.

    There are indigenous "imagining's" surfacing that predict that there will be an equating of science and traditional knowledge.

    A MASSIVE misconception is that some indigenous stories are based on belief. This is NOT the case. They are knowledge, i.e. the initiated see/hear the knowledge just as a scientists see/hear the graduations on a micrometre. In both cases the knowledge is validated and checked by their peers. (otherwise initiates might think they are hallucinating)

    To see and hear proof of indigenous knowledge you have to go through initiations. Not an easy task. Or just ask and they will tell you, but you have to ask.

    The reason I like small basic is because it's a language. I think it's interesting how it has true/false state.

    In indigenous common language we don't have "yes", only "no".

    "Yes" is the timeless state and "no" is destined for extinction.

    e.g. If you ask is 1+1=2 you will be given silence or perhaps "boo" which means "good".

    If you ask is 1+1=5 you'll be answered "ta" or "taboo" which means "no good".

    There is no reason in its simplest form to answer "yes" that 1+1=2. It will just survive as being. But run around saying 1+1=5 and you'll become useless and potentially extinct. 1+1=5 is taboo.


    Sunday, September 14, 2014 7:29 AM
    Moderator
  • My big take away on excluding AEIOUY is philosophical, much can be achieved by excluding the unnecessary to perform a useful task. Powerful simplicity. Beautiful code.

    Imagine going back 10,000 years, possibly = 625 generations, with todays technology. Imagine by applying natural growth rates what the future will look like in 3 generations from now, possibly = 100 years.

    I think computer languages, and just language itself, will play a vital role in this progression.

    Sunday, September 14, 2014 8:56 AM
    Moderator
  • The creation of Small Basic was inspired by a person called Johnny.

    Gee, Johnny must be important!

    What Johnny needs Johnny gets. Johnny rules the world.

    citing: http://blogs.msdn.com/b/smallbasic/archive/2014/05/17/why-johnny-can-t-code.aspx


    Sunday, September 14, 2014 9:32 AM
    Moderator
  • 8. was that A, E, I, O, U, Y are not used in Program IDs.

    9. Program.Directory has remote URL (http://smallbasic.com/program/?XXX000) when the program run in remote.


    Nonki Takahashi

    Tuesday, September 16, 2014 3:13 AM
    Moderator
  • GraphicsWindow.FontName by default also supports NOT installed fonts, similar to LDGraphicsWindow.SetFontFromFile(fontFile)

    but with an other syntax like:

    1.)  see IntelliSense, for installed fonts in C:\Windows\Fonts

    GraphicsWindow.FontName = "[#]fontName"    or

    GraphicsWindow.FontName = "[#]fontName, [#]compositeFontName1, [#]compositeFontName2, ..."

     

    2.)  for NOT installed fonts, in any given directory path as file-Uri or full dir path.

    GraphicsWindow.FontName = "C:\folder\path\#fontName[, compositeFont, ..]"

    GraphicsWindow.FontName = "file:///C:/folder/path/#fontName[, compositeFont, ..]"

    GraphicsWindow.FontName = "file:///C:\folder\path\#fontName[, compositeFont, ..]"

    etc.... lots of thinkable combinations, initial loading takes a little longer, if there are a lot of .ttf files in that directory.

    Here's a simple Counter as a using sample(ID: ZTB374)

    About syntax, FontFallback, CompositeFonts see FontFamily class , FontFamily constructor (String)

    Sunday, February 25, 2018 10:57 PM
    Answerer
  • Pappa Lapub, what a great discovery about Small Basic fonts!  Thanks.

    Nonki Takahashi

    Wednesday, March 14, 2018 1:27 PM
    Moderator