working on it ...

Filters

Explore Public Snippets

Sort by

Found 858 snippets matching: pascal

    public by FMXExpress modified Nov 13, 2014  8979  90  7  1

    Non Blocking Message Dialog For Delphi XE7 Firemonkey

    MessageDlg(‘Do you want to press yes or no?’, System.UITypes.TMsgDlgType.mtInformation,
      [System.UITypes.TMsgDlgBtn.mbYes, System.UITypes.TMsgDlgBtn.mbNo], 0,
        procedure(const AResult: TModalResult)
        begin
          case AResult of
            { Detect which button was pushed and show a different message }
            mrYes:
                begin
                // pressed yes
                end;
            mrNo:
                begin
                // pressed no
                end;
          end;
        end
      );
    // code here would get executed right away

    public by FMXExpress modified Nov 12, 2014  7065  9  9  4

    Install A Shortcut On Android With Delphi XE5 Firemonkey

    http://www.fmxexpress.com/install-shortcuts-on-the-android-home-screen-with-delphi-xe5-firemonkey/
    //Android permission required:
    //<uses-permission android:name=”com.android.launcher.permission.INSTALL_SHORTCUT”/>
        
    Uses
    Androidapi.JNI.GraphicsContentViewText, FMX.Helpers.Android,
    Androidapi.JNI.JavaTypes, FMX.Platform.Android, AndroidApi.JniBridge, AndroidApi.Jni.App,
    AndroidAPI.jni.OS;
    
    {$IFDEF ANDROID}
    var
    ShortcutIntent: JIntent;
    addIntent: JIntent;
    wIconIdentifier : integer;
    wIconResource : JIntent_ShortcutIconResource;
    {$ENDIF}
    begin
    {$IFDEF ANDROID}
    
    ShortcutIntent := TJIntent.JavaClass.init(SharedActivityContext, SharedActivityContext.getClass);
    ShortcutIntent.setAction(TJIntent.JavaClass.ACTION_MAIN);
    
    addIntent := TJIntent.Create;
    addIntent.putExtra(TJIntent.JavaClass.EXTRA_SHORTCUT_INTENT, TJParcelable.Wrap((shortcutIntent as ILocalObject).GetObjectID));// here we need to cast the intent as it’s not done in delphi by default, not like java
    addIntent.putExtra(TJIntent.JavaClass.EXTRA_SHORTCUT_NAME, StringToJString(Application.Title));
    addIntent.setAction(StringToJString(‘com.android.launcher.action.INSTALL_SHORTCUT’));
    // get icon resource identifier
    wIconIdentifier := SharedActivity.getResources.getIdentifier(StringToJString(‘ic_launcher’), StringToJString(‘drawable’), StringToJString(‘com.embarcadero.HeaderFooterApplication’)); // if the app name change, you must change the package name
    wIconResource := TJIntent_ShortcutIconResource.JavaClass.fromContext(SharedActivityContext, wIconIdentifier);
    // set icon for shortcut
    addIntent.putExtra(TJIntent.JavaClass.EXTRA_SHORTCUT_ICON_RESOURCE, TJParcelable.Wrap((wIconResource as ILocalObject).GetObjectID));
    
    SharedActivityContext.sendBroadcast(addIntent);
    
    {$ENDIF}
     

    public by FMXExpress modified Nov 12, 2014  4171  17  6  1

    Decode GZIP Content From TRESTClient In Delphi XE7 Firemonkey

    RESTClient.AcceptEncoding := 'gzip, deflate';
    RESTClient.Execute;
    
    if RESTResponse.ContentEncoding=’gzip’ then
    DecodeGZIPContent(RESTResponse.RawBytes) // decode and do something with the content
    else
    RESTResponse.Content; // do something with the content
    
    function DecodeGZIPContent(RawBytes: System.TArray<System.Byte>): String;
    var
    MSI: TMemoryStream;
    MSO: TStringStream;
    begin
    MSI := TMemoryStream.Create;
    MSO := TStringStream.Create;
    MSI.WriteData(RawBytes,Length(RawBytes));
    MSI.Seek(0,0);
    // Zlib is a TIdCompressorZlib
    Zlib.DecompressGZipStream(MSI,MSO);
    MSI.DisposeOf;
    MSO.Seek(0,0);
    Result := MSO.DataString;
    MSO.Free;
    end;

    public by FMXExpress modified Nov 12, 2014  4627  2  7  1

    Process Strings Using A Parallel For Loop In Delphi XE7 Firemonkey

    TParallel.For(0,1000,
     procedure(I: Integer)
      begin
       TThread.Queue(TThread.CurrentThread,
        procedure
         begin
          Memo1.Lines.Append(I.ToString);
         end);
      end);

    public by Geometry modified Jul 28, 2016  1277  0  4  0

    CalculatePressure: Calculates the pressure from the raw sensor data.

    Calculates the pressure from the raw sensor data. Pressure in pascal
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Windows.Devices.Bluetooth.GenericAttributeProfile;
    using Windows.Storage.Streams;
    using System.Runtime.InteropServices.WindowsRuntime;
    using X2CodingLab.SensorTag.Exceptions;
    using X2CodingLab.Utils;
    
    /// <summary>
    /// Calculates the pressure from the raw sensor data.
    /// </summary>
    /// <param name="sensorData"></param>
    /// <param name="calibrationData"></param>
    /// <param name="calibrationDataSigned"></param>
    /// <returns>Pressure in pascal</returns>
    public static double CalculatePressure(byte[] sensorData, int[] calibrationData)
    {
        Validator.RequiresNotNull(sensorData, "sensorData");
        Validator.RequiresNotNull(calibrationData, "sensorData");
        Validator.RequiresArgument(calibrationData.Length == 8, "Calibration data doesn't have the appropriate lenth. Use PressureSensorInstance.CalibrationData.");
    
        //more info about the calculation:
        //http://www.epcos.com/web/generator/Web/Sections/ProductCatalog/Sensors/PressureSensors/T5400-ApplicationNote,property=Data__en.pdf;/T5400_ApplicationNote.pdf
        int t_r, p_r;	// Temperature raw value, Pressure raw value from sensor
        double t_a, S, O; 	// Temperature actual value in unit centi degrees celsius, interim values in calculation
    
        t_r = BitConverter.ToInt16(sensorData, 0);
        p_r = BitConverter.ToUInt16(sensorData, 2);
    
        t_a = (100 * (calibrationData[0] * t_r / Math.Pow(2, 8) + calibrationData[1] * Math.Pow(2, 6))) / Math.Pow(2, 16);
        S = calibrationData[2] + calibrationData[3] * t_r / Math.Pow(2, 17) + ((calibrationData[4] * t_r / Math.Pow(2, 15)) * t_r) / Math.Pow(2, 19);
        O = calibrationData[5] * Math.Pow(2, 14) + calibrationData[6] * t_r / Math.Pow(2, 3) + ((calibrationData[7] * t_r / Math.Pow(2, 15)) * t_r) / Math.Pow(2, 4);
        return (S * p_r + O) / Math.Pow(2, 14);
    }

    external by darkodelta modified Sep 8, 2015  105316  0  3  0

    Linked lists pascal

    Linked lists pascal: linked-list.pas
    program p1;
    
    
    type
         int = integer;
         pelem = ^element;
         element = record
                data: int;
                next: pelem;
         end;
    
    var
         lp : pelem;
         n : int;
    
    
    procedure popuni_listu(var lp: pelem; bre: int);
    var i, t: int;
        temp: pelem;
         begin
             writeln('Unesite elemente ->');
             for i:= 1 to bre do
             begin
               write('Unesite ', i,'. element: ');
               readln(t);
               if lp = NIL then //u slucaju da prvi element ne postoji
               begin
               new(lp);
               lp^.data:= t;
               lp^.next:= NIL;
               end
               else
               begin
                    temp:=lp;
                    while(temp^.next <> NIL) do temp:= temp^.next;
                    new(temp^.next);
                    temp := temp^.next;
                    temp^.data:= t;
                    temp^.next:= NIL;
               end;
             end;
         end;
    
    procedure ispis(lp: pelem);
        begin
             while(lp <> NIL) do
             begin
               writeln('[',lp^.data,']');
               lp:=lp^.next;
             end;
        end;
    procedure memclean(var lp: pelem);
    var temp: pelem;
        begin
           temp:=lp;
           while(lp <> NIL) do
           begin
             dispose(temp);
             lp:=lp^.next;
             temp:=lp;
           end;
        end;
    begin
      lp := NIL;
      write('Unesite broj elemenata liste: ');
      readln(n);
      popuni_listu(lp, n);
      ispis(lp);
      memclean(lp);
    end.
    
    

    external by Toby Deshane modified Sep 27, 2014  17298  0  3  0

    Information on the hot new version of Pascal: Borland Pascal with Objects 7.0

    Information on the hot new version of Pascal: Borland Pascal with Objects 7.0: BP7-INFO.TXT
    [The following combines two information files from Borland
    International regarding the two newly released Pascal products. A copy
    of this information is being sent as an automated reply to e-mail sent
    to the Internet address bp7-info@borland.com. Other Internet e-mail
    addresses at Borland include:
    
    customer-support@borland.com is an address to send e-mail to our
    Customer Service department. You can get product and price info,
    information on upgrade offers, check the status of your order, arrange
    for a replacement of a bad disk in order, etc. In other words, they
    can handle any non-technical problem or request. Due to restrictions
    on use of our connection via NSFNET, we cannot accept actual sales
    orders and credit card numbers via e-mail to borland.com addresses.
    
    education@borland.com reaches an Educational Sales representative who
    can provide information regarding academic discount programs to
    students, teachers, or people otherwise affiliated with educational
    institutions within the United States.
    
    intl-edu@borland.com is the address from which to get information
    about Educational Sales programs outside of the United States, if you
    do not know how to contact the Borland representative in your part of
    the world. Depending on where you are, intl-edu@borland.com may just
    provide you with the information as to who is your local contact.
    
    bugs@borland.com is a place to send reports of reproducible bugs to
    Borland QA. It is not a place to get help or verification of problems,
    but it is a way of making sure that we know about a problem so it can
    get fixed sooner.
    
    If you discover problems with any of these Internet addresses, you
    should inform postmaster@borland.com. Please do not send that address
    any questions regarding Borland products, requests for technical
    support, or queries about email addresses of individuals. Borland
    does not yet offer technical support by e-mail, nor do we have a
    general connection between internal e-mail systems and the Internet.]
    
    =====================================================================
    
                          Borland Pascal with Objects 7.0
                                 Turbo Pascal 7.0
                               Features and Benefits
    
    
    Overview
    
    Here are the primary features and benefits of Borland Pascal with
    Objects 7.0 and Turbo Pascal with Objects 7.0.  These are taken
    from the Reviewer's guide which includes more detailed product
    descriptions and technical information.
    
    
    Borland Pascal with Objects 7.0
    
    Borland Pascal with Objects 7.0 is the most productive
    programming system available for DOS and Windows.  It includes
    the following new features:
    
       Program for DOS, DOS Protected Mode (DPMI) and Windows
       Professional tools for all three platforms with nothing else
       to buy
    
       Free DOS Extender! Create DOS Protected Mode (DPMI)
       applications.  Break the 640K barrier and use up to 16 MB of
       memory, without royalties
    
       Create DOS protected mode Dynamic Link Libraries (DLLs)
       Reuse DLLs in DOS and Windows; and link C or C++ code easily
    
       High capacity, multi-target IDEs
       Choose the DOS or Windows IDE and target any platform
    
       DOS and Windows ObjectBrowsers
       Navigate source code quickly with full cross-reference
       information
    
       Improved IDEs with color syntax highlighting, unlimited
       undo/redo. Makes it easier to read code and experiment with
       changes
    
       Enhanced application frameworks
       Add data validation to DOS and Windows applications easily
    
       New language features and optimizations
       Write more flexible code with better performance
    
       Winsight and Winspector included
       For faster debugging of Windows applications
    
       Free Runtime library source code included ($195 value included
       free!).  Learn the secrets of object-oriented programming from
       the experts
    
    
       Turbo Pascal 7.0
    
       Turbo Pascal 7.0 is the fastest way to learn object-oriented
       programming.  It includes the following new features:
    
          High capacity IDE
          Compile large real-mode applications within the IDE
    
          ObjectBrowser
          Navigate source code quickly with full cross-reference
    
          Improved IDE with color syntax highlighting, unlimited
          undo/redo Makes it easier to read code and experiment with
          changes
    
          Enhanced application frameworks
          Add data validation to DOS and Windows applications easily
    
          New tutorials on Turbo Vision and pointers
          Makes it easy to learn object-oriented programming
    
    =================================================================
    
                           Borland Pascal with Objects 7.0
                                 Questions & Answers
    
    
    I. General Questions
    
       1. What are the new features of Borland Pascal with Objects
          7.0?
    
          Borland Pascal with Objects 7.0 includes all of the
          features necessary for high productivity application
          development for DOS and Windows.  
          The major new features are:
    
          o  Support for DOS, DOS Protected Mode (DPMI) and Windows
             programming
          o  Ability to create DOS Dynamic Link Libraries (DLLs) that
             are binary compatible with Windows
          o  High capacity DOS and Windows IDEs
          o  Improved IDEs with color syntax highlighting and
             undo/redo
          o  DOS and Windows ObjectBrowsers for navigating source
             code
          o  New compiler optimizations and language features
          o  Extended DOS and Windows application frameworks
          o  Over 3,800 pages of documentation with many new
             tutorials
          o  Over 4 megabytes of on-line help including the Windows
             API
    
    
       2. What are the new features of Turbo Pascal 7.0?
    
          Turbo Pascal 7.0 includes features that make it the best
          way to learn object-oriented programming.  The major new
          features of Turbo Pascal 7.0 are:
    
          o  High capacity DOS Integrated Development Environment
             (IDE)
          o  Improved IDE with color syntax highlighting and
             undo/redo
          o  ObjectBrowser for navigating source code
          o  Additional Turbo Vision objects
          o  1,500 pages of documentation with several new tutorials
          o  1 megabyte of on-line help with copy-and-paste examples
    
    
       3. What's the difference between Borland Pascal with Objects
          7.0 and Turbo Pascal 7.0?
    
          Borland Pascal with Objects 7.0 includes features aimed at
          professional DOS and Windows programmers including the
          ability to create DOS Protected Mode (DPMI) applications,
          DOS Dynamic Link Libraries (DLLs), as well as a more
          complete set of professional tools including Turbo
          Debugger, Turbo Profiler, Turbo Assembler.
    
          Turbo Pascal 7.0 is a subset of Borland Pascal with Objects
          and includes the ability to create DOS real mode programs. 
          It includes the high capacity IDE, ObjectBrowser and
          extended Turbo Vision application framework, but does not
          support DOS Protected Mode (DPMI) or Windows development.
    
    
       4. Who uses Pascal?
    
          Borland has shipped over 2,000,000 units of Pascal.  The
          largest segment of Pascal customers is professional
          programmers, who make up 40% of the market.  Pascal is
          widely used for internal corporate application development,
          by consultants and VARs in vertical markets such as
          health-care and construction and by commercial "shrink
          wrap" software developers.  Borland Pascal with Objects 7.0
          is targeted directly to professional programmers who want
          high productivity development for DOS and Windows.
    
          Pascal is also the most popular language for learning
          structured and object-oriented programming.  Turbo Pascal
          7.0 is targeted at new programmers who want the fastest way
          to learn object-oriented programming.
    
    
       5. Are there commercial applications written in Pascal?
    
          There are many commercial "shrink wrap" software products
          written in Pascal.  These products include leading CAD
          packages such as Autodesk's Generic Cadd, Fast CAD, Turbo
          CAD, Claris' Filemaker Pro for Windows, leading tax
          preparation software such as Tax Cut, Turbo Tax, Parson's
          Personal Tax Edge, financial packages such as Money   
          Counts, communications packages such as QModem, Tapcis,
          Ozcis and many others.
    
    
       6. Does Borland use Pascal to develop any of its products?
    
          Borland has a major commercial application under
          development using the new Borland Pascal with Objects 7.0. 
          Borland has not yet announced the name of the application
          being developed in Pascal.
    
          In addition, the DOS IDE for Borland Pascal with Objects
          7.0 is written entirely in Pascal using the Turbo Vision
          application framework.
    
    
       7. Why has the product name changed?
    
          We've called the new professional Pascal programming system
          "Borland Pascal with Objects" to reflect the professional
          positioning of the product and provide greater consistency
          with the C++ product line. Borland continues to offer Turbo
          Pascal 7.0 and Turbo Pascal for Windows 1.5 for entry level
          programmers who do not need all of the advanced
          capabilities that professionals require.
    
    
       8. What are the benefits of creating DPMI applications?
    
          By using Borland Pascal with Objects 7.0 you can create DOS
          Protected Mode (DPMI) applications that break through the
          640K barrier and access up to 16 megabytes of memory for
          code and data.  This gives you higher capacity for dealing
          with larger amounts of data for more efficient processing.
    
    
       9. How do you create DPMI applications?
    
          You can simply select the Compile Target menu choice to DOS
          protected mode and recompile existing programs.  The
          compiler will create an EXE with a real-mode stub that
          automatically loads the DPMI server and runtime manager and
          then switches to protected mode and runs your program.
    
    
       10.What DPMI technology do you use?  Is there a royalty
          charge?
    
          The DOS extender is fully compatible with the DPMI
          specification and is based entirely on Borland technology
          and was used in the latest version of Borland's Paradox 4.0
          database.  No royalty payments or runtime charges are
          required to distribute protected-mode applications written
          with Borland Pascal with Objects 7.0.
    
    
       11.What is the benefit of DOS DLLs?  How do you use them?
    
          By creating programs as Dynamic Link Libraries (DLLs) you
          are able to share the same source code and binary file
          between both DOS and Windows programs.  For example, a
          typical business application might be constructed with a
          DOS Turbo Vision user interface and a Dynamic Link Library
          that does "back end" computation and data processing.  The
          back end DLL can be shared with a Windows version of the
          program that uses an ObjectWindows user interface.  The
          source code to the DLL does not require any changes to work
          in Windows and, in fact, does not even need to be
          recompiled to work in Windows.
    
          In the same way, you can compile C or C++ code as a Dynamic
          Link Library using Borland C++ or any other compiler and
          link that code into Windows or DOS applications written
          with Borland Pascal with Objects.  No other language offers
          the ability to create and link to
          DOS and Windows DLLs.
    
    
       12.What are the new optimizations in Borland Pascal with
          Objects 7.0?
    
          Several new compiler optimizations have been added so that
          existing programs can be recompiled for faster performance. 
          These include 32 bit LongInt math operations, redundant
          pointer load suppression, optimized sets, constant
          parameters and faster string and file I/O routines.
    
    
       13.Does Borland Pascal with Objects 7.0 include visual
          resource editing?
    
          Yes, Borland Pascal with Objects 7.0 includes Borland's
          Resource Workshop, a fast, powerful way to visually created
          user interface elements including menus, dialogs, bitmaps,
          cursors, icons and so on. There are also third party visual
          resource editing tools available for use with Turbo Vision,
          including Blaise's Turbo Vision Development Toolkit.
    
    
       14.Do developers need to buy the Microsoft Windows Software
          Development Kit (SDK) to use Borland Pascal with Objects
          7.0?
    
          No, Borland Pascal with Objects includes everything you
          need to develop DOS and Windows applications.  It is fully
          compatible with Windows 3.0 and 3.1.  It includes:
          o  Windows Integrated Development Environment
          o  Borland Pascal with Objects command line compiler
          o  Windows 3.1 interface files
          o  ObjectWindows application framework
          o  Resource Workshop
          o  WinSight
          o  WinSpector
          o  Resource Compiler
          o  Help Compiler
          o  Turbo Help hypertext system
          o  Sample programs
          o  Complete Windows tutorials
    
    
       15.Does Borland Pascal with Objects 7.0 include help on new
          Windows 3.1 API functions?
          The on-line Turbo Help system has been completely expanded
          to provide more detailed descriptions of Windows API
          functions as well as new entries for all new Windows 3.1
          features.  There are over 4 megabytes of on-line help.  In
          addition, we are making available a complete printed
          reference 3 volume set of all Windows API calls for $39.95.
          This three volume set includes Pascal definitions of all
          API calls and data structures.
    
    
       16.Is the Runtime Library Source Code included?
    
          As a special bonus to purchasers of Borland Pascal with
          Objects 7.0, we will include in all upgrades a retail
          purchases the Application Frameworks and Runtime Library
          Source Code.  This includes the complete source code to the
          Turbo Vision and ObjectWindows application frameworks and
          is a $195 value.
    
    
       17.Is there a CASE tool for Pascal?  What is Protogen?
    
          Since there are many professional programmers who are new
          to Windows development, Borland will be making available a
          version of the Protogen CASE tool that generates Pascal
          source code.  Protogen allows developers to draw their user
          interface in Windows and then automatically generate much
          of the standard Windows code that is required.  This makes
          it much easier to get started in Windows and
          object-oriented programming.  Protogen will be made
          available for the special price of $49.95 to purchasers of
          Borland Pascal with Objects 7.0.
    
    
       18.Does Borland Pascal with Objects work with the new Paradox
          Engine?
    
          Yes Borland Pascal with Objects works with the latest
          version of the Paradox Engine 3.0.  Paradox Engine 3.0
          includes support for real mode, DOS protected mode (DPMI)
          and Windows application development in Pascal.  It also
          includes a complete object-oriented database framework for
          Pascal programmers as well as faster and more memory    
          efficient performance.  Paradox Engine 3.0 is available
          separately.
    
    
       19.What is the minimum hardware configurations for Borland
          Pascal with Objects 7.0 and Turbo Pascal 7.0?
    
          Borland Pascal with Objects 7.0 requires an 80286 or higher
          processor, 2 megabytes of memory, a hard disk.  For Windows
          development you must also have Windows 3.0 or later,
          graphics (EGA, Hercules, VGA or higher resolution) and a
          mouse.
    
          Turbo Pascal 7.0 requires 720K of disk space and 512K of
          memory.  A hard disk and 80286 or higher processor is
          required to use the high-capacity IDE.
    
    
       20.How do the new products affect the existing product line?
    
          Borland Pascal with Objects 7.0 and Turbo Pascal 7.0
          replace the existing Turbo Pascal Professional 6.0 and
          Turbo Pascal 6.0 products. Turbo Pascal for Windows 1.5
          remains on the market as an entry level object-oriented
          programming system for Windows.
    
    
       21.What is the pricing and availability?
    
          Borland Pascal with Objects 7.0 has a suggested retail
          price of $495.00.  Upgrades from any previous version of
          Turbo Pascal for DOS or Windows to Borland Pascal with
          Objects 7.0 are $149.95. As a special bonus, Borland Pascal
          with Objects 7.0 includes the Application Frameworks and
          Runtime Library source code, a $195 value.
    
          Turbo Pascal 7.0 has a suggested retail price of $149.95.
          Upgrades from any previous version of Turbo Pascal for DOS
          or Windows to Turbo Pascal 7.0 is $89.95.
    
          Both products will ship November 2, 1992.
    
    =================================================================
    
    
    

    external by Ciaran Downey modified May 15, 2015  24212  0  3  0

    Solving the blowing fuses problem in Pascal

    Solving the blowing fuses problem in Pascal: fuses.pas
    program Fuses;
    
    {
    The input consists of several test cases. Each test case describes a set of
    electrical devices and gives a sequence of turn on/off operations for these
    devices.
    
    The input will be terminated by a test case starting with n = m = c = 0. This
    test case should not be processed.
    }
    
    type
        { Device represents anything that can draw power }
        Device = record
            turnedOn : boolean;
            consumption : integer;
        end;
    
        { Circuit represents a collection of Devices. It has a maximum draw
        (capacity) }
        Circuit = record
            capacity : integer;
            state : array of Device; { resizable array }
        end;
    
    var
        n, m, c, i, j, currentDraw, maximum, seqNum : integer;
        tcircuit : Circuit;
    
    begin
        seqNum := 1;
        repeat { loop while n, m, and c are not all == 0 }
            {
            The first line of each test case contains three integers n, m and c, where
            n is the number of devices (n <= 20), m the number of operations performed
            on these devices and c is the capacity of the fuse (in Amperes).
            }
            read(n); read(m); read(c);
            if (n = 0) and (m = 0) and (c = 0) then break;
    
            setLength(tcircuit.state, n);
            tcircuit.capacity := c;
    
            {
            The following n lines contain one positive integer ci each, the consumption
            (in Amperes) of the i-th device.
            }
            for i := 0 to n - 1 do
            begin
                read(tcircuit.state[i].consumption);
                tcircuit.state[i].turnedOn := false;
            end;
    
            {
            This is followed by m lines also containing one integer each, between 1 and
            n inclusive. They describe a sequence of turn on/turn off operations
            performed on the devices. For every number, the state of that particular
            devices is toggled, i.e. if it is currently running, it is turned off, and
            if it is currently turned off, it will by switched on. At the beginning all
            devices are turned off.
            }
            maximum := 0;
            for i := 1 to m do
            begin
                read(j); dec(j); { 0-based indices, but the input is 1-based }
    
                tcircuit.state[j].turnedOn := not tcircuit.state[j].turnedOn;
    
                currentDraw := 0;
                for j := 0 to Length(tcircuit.state) - 1 do
                begin
                    if tcircuit.state[j].turnedOn then
                        currentDraw := currentDraw + tcircuit.state[j].consumption;
                end;
    
                if currentDraw > maximum then maximum := currentDraw;
            end;
    
            { print out the summary }
            writeln('Sequence ', seqNum);
            if maximum > tcircuit.capacity then
                writeln('Fuse was blown.')
            else
            begin
                writeln('Fuse was not blown.');
                writeln('Maximal power consumption was ', maximum, ' amperes.')
            end;
    
            writeln();
    
            inc(seqNum);
        until false;
    end.
    
    

    external by JonatasMA modified Jun 12, 2016  337  0  3  0

    Programa feito em pascal (Pascalzim) para realizar o calculo de hidden power.

    Programa feito em pascal (Pascalzim) para realizar o calculo de hidden power.: Hidden_Power_Pokemon.pas
    program Hidden_Power_Calculator;
    
    {Utilizado para calcular o hidden power de um pokémon
    Fontes de dados: Bulbapedia, PokémonDB e Psypoke}
    
    const
    n = 2;
    dm = 4;
    
    var
    //IV's para calcular o tipo
    a, b, c, ei, f, d: integer;
    
    //Variaveis para o calculo do poder (power)
    u, v, w, y, z, x: integer;
    
    //Variaveis de informação
    HP, power : integer; 
    type2 : string;
    
    //Variavel de controle
    submenu : string;
    
    begin
      while (submenu<>'v') do
      begin
        writeln ('-------------------------------------------------------------------------------');
        writeln ('||                        Calculadora de Hidden Power                        ||');
        writeln ('-------------------------------------------------------------------------------');
        
        // Lê a iv de HP e faz parte dos calculos
        repeat
          write ('Informe a IV de HP.........: ');
          readln (a);
        until (a>=0)and(a<=31);
        u := a mod dm;
        if ((u = 2) or (u = 3)) then begin
          u := 1;
        end else begin
          u := 0;
        end;
        a := a mod n;
        
        // Lê a IV de attack e faz parte dos calculos
        repeat
          write ('Informe a IV de Attack.....: ');
          readln (b);
        until (b>=0)and(b<=31);
        v := b mod dm;
        if ((v = 2) or (v = 3)) then begin
          v := 1;
        end else begin
          v := 0;
        end;
        b := b mod n;
        
        //Lê a IV de defense e faz parte dos calculos
        repeat
          write ('Informe a IV de Defense....: ');
          readln (c);
        until (c>=0)and(c<=31);
        w := c mod dm;
        if ((w = 2) or (w = 3)) then begin
          w := 1;
        end else begin
          w := 0;
        end;
        c := c mod n;
        
        //Lê a IV de sp.attack e faz parte dos calculos
        repeat
          write ('Informe a IV de Sp.Attack..: ');
          readln (ei);
        until (ei>=0)and(ei<=31);
        y := ei mod dm;
        if ((y = 2) or (y = 3)) then begin
          y := 1;
        end else begin
          y := 0;
        end;
        ei := ei mod n;
        
        //Lê a IV de sp.defense e faz parte dos calculos
        repeat
          write ('Informe a IV de Sp.Defense.: ');
          readln (f);
        until (f>=0)and(f<=31);
        z := f mod dm;
        if ((z = 2) or (z = 3)) then begin
          z := 1;
        end else begin
          z := 0;
        end;
        f := f mod n;
        
        //Lê a iv de speed e faz parte dos calculos
        repeat
          write ('Informe a IV de Speed......: ');
          readln (d);
        until (d>=0)and(d<=31);
        x := d mod dm;
        if ((x = 2) or (x = 3)) then begin
          x := 1;
        end else begin
          x := 0;
        end;
        d := d mod n;
        
        //Calculos
        HP := ((((32*f) + (16*ei) + (8*d) + (4*c) + (2*b) + (a))*15)div 63);
        power := (((((1*u) + (2*v) + (4*w) + (8*x) + (16*y) + (32*z))*40) div 63) + 30);
        
        //Descreve o tipo
        case HP of
          0 :
          type2 := 'FIGHTING';
          
          1 :
          type2 := 'FLYING';
          
          2 :
          type2 := 'POISON';
          
          3 :
          type2 := 'GROUND';
          
          4 :
          type2 := 'ROCK';
          
          5 :
          type2 := 'BUG';
          
          6 :
          type2 := 'GHOST';
          
          7 :
          type2 := 'STEEL';
          
          8 :
          type2 := 'FIRE';
          
          9 :
          type2 := 'WALTER';
          
          10 :
          type2 := 'GRASS';
          
          11 :
          type2 := 'ELECTRIC';
          
          12 :
          type2 := 'PSYCHIC';
          
          13 :
          type2 := 'ICE';
          
          14 :
          type2 := 'DRAGON';
          
          15 :
          type2 := 'DARK';
          
        end;
        //Mostra o resultado
        writeln (' ');
        writeln ('-------------------------------------------------------------------------------');
        writeln ('Hidden Power ', HP, ' tipo ', type2, ' com poder ', power);
        writeln ('-------------------------------------------------------------------------------');
        writeln (' ');
        writeln ('-------------------------------------------------------------------------------');
        writeln ('||                             Você deseja fazer?                            ||');
        writeln ('||                  [V]oltar ou continuar na [C]alculadora                   ||');
        writeln ('-------------------------------------------------------------------------------');
        repeat
    		read (submenu);
    		until (submenu = 'v') or (submenu = 'c');
        clrscr
      end;
    end;
    
    
    

    external by Andrei Glingeanu modified Apr 9, 2017  3  0  1  0

    Compute Nth Pascal row with Mozart language: https://en.wikipedia.org/wiki/Pascal%27s_triangle

    Compute Nth Pascal row with Mozart language: https://en.wikipedia.org/wiki/Pascal%27s_triangle: pascal.ozf
    % 1:    1
    % 2:   1 1
    % 3:  2 1 1
    % 4: 1 3 3 1
    % N:
    declare Pascal AddList ShiftLeft ShiftRight
    fun {Pascal N}
       if N==1 then [1]
       else
          {AddList {ShiftLeft {Pascal N - 1}}
                   {ShiftRight {Pascal N - 1}}}
       end
    end
    
    fun {ShiftLeft L}
       case L of H | T then
          H | {ShiftLeft T}
       else
          [0]
       end
    end
    
    fun {ShiftRight L}
       0 | L
    end
    
    fun {AddList L1 L2}
       case L1 of H1 | T1 then
          case L2 of H2 | T2 then
    	 H1 + H2 | {AddList T1 T2}
          else
    	 nil
          end
       else
          nil
       end
    end
    
    {Show {Pascal 5}}
    
    
    • Public Snippets
    • Channels Snippets