pascal

How do you get the current sample rate of Windows audio playback?

邮差的信 提交于 2019-12-04 12:59:20
I am using the Windows waveOut API (aka MME or Multimedia Extension) mmsystem.h. Some programs change the audio playback sample rate (eg. from 44.1kHz to 48kHz), and it would be very useful for my program to detect the current playback sample rate, so it can warn users that Windows will be resampling the program's output. According to this documentation http://msdn.microsoft.com/en-us/library/aa909811.aspx , waveOutGetPlaybackRate returns the resampling % that the device is currently performing (eg, device plays at 44.1, and program is playing audio at 44.1 so it would return 1.0). I am

How can I detect elapsed time in Pascal?

拈花ヽ惹草 提交于 2019-12-04 10:12:50
I'm trying to create a simple game in Pascal. It uses the console. The goal in the game is to collect as many 'apples' as you can in 60 seconds. The game structure is a simple infinite loop. Each iteration, you can make one move. And here's the problem — before you make the move ( readKey ), time can pass as much as it wants. For example, the user can press a key after 10 seconds! Is there any way to count time? I need the program to know when user plays (before and after a key is pressed), so I don't know how to prevent user from "cheating". Here's simple structure of my game: begin repeat {*

Delphi: How to get (current code line, current unit, current function) without using Assertion?

冷暖自知 提交于 2019-12-04 07:55:54
I am trying to create a log system on my program that will log debugging messages on text files, and I want to save the exact place in the code where the log message called, but I don't want to use Assert function because it creates exceptions and this system is not for logging exceptions only, also I have to write some debugging info. example usning assert: procedure AnyProcedure(); begin try Assert(1=0); except on E: Exception do Log.AddLine('Log occurred is '+E.Message+' : Start');//Log occurred is "c:\progr~..jkdj.pas" at line [29] end; //....some code try Assert(1=0); except on E:

Any cool function to replace readln from pascal in ansi c?

匆匆过客 提交于 2019-12-04 05:22:46
问题 The readln reads until the end of line (enter pressed) with spaces and everything, I would like something like that but for ansi c (not c++ and need to be for linux and windows) I know that I can make a function that reads every char until the enter pressed but If there is anything cooler it would be great =D Thanks! 回答1: You can use scanf with a scanset conversion something like this: char buffer[256]; scanf("%255[^\n]", buffer); another possibility is to use fgets : char buffer[256]; fgets

Counting the number of decimal places in pascal

心已入冬 提交于 2019-12-04 02:29:55
问题 I just started studying pascal and I have to do a pascal program as homework. I made it but I don't know how to count the number of decimal places in a real number (the number of digit after the "."). I need it just to format well a real number (like write(real:0:dec) where dec is the number of decimal digit i don't know how to know). I'd like to do that because i don't want it in scientific notation or with many unnecessary zeros. For example if a real number is 1.51 (x) and I write writeln

How to do this the fastest way?

。_饼干妹妹 提交于 2019-12-04 02:16:13
问题 I need to find out how many time one word appears in the string, but the catch is that the word you need to find can have spaces in between, for example you want to see how many times word text appears in *tOeOxOt" and it would give you output 1, or for example in textt it would give you output 2, I have written this procedure in pascal for this procedure search(x:integer; i:integer); var x2:integer; begin x2:=x+1; while (x2<=n) and (x2>0) do begin if myarray[x2]=mystring[i+1] then if i

3 points are collinear in 2d

☆樱花仙子☆ 提交于 2019-12-04 01:15:15
问题 I am trying to verify when 3 points (double) are collinear in 2-D. I have found different Pascal functions that return true if this is verified; those functions use integer to specify X and Y coordinates. I need a more precise calculation at least to the first 3 digits of the decimal part of X and Y expressed as double type. Who can help me with this? I found this function: function Collinear(x1, y1, x2, y2, x3, y3: Double): Boolean; begin Result := (((x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 -

关于 C/C++ 函数调用约定

北城以北 提交于 2019-12-03 20:39:28
关于 C/C++ 函数调用约定,大多数时候并不会影响程序逻辑,但遇到跨语言编程时,了解一下还是有好处的。 VC 中默认调用是 __cdecl 方式,Windows API 使用 __stdcall 调用方式,在 DLL 导出函数中,为了跟Windows API 保持一致,建议使用 __stdcall 方式。 调用约定跟堆栈清除密切相关。如果写一个汇编函数,给 C/C++ 调用,在 __cdecl 方式下,则汇编函数无需清除堆栈,在 __stdcall 方式下,汇编函数需要在返回(RET)之前恢复堆栈。 C 语言有 __cdecl、__stdcall、__fastcall、naked、__pascal。 C++ 语言有 __cdecl、__stdcall、__fastcall、naked、__pascal、__thiscall,比 C 语言多出一种__thiscall 调用方式。 在VC中,可以设置默认的调用约定,设置路径为: Project à Properties à Configuration Properties à C/C++ à Advanced à Call Conversion。 下面详细介绍如上六种调用方式: 1、__cdecl __cdecl调用约定又称为 C 调用约定,是 C/C++ 语言缺省的调用约定。参数按照从右至左的方式入栈,函数本身不清理栈

Writing a Scheme interpreter with FPC: Recursive data structures

对着背影说爱祢 提交于 2019-12-03 17:33:53
Essentially, this is a question about recursive data structures in Pascal (FPC). As I would like to implement a Scheme interpreter like it is shown in SICP chapter 4, this question may be relevant for Schemers as well. :) S-expressions shall be represented as tagged data. So far, I have constructed a variant record, which represents numbers and pairs. Hopefully the code is readable and self-explanatory: program scheme; type TTag = (ScmFixnum, ScmPair); PScmObject = ^TScmObject; TScmObject = record case ScmObjectTag: TTag of ScmFixnum: (ScmObjectFixnum: integer); ScmPair: (ScmObjectCar,

Make an installer with text that is formatted (Partially Bold) in Inno Setup?

落爺英雄遲暮 提交于 2019-12-03 16:04:50
Anyone saw GOG.com game installer? How to make welcome text string like there including Path and Need Size in a single Caption? Where part of is bolded. Here are examples of how changes String line breaking after modifying install path You can use a TRichEditViewer setting the RFTText property and the UseRichEdit to True. Try this sample procedure CreateCustomPages; var Page : TWizardPage; rtfHelpText : TRichEditViewer; s: string; begin Page := CreateCustomPage(wpWelcome, 'Custom wizard page controls', 'Bold Demo'); Page.Surface.Align:=alCLient; s:='{\rtf1\ansi\ansicpg1252\deff0\deflang13322{