H1KAF

      Just use Xubuntu and be done with it..
      Nobody's forcing you to use Linux.

      https://www.raspberrypi.org/blog/pixel-pc-mac/
      
Like a RaspberryPi -- PixelOS on VirtualBox
===========================================

Install PIxel OS to hard disk as follows:

  https://www.raspberrypi.org/blog/pixel-pc-mac/

Egon Rath says:
22nd Dec 2016 at 7:29 am

How to: Install to HDD (as the only OS)

Assumptions:

  -- The USB Stick you boot from is /dev/sdb
  -- The internal HDD is /dev/sda

Commands are given in double quotation marks.

  1. Boot it from USB/DVD
  2. Transfer the entire stick to your drive:
  2.1. "sudo bash"
  2.2. "dd if=/dev/sdb of=/dev/sda bs=1M"
  3. Reboot without the stick, should boot from internal HDD_
  3.1 "reboot"
  4. Resize the Partition:
  4.1. "sudo bash"
  4.2. "fdisk /dev/sda"
  4.3. print partitions with "p"
  4.4. write down the beginning of partition 2
  4.5. delete partition 2 with "d", then "2"
  4.6. create a new parition with "n", primary partition, starting at the location from 4.4
  4.7. write with "w"
  5. Reboot:
  5.1. "reboot"
  6. Resize the filesystem on /dev/sda2 to fill the disk:
  6.1. "sudo bash"
  6.2. "resize2fs /dev/sda2"

In VirtualBox I have mounted the iso as an image.
To install to disk change the following:

  Replace "dd if=/dev/sdb of=/dev/sda bs=1M"
  with "dd if=/dev/sr0 of=/dev/sda bs=1M" 
     
VM History
----------

    1  echo $SHELL
    2  sudo  -s
       fdisk /dev/sda
       reboot
    3  sudo -s
       apt-get update
       apt-get upgrade
       cd /media/pi/VBOXADDITIONS_5.1.14_112924/
       ./VBoxLinuxAdditions.run 
       locale
       export LANG=en_US.UTF-8
       dpkg-reconfigure locales
       dpkg-reconfigure keyboard-configuration
    4  setupcon # ALT-F2, sudo -s
    5  reboot
    6  sudo -s
       mkdir /mnt/vbox
       mount -t vboxsf Desktop /mnt/vbox
       cp /mnt/vbox/Flowgorithm.exe /usr/local/bin
       exit
    7  mono /usr/local/bin/Flowgorithm.exe 
    8  sudo mv Downloads/logisim-generic-2.7.1.jar /usr/local/bin/
    9  java -jar /usr/local/bin/logisim-generic-2.7.1.jar
   10  sudo -s
       mkdir /usr/local/bin/smath 
       mv Downloads/SMathStudioDesktop.0_98_6179.Mono.tar.gz /usr/local/bin/smath
       cd /usr/local/bin/smath
       tar xf SMathStudioDesktop.0_98_6179.Mono.tar.gz
       exit
   11  cd ~ 
   12  mono /usr/local/bin/smath/SMathStudio_Desktop.exe

History note: After dpkg-reconfigure keyboard-configuration
-----------------------------------------------------------

  (ALT-F2) login as pi/raspberry
    $ sudo -s
    # setupcon
  
C, C++, Java, Python already installed 
--------------------------------------

  # gcc --version
  gcc (Debian 4.9.2-10) 4.9.2
  Copyright (C) 2014 Free Software Foundation, Inc.
  ..
  # g++ --version
  g++ (Debian 4.9.2-10) 4.9.2
  Copyright (C) 2014 Free Software Foundation, Inc.
  ..
  # java -version
  java version "1.8.0_112"
  Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
  Java HotSpot(TM) Client VM (build 25.112-b15, mixed mode)
  ..
  
  # python --version
  Python 2.7.9

More
----

  # apt-get install vim
  
Testing java
------------

  $ cd ~
  $ mkdir testjava
  $ cd testjava
  $ vi confu.java
  $ cat confu.java | head -n 20 | tail -n 12 | sed 's/^\/\/ //' > Dog.java
  $ javac Dog.java
  $ javac confu.java
  $ java confu
  Before, Hello, Left but Down, 1

confu.java

  // Java is confusing because everything is passed by value. 
  // However for a parameter of reference type 
  // (i.e. not a parameter of primitive type) 
  // it is the reference itself which is passed by value
  //   http://stackoverflow.com/questions/1068760
  //        /can-i-pass-parameters-by-reference-in-java
  // Output: Before, Hello, Left but Down, 1

  // public class dog {
  //     String cName;
  //     public dog( String aName) {
  //         cName = aName;
  //     }
  //     String getName() {
  //         return cName;
  //     }
  //     void setName(String aName) {
  //         cName = aName;
  //     }
  // }

  public class confu { 
    public static void main( String[] args ) {
      Object o = "Before";
      String s = "Hello";
      dog    d = new dog("Up");
      dog    e = new dog("Left");
      int[]  i = new int[10];
      i[0] = 0;
      mutate(s, o, d, e, i);
      System.out.println( 
        o + ", " + s + ", " + e.getName() + " but " + 
        d.getName() + ", " + i[0]);
    }

    public static void mutate( 
        String as, Object ao, dog ad, dog ae, int[] ai ) {
      ao = "After";
      as = "Goodbye";
      ad.setName("Down");
      ae = new Dog("Right");
      ai[0] = 1;
    }
  }

