Sunday, December 29, 2019

How to Manipulate INI files from Delphi

INI files are text-based files used for storing an applications configuration data. Even though Windows recommends using the Windows Registry to store application-specific configuration data, in many cases, youll find that INI files provide a quicker way for the program to access its settings. Windows itself even uses INI files;  desktop.ini  and boot.ini  being just two examples. One simple use of INI files  as a status saving mechanism would be to save the size and location of a form if you want a form to reappear at its previous position. Instead of searching through a whole database of information to find the size or location, an INI file is used instead. The INI File Format Initialization or Configuration Settings file (.INI) is a text file with a 64 KB limit divided into sections, each containing zero or more keys. Each key contains zero or more values. Heres an example: [SectionName] keyname1value ;comment keyname2value Section names are enclosed in square brackets and must begin at the beginning of a line. Section and key names are case-insensitive (the case doesnt matter), and cannot contain spacing characters. The key name is followed by an equal sign (), optionally surrounded by spacing characters, which are ignored. If the same section appears more than once in the same file, or if the same key appears more than once in the same section, then the last occurrence prevails. A key can contain string, integer, or boolean value.​ Delphi IDE uses the INI file format in many cases. For example, .DSK files (desktop settings) utilize the INI format. TIniFile Class Delphi provides the TIniFile class, declared in the inifiles.pas unit, with methods to store and retrieve values from INI files. Prior to working with the TIniFile methods, you need to create an instance of the class: uses inifiles; ... var   Ã‚  IniFile : TIniFile; begin   Ã‚  IniFile : TIniFile.Create(myapp.ini) ; The above code creates an IniFile object and assigns myapp.ini to the only property of the class — the FileName property — used to specify the name of the INI file you are to use. The code as written above looks  for the myapp.ini file in the \Windows directory. A better way to store application data is in the applications folder - just specify the full pathname of the file for the Create method: // place the INI in the application folder, // let it have the application name // and ini for extension: iniFile : TIniFile.Create(ChangeFileExt(Application.ExeName,.ini)) ; Reading From INI The TIniFile class has several read methods. The ReadString reads a string value from a key, ReadInteger. ReadFloat and similar are used to read a number from a key. All read methods have a default value that can be used if the entry does not exist. For example, the ReadString is declared as: function ReadString(const Section, Ident, Default: String): String; override; Write to INI The TIniFile has a corresponding write method for each read method. They are WriteString, WriteBool, WriteInteger, etc. For example, if we want a program to remember the name of the last person who used it, when it was, and what the main form coordinates were, we might establish a section called Users, a keyword called Last, Date  to track the information, and a section called Placement  with keys Top,  Left,  Width, and Height. project1.ini   [User]   LastZarko Gajic   Date01/29/2009   [Placement]   Top20   Left35   Width500   Height340 Note that the key named Last holds a string value, Date holds a TDateTime value, and all keys in the Placement section hold an integer value. The OnCreate event of the main form is the perfect place to store the code needed to access the values in the applications initialization file: procedure TMainForm.FormCreate(Sender: TObject) ; var   Ã‚  appINI : TIniFile;   Ã‚  LastUser : string;   Ã‚  LastDate : TDateTime; begin   Ã‚  appINI : TIniFile.Create(ChangeFileExt(Application.ExeName,.ini)) ;   Ã‚  try   Ã‚  Ã‚  Ã‚  //if no last user return an empty string   Ã‚  Ã‚  Ã‚  LastUser : appINI.ReadString(User,Last,) ;   Ã‚  Ã‚  Ã‚  //if no last date return todays date   Ã‚  Ã‚  Ã‚  LastDate : appINI.ReadDate(User, Date, Date) ;   Ã‚  Ã‚  Ã‚  //show the message   Ã‚  Ã‚  Ã‚  ShowMessage(This program was previously used by LastUser on DateToStr(LastDate));   Ã‚  Ã‚  Ã‚  Top : appINI.ReadInteger(Placement,Top, Top) ;   Ã‚  Ã‚  Ã‚  Left : appINI.ReadInteger(Placement,Left, Left);   Ã‚  Ã‚  Ã‚  Width : appINI.ReadInteger(Placement,Width, Width);   Ã‚  Ã‚  Ã‚  Height : appINI.ReadInteger(Placement,Height, Height);   Ã‚  finally   Ã‚  Ã‚  Ã‚  appINI.Free;   Ã‚  end; end; The main forms OnClose event is ideal for the Save INI part of the project. procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction) ; var   Ã‚  appINI : TIniFile; begin   Ã‚  appINI : TIniFile.Create(ChangeFileExt(Application.ExeName,.ini)) ; try   Ã‚  Ã‚  Ã‚  appINI.WriteString(User,Last,Zarko Gajic) ;   Ã‚  Ã‚  Ã‚  appINI.WriteDate(User, Date, Date) ;   Ã‚  Ã‚  Ã‚  with appINI, MainForm do   Ã‚  Ã‚  Ã‚  begin   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  WriteInteger(Placement,Top, Top) ;   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  WriteInteger(Placement,Left, Left) ;   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  WriteInteger(Placement,Width, Width) ;   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  WriteInteger(Placement,Height, Height) ;   Ã‚  Ã‚  Ã‚  end;   Ã‚  finally   Ã‚  Ã‚  Ã‚  appIni.Free;   Ã‚  end; end; INI Sections The EraseSection erases an entire section of an INI file. ReadSection and ReadSections fill  a TStringList object with the names of all sections (and key names) in the INI file. INI Limitations Downsides The TIniFile class uses the Windows API  which imposes a limit of 64 KB on INI files. If you need to store more than 64 KB of data, you should use the TMemIniFile. Another problem might arise if you have a section with more than 8 K value. One way to solve the problem is to write your own version of the ReadSection method.

