Home   -   Computerkurs   Demos   Editpointstatic   Folderwatcher   Gipsydrive   Licenses   Shrinkseries   V4   More...  

All   Asm   Bas   C   C++   C#   Couch   CSS   HTML   Java   JS   Lisp   OPAL   PHP   Perl   PS   Py   SQL   Win  

Arrays   Files   Processes   RegEx   AccessIE   Linq   WindowsServices   SimpleGuiAccess   WpfTreeView  

Previous page Home chapter Next page

Downtown Programmer's Corner   -   Demos   -   C#

Arrays

Snippets how to handle arrays in   C#   JavaScript   PHP   Perl   Python   C++   C   Scheme and   Assembler and   PowerShell   OPAL and   other   languages.

Csharp

.

   // (# 20101216.0021)
   // Define multidimensional array of strings
   string[][] aa =
               { new string[] { "a1" , "a2" , "a3" , "a4" }
                , new string[] { "b1" , "b2" , "b3" , "b4" }
                 , new string[] { "c1" , "c2" , "c3" , "c4" }
                  };
   // Code samples lost-and-found
   // ...
  1. Link icon for miscellaneous sites ... (# 2011xxx.xxx).

.

JavaScript

.

   // Code samples lost-and-found
   // ...
  1. Link icon for miscellaneous sites ... (# 2011xxx.xxx).

.

PHP

.

   // Code samples lost-and-found
   // ...
  1. Link icon for miscellaneous sites ... (# 2011xxx.xxx).

.

Perl

.

   // Code samples lost-and-found
   // ...
  1. Link icon for miscellaneous sites ... (# 2011xxx.xxx).

.

Python

.

   // Code samples lost-and-found
   // ...
  1. Link icon for miscellaneous sites ... (# 2011xxx.xxx).

.

C++

.

   // Code samples lost-and-found
   // ...
  1. Link icon for miscellaneous sites ... (# 2011xxx.xxx).

.

C

.

   // Code samples lost-and-found
   // ...
  1. Link icon for miscellaneous sites ... (# 2011xxx.xxx).

.

Scheme

General. To handle arrays in Scheme, you need to know the car, cdr and the like keywords. There are no arrays in lisp, only lists. With one list, you always can access head and tail with car and cdr. [todo: *are* arrays?].

Code samples lost and found. Just one arbitrary example, sniped from GIMP Script-Fu script suaheli-shrink-sequence.scm :

   ; ...
   (define mylist '( 1 2 3 )) ; provisory fix # 20110927.1442
   (set! mylist '(
                          prcent maxpix mxsqur qality
                          ------ ------ ------ ------
                        (    100      0      0     33 )        ; p99q33
                        (    100      0      0     66 )        ; p99q66
                        (     50      0      0     77 )        ; p50q77
                        (     25      0      0     88 )        ; p25q88
                        (      0    180      0     88 )        ; mx180q88
                        (      0    128      0     88 )        ; mx128q88
                        (      0      0    180     88 )        ; sq0180q88
                        (      0      0    128     88 )        ; sq0180q88
   ))

   ; ...

   ; read the array of arrays
   (while mylist
      ; preparation - retrieve the 4 loop variables from job list
      ; BTW we should use 'cadddr', but that produces an error
      (set! px (car mylist))
      (set! iSizepercent (car px))
      (set! li1 (cdr px))
      (set! iSizemaxpixel (car li1))
      ; ... do other preparation ...

      (if (> iSizepercent 0)
         ( begin
            ; calculate new size
            (set! iNewwidth  (* iOrginalwidth (/ iSizepercent 100)))
            (set! iNewheight (* iOrginalheight (/ iSizepercent 100)))
            ; ... calculate other things ...
         )
      )
      ;
   )
   ; ...
  1. Link icon for miscellaneous sites ... (# 2011xxx.xxx).

.

Assembler

.

Code samples lost-and-found. Arbitrary snippet from aloha080.asm

   ;;;
   segment data
   msgwelcome:   db 'Welcome.', 13, 10, '$'
   msgmenu:      db 13, 10, 'Tastaturmenu: 1=Hallo 2=Add 3=Sound 4 5 6 7 8 9 0=Ende', 13, 10, '$'
   msgkey1 :     db ' Nochmal Hallo!', 13, 10, '$'
   msgkey3 :     db ' Sound..', 13, 10, '$'
   msgkey4 :     db ' Taste 4', 13, 10, '$'
   msgkey5 :     db ' Taste 5', 13, 10, '$'
   msgkeyany :   db ' Irgendeine Taste.', 13, 10, '$'
   msgbye :      db ' Bye.', 13, 10, '$'
   jmptable:     dw key1, key2, key3, key4, key5, key6, key7, key8, key9, keyany
  1. Link icon for miscellaneous sites ... (# 2011xxx.xxx).

.

PowerShell

Code samples lost-and-found. Arbitrary snippet from demo--ie--page-dive-recursively.ps1 (sequence # 20100623.1222):


   write-host
   write-host ("Found text:")
   #-----------------------------------
   $a = @()
   foreach ($key in $global:textlist.keys) {
      $a += $key
   }
   [Array]::Sort([array]$a)
   for ($i = 0; $i -lt $a.Count; $i++) {
      Write-Host ($a[$i] + " = " + $global:textlist[$a[$i]])
   }
   #-----------------------------------
  1. Link icon for miscellaneous sites ... (# 2011xxx.xxx).

.

OPAL

.

   // Code samples lost-and-found
   // ...
  1. Link icon for miscellaneous sites ... (# 2011xxx.xxx).

.

Other languages

.

   // Code samples lost-and-found
   // ...
  1. Link icon for miscellaneous sites ... (# 2011xxx.xxx).

.

Links

.

Imprint : www.trilo.de/imprint.html