ToDo
----

Use Java to solve following tasks:

 v Install mono-complete
 v Install and run logisim, Flowgorithm, SMath Studio
 v Build converter for "К работе 1 (Карта Карно и Logisim)"
   Build converter from Gaddis Pseudocode to Flowgorithm XML
   Build converter from Gaddis Pseudocode to Java
   Build converter from Gaddis Pseudocode to Arduino C++
    
Links
-----

  https://wiki.debian.org/ChangeLanguage
  http://superuser.com/questions/646425/permanently-change-
    default-language-and-keyboard-settings-what-am-i-missing 

TO FLOWGORITHM
==============

  +-----------------------------------------------------------+
  | NULL DAZIBAO: Console input and output are always strings |
  +-----------------------------------------------------------+

However, data processing, instead, may involve different data types:

  + integer for integer numbers, character codes, logical values such as true (1) and false (0), memory addresses (pointers).

  + reals for numbers with fractional part. Such new notions as mantissa and exponent are introduced.
  
Primitive data may be combined into arrays (named strings if array elements hold character codes). Next, variables of named data types may form structures (named bitfields if memory space is critical).

Gaddis Pseudocode: Declare means nothing, 
-----------------------------------------

i.e statement continues as one of the:

  int
  real
  bool
  string

Gaddis Pseudocode: Set means nothing, 
-------------------------------------

i.e. statement continues as 

  variable names = ..
  
Variable names can be collected from the statements that begins with "int" or "real" or "bool" or "string"

Gaddis Pseudocode: Keywords
---------------------------

Module main() | End Module
Declare       | Set 
Real          | Integer    | Boolean   | String
If            | Then       | Else      | End If
Do            | While      | End While
For           | To         | Step      | End For
Call          | Return     | Function  | End Function
Output        | Input

Convert some scripts found here to Gaddis Pseudocode
----------------------------------------------------

  main or none -> Module main()
  niam or none -> End Module
  before data type -> Declare
  before var_name = -> Set
  double -> Real
  long   -> Integer
  bool   -> Boolean
  string -> String
  if then -> If Then
  fi -> End If
  do -> Do
  while -> While
  elihw -> End While
  call -> Call
  return -> Return
  function -> Function
  noitcnuf -> End Function
  out -> Output
  in -> Input
  
Operators as in Flowgorithm.

Flowgorithm: missing Break
--------------------------

Use variables with "flag" behaviour.

  x = 1
  while expr
    out x
    x = x + 1
    if x == 10 break
  out "out of loop"

  x = 1
  nbreak = true
  while expr && nbreak
    out x
    x = x + 1
    if x == 10
      nbreak = false
    fi
  elihw

  output "out of loop"

Flowgorithm: missing continue
-----------------------------

Not as much as break, however:

  for x=0 to 10
    if x<3 || x>7 continue
    out x
  
  for x=0 to 10
    if x>=3 && x<=7
      out x
    fi
  rof
     
Calculations
------------

Area of a Circle
................

  real area
  int  radius

  out "Please enter the radius of a circle"
  in radius
  area = 3.14 * radius ^ 2
  out "The area is " + area

Area of a Triangle
..................

  real base
  real height
  real answer

  out "Please enter the base of the triangle"
  in  base
  out "Please enter the height of the triangle"
  in  height
  answer = 1 / 2 * (base * height)
  out "The area of the triangle is " + answer

Tip Calculator
..............

  real bill
  real tip

  out "How much is the bill?"
  in bill
  tip = bill * 0.15
  out "The tip is $", tip
  out "The total, with tax, is $", tip + bill

Loops
-----

While Loop 1 to 100
...................

  int n

  n = 1
  while n <= 100 
      Display n
      Set n = n + 1
  end while
  
For Loop 1 to 100
.................

  int n

  for n = 1 to 100 
      out n
  end for

String -- Character per line
............................

  string name
  int    n

  in name
  for n = 0 to len(name) - 1
      out substring(name, n, 1)
  end for

99 Bottles -- While
...................

  // The If Statement inside the loop will print the correct lyrics: 
  // bottles vs. bottle.

  int n

  n = 99
  while n >= 1
      if n == 1 then
          out "One bottle of beer on the wall"
      else
          out n, " bottles of beer on the wall"
      end if
      n = n - 1
  end while