Saturday, December 21, 2019

Krispy Kreme Microeconomic Analysis Dozen Glazed Donuts

Krispy Kreme Microeconomic Analysis: Dozen Glazed Donuts Elizabeth Reel GM 545 Ben Gruszczyk Introduction Krispy Kremes glazed donuts are a tasty treat especially hot out of the oven. Thousands of people enjoy this delectable delight every day. Knowing this I will attempt to analyze the microeconomics of a dozen glazed donuts at a weekly basis. I will be covering terminal course objectives A through D. The TCOs are as follows: TCO A- Illustrate how the price mechanism, in response to changes in other demand or supply factors leads to a new market equilibrium price and level of output. TCO B- Given appropriate marketing data, including price elasticity coefficients, demonstrate how to use this information in product pricing†¦show more content†¦There is no TR test for the elasticity of supply, price and TR always move together. Marginal Analysis Total Quantity TFC TVC TC ATC MC TR (price=$4.40) Profit or Loss 260,000 $150,000 $150,000 $300,000 $1.15 $.71 $1,170,000 870,000 190,000 150,000 100,000 250,000 1.32 .1 855,000 605,000 120,000 150,000 93,000 243,000 2.03 .73 540,000 297,000 75,000 150,000 60,000 210,000 2.8 1.4 337,500 127,500 50,000 150,000 25,000 175,000 3.5 .5 225,000 50,000 0 150,000 0 150,000 0 (150,000) From the above information (which is fictional data), we can assume that the breakeven point is somewhere between 75,000 and 120,000 dozen donuts produced, and the more they produce the more profit they will have. That is if they have a set price of $4.50 per dozen. In evaluating this data, I think that Krispy Kreme should and will stay in business due to the fact that the profit potential is very high. Competitive Market This last TCO asks us to discuss optimal output levels for a competitive firm versus an imperfectly competitive firm. I do not think that this applies to this particular firm due to the fact that there are so many producers of glazed donuts in all competitive markets. There are no donut monopolies and I doubt that any antitrust laws will be broken by Krispy Kreme now or in the near future. NOTE: With the exception of the current selling

Friday, December 13, 2019

Stakeholder Free Essays

This report is focusing mainly on the identification of stakeholders in the canadian rockies, asses their inetrests, goals, and priorities in a sustainable way, assessing the effectiveness of current strategies for stakeholders management, Analyse it, focus on the level of power of each stakeholder. And finally, look into what their stake is, every stakeholder have a stake for which its level of interest is attached. Stakeholder is the group or the body that can affect or be affected directly or indirectly by the action of the business as a whole Bleasdale Module class 3rd week, and Stakeholders Analysis (SA) is the â€Å"identification of a projects key stakeholders, an assessment of their interests and the ways in which these interests affect project riskiness and viability† (DfiD, 1995). We will write a custom essay sample on Stakeholder or any similar topic only for you Order Now Buttresing this point on Stakeholders Analysis, Grimble and welllard define stakeholders analysis as â€Å"a historical approach or procedure for gaining an understanding of a system and assesing the impact of changes to that system† cited in Hardy and Beeton: pg175. And Freeman’s 1984 book Strategic Management – A Stakeholder Approach is often cited as the pivotal study that gave the Stakeholder analysis its momentum as an issue of importance in the organisational context (Freeman and McVea, 2001; Kaler, 2004). Sustainable tourism can simply be defined as Therefore, Canadian Stakeholders are very important when Tourism is critically analysed in Canada, Stakeholders are the most essential group that deal directly with the tourism of any country, proceeding to analysing powerful stakeholders in canada ranging from the the Aboriginals which are the indiginous first people, the Canadian Governments, Tourists, Host Community, Media, British columbia state Governments, Local Authorities and National Park Authorities just to mention a few. How to cite Stakeholder, Essay examples