99 Bottles -- For
.................

  // The If Statement inside the loop will print the correct lyrics: 
  // bottles vs. bottle. 
  //  
  // This version uses a For Loop rather than a while Loop. 
  // It will only work in version 1.7 and later.

  int n

  for n = 99 to 1 step -1
      if n == 1 then
          out "One bottle of beer on the wall"
      else
          out n, " bottles of beer on the wall"
      end if
  end for

If Statements
-------------

if: Go Do It
............

  string answer

  out "Is there something you need to do? (y/n)"
  in answer
  if answer == "n" then
      out "Stop lying!"
  end if
  out "Go do it"

if: Age Vote
............

  int age

  out "How old are you?"
  in age
  if age >= 18 then
      out "Go vote!"
  else
      out "Sorry, not yet"
  end if

Arrays
------

array: Squares
..............

  // it is recommended that you open the variable window 
  // and step through this program.

  int n
  int squares[10]

  // this loop fills the array with squares. 
  // so, squares[3] will be 9. 
  // the first subscript (array element number) starts at zero. 
  // so, we loop from 0 to 9.

  for n = 0 to 9
      set squares[n] = n ^ 2
  end for

  // this loop will print all the array elements 
  // that were assigned in the last loop.

  for n = 0 to 9
      out squares[n]
  end for

Functions
---------

function: Area of a circle
..........................

  function void main()
      int x
      
      out "Enter the radius of the circle"
      in x
      
      // the following will call the circle function 
      // using the value the user entered.  
      //  
      // notice that this variable is called 'x' 
      // while the function uses 'radius'. 
      // the value of 'x' is passed to the function.
      
      out "area is ", circle(x)
  end function

  function real circle(real radius)
      // this function has one parameter called radius. 
      // it acts like a local variable that is assigned 
      // when the function is called.
      
      real area
      
      area = pi * radius ^ 2
      
      // this function returns the contents of the area variable.
      
      return area
  end function

Sample Gaddis Pseudocode
------------------------

  Module main()
      // Let's Start
      
      Declare Integer i
      Declare Real r
      Declare Boolean b
      Declare String s
      
      Set i = 3
      
      If true Then
          Display "True"
      Else
          Display "False"
      End If
      
      Do
          Set i = i - 1
          Display "i is ", toString(i), "now"
      While i != 0
      
      While false
      End While
      
      For i = 0 To 3
      End For
      
      Call foo()
      Display foo()
      
      Input x
  End Module

  Function String foo()
      Return "Foo"
  End Function

Same in Flowgorithm XML

<?xml version="1.0"?>
<flowgorithm fileversion="2.0">
    <attributes>
        <attribute name="name" value=""/>
        <attribute name="authors" value=""/>
        <attribute name="about" value=""/>
        <attribute name="saved" value=""/>
        <attribute name="created" value=""/>
        <attribute name="edited" value=""/>
    </attributes>
    <function name="Main" type="None" variable="">
        <parameters/>
        <body>
            <comment text="Let's Start"/>      
            <declare name="i" type="Integer" array="False" size="" variables="i"/>
            <declare name="r" type="Real" array="False" size="" variables="r"/>
            <declare name="b" type="Boolean" array="False" size="" variables="b"/>
            <declare name="s" type="String" array="False" size="" variables="s"/>
            <assign variable="i" expression="3"/>
            <if expression="True">
                <then>
                    <output expression="&quot;True&quot;"/>
                </then>
                <else>
                    <output expression="&quot;False&quot;"/>
                </else>
            </if>
            <do expression="i != 0">
                <assign variable="i" expression="i -1"/>
                <output expression="&quot;i is &quot; &amp; ToString(i) &amp; &quot;now&quot;"/>
            </do>
            <while expression="False"/>
            <for variable="i" start="0" end="3" direction="inc" step="1"/>
            <call expression="foo"/>
            <output expression="foo()"/>
            <input variable="x"/>
        </body>
    </function>
    <function name="foo" type="String" variable="&quot;Foo&quot;">
        <parameters/>
        <body/>
    </function>
</flowgorithm>

Read this:

  http://www.flowgorithm.org/documentation/index.htm

See also:  

  "Programming Logic and Design" by Tony Gaddis

Swap witout third variable
..........................

  a = a + b
  b = a - b # b is a
  a = a - b # a + b - a

Links
-----

1. http://robatz.altervista.org/blog/flowcharts-book/

    Windows 10 Kreators Update,
    Edge (14986) -> print to Microsoft PDF pp.2-13
    ABBYY Fine Reader -> Text.
    Add zip extension

Clipboard
---------

pi@raspberrypi:~ $ cat /usr/local/bin/lo
#!/bin/sh

java -jar /usr/local/bin/logisim-generic-2.7.1.jar
pi@raspberrypi:~ $ cat /usr/local/bin/flo
#!/bin/sh

mono /usr/local/bin/Flowgorithm.exe
pi@raspberrypi:~ $ cat /usr/local/bin/sma
#!/bin/sh

sh /usr/local/bin/smathstudio_desktop_mono
pi@raspberrypi:~ $ 
