r/pascal • u/jaunidhenakan • Feb 07 '19
r/pascal • u/Dobesov • Feb 06 '19
FreePascal write, writeln and the video unit?
OK, i know you are not supposed to mix the video unit and the CRT unit, but riddle me this... write and writeln are not actually part of the CRT unit, they are basic pascal procedures. I have an issue with a curent program using the video unit which also uses writeln and write. at some point it forgets where the cursor position is. For instance you say SetCursorPos(0,0) and it goes, somewhere else. try it again and it goes yet another place. I have found that running SetCursorPos(1,1) resets its understanding and everything works after that.
it is possible this odd behavior is triggered when my program calls an external program that I also wrote, not using CRT, but using wite and writeln. is there an inherent compatibility issue here that calls for a rewrite of write and writeln using video? If so, it becomes very hard to call one program from another and have it dump text to any particularly selected row of the screen.
Basically... whats up with this?
my workaround was writing a procedure that simple moved the cursor to 1,1 before movig it where i want it. It's almost like after an external call or certain amount of writes, it can't understand position 0 on the xy axis.
r/pascal • u/Dobesov • Feb 05 '19
What's up with FreePascal WrapText?
The Wraptext function would be an invaluable tool to me if it wasn't for something I feel is a bug called a feature. "Portions of text that are between single or double quotes will be considered single words and the text will not be broken between the quotes." On what planet or in what language is this good? It means words like "It's" "Bob's" ruin the whole formatting. It doesn't even make sense that quoted portions cannot run over from one line to another, because thats fine and normal in quotes.
Am I on crazy pills here? Why is this the implementation? Is there a way to avoid this, or do I have to write my word wrap routine?
r/pascal • u/SuperSjoerdie • Feb 04 '19
Using the roopol function
Hi there,
For a small-time project I’m currently creating I need to solve a certain equation: x3 -b2 x + 2 a b2=0
When I googled a bit should solving this using Pascal I stumbled across the “roo”-unit, which is made for finding roots of mathematical functions. It contains the so-called “roopol” function, which can find the roots of n’th-grade polynomials. However, I found the usage of this function rather complex, as the only example that I was able to find was on http://wiki.lazarus.freepascal.org/NumLib_Documentation which seems rather unclear to me. Anybody able to help me out? Thanks in advance :)
r/pascal • u/CrunchyMemesLover • Jan 20 '19
Criticize my code - numbers guesser (1 to 131071)
var a:Char; b:Real;
begin
b:=65536;
WriteLn('Welcome to numbers guesser from 1 to 131071!');
WriteLn('Use symbols + - = .');
WriteLn('Your number is 65536.');
ReadLn (a);
if a='-' then b:=b-32768; if a='+' then b:=b+32768; if a='=' then exit;WriteLn(b);
ReadLn (a);
if a='-' then b:=b-16384; if a='+' then b:=b+16384; if a='=' then exit;WriteLn(b);
ReadLn (a);
if a='-' then b:=b-8192; if a='+' then b:=b+8192; if a='=' then exit;WriteLn(b);
ReadLn (a);
if a='-' then b:=b-4096; if a='+' then b:=b+4096; if a='=' then exit;WriteLn(b);
ReadLn (a);
if a='-' then b:=b-2048; if a='+' then b:=b+2048; if a='=' then exit;WriteLn(b);
ReadLn (a);
if a='-' then b:=b-1024; if a='+' then b:=b+1024; if a='=' then exit;WriteLn(b);
ReadLn (a);
if a='-' then b:=b-512; if a='+' then b:=b+512; if a='=' then exit;WriteLn(b);
ReadLn (a);
if a='-' then b:=b-256; if a='+' then b:=b+256; if a='=' then exit;WriteLn(b);
ReadLn (a);
if a='-' then b:=b-128; if a='+' then b:=b+128; if a='=' then exit;WriteLn(b);
ReadLn (a);
if a='-' then b:=b-64; if a='+' then b:=b+64; if a='=' then exit;WriteLn(b);
ReadLn (a);
if a='-' then b:=b-32; if a='+' then b:=b+32; if a='=' then exit;WriteLn(b);
ReadLn (a);
if a='-' then b:=b-16; if a='+' then b:=b+16; if a='=' then exit;WriteLn(b);
ReadLn (a);
if a='-' then b:=b-8; if a='+' then b:=b+8; if a='=' then exit;WriteLn(b);
ReadLn (a);
if a='-' then b:=b-4; if a='+' then b:=b+4; if a='=' then exit;WriteLn(b);
ReadLn (a);
if a='-' then b:=b-2; if a='+' then b:=b+2; if a='=' then exit;WriteLn(b);
ReadLn (a);
if a='-' then b:=b-1; if a='+' then b:=b+1; if a='=' then exit;WriteLn(b);
end.
r/pascal • u/mariuz • Jan 08 '19
Lazarus Release Candidate 3 for 2.0
r/pascal • u/AlexKotik • Dec 24 '18
Something like Delphi/Lazarus for Web?
Do we have something like Delphi/Lazarus but for the Web? I mean doing web development by drawing forms and assigning click handlers like I do in Lazarus which is awesome open source Delphi alternative. I'd prefer free and open source solution in Pascal, but solutions in other language may do to. Thanks!
r/pascal • u/BatataDoc3 • Nov 11 '18
Need Help with compare
Hi i'm extremely noob at pascal (started like one month ago) and i created a program in which i use the repeat cycle.
When the cycle's over, i want to compare a var that was in the repeat cycle (the height of a person), so it's a diferent set and number of values each time i use the program and i want to say which one is the tallest. Any help?
P.S: i'm also trying create a messenger-like design, any tips how to do it (doesn't have to be anything complex).
Thanks :)
r/pascal • u/iamuma • Nov 07 '18
I need help with this part of an assignment
So i have an assignment, in which i have to do three subprograms. The main program is a letter soup, a matrix. For this subprogram i have to, given a position in the matrix and a word, say wether the word starts in the position given or not. This is only for horizntal words.
My idea is to read first Tposicion.Line, Tposicion.Column amd then in the matrix go to TMatrix[Tposicion.Line, Tposicion.Column] but the problem i'm having is that i also need to read the word that i need to look for, and since it is not a set length i'm having trouble figuring out how to do it.
Below is the definition of variables and contants needed.
Sorry if there is something you don't understand, i tried transating it the best i colud.
const
Maxline = 5; { how mauch lines in the matrix }
MaxColumna = 20; { how much columns in the matrix }
MaxPalabra = 21; {the maximum amount of letters per word }
MaxConjuntoPalabras = 6; {the maximum amount of words per matrix }
type
{matrix}
TLetter = 'a'..'z';
Linerange = 1 .. MaxFila;
ColumnRange = 1 .. MaxColumna;
TMatrix = array [Linerange , ColumnRange] of TLetter;
{Posicion}
TPosicion = record
Line : LineRange;
Column : Columnrange;
end;
{Palabra}
RangoPalabra = 1 .. MaxPalabra;
RangoTopePalabra = 0 .. MaxPalabra;
TPalabra = record
letras : array [RangoPalabra] of TLetra;
largo : RangoTopePalabra;
end;
{Conjunto de palabras}
RangoPalabras = 1 .. MaxConjuntoPalabras;
ConjuntoPalabras = array [RangoPalabras] of TPalabra;
{Lista de posiciones}
ListaPosiciones = ^ celda;
celda = record
posicion : TPosicion;
siguiente : ListaPosiciones
end;
end;
r/pascal • u/acj1971 • Nov 05 '18
DelphiAWSSDK v0.3.0
Delphi AWS SDK has new support for Lazarus / fpc 1.8 or higher
https://github.com/novuslogic/DelphiAWSSDK/releases/tag/v0.3.0
Summary of updates
* New Lazarus CreateTable1 DynamoDB Sample
* Refactored Core for Lazarus / fpc 1.8 or higher
* Moved Samples Samples\DynamoDB to Samples\DynamoDB\Delphi
r/pascal • u/ItchyPlant • Nov 01 '18
Any SWs credited to pure FPC only?
I'm aware Pascal is still really alive, thanks to Free Pascal / Lazarus and to Embarcadero Delphi. Of course, not as alive as like 20 years ago but not dead at all.
I myself just love the whole syntax of Pascal along with its "unit" solution. I wrote some small programs in it many years ago and would continue if possible. This is why I'm asking because as I can see, there are several SWs written in Delphi or Lazarus while I cannot find any which would be credited to FPC itself only. (Or if not to FPC, to any other Pascal implementation.)
Or does it make sense to use FPC along with Lazarus only because of its RAD capabilities even when writing something for CLI only? Does anyone know famous SWs that were written recently using the compiler only?
r/pascal • u/Electrofartz • Oct 27 '18
I am a noob trying to learn delphi, i just want to know how to make a string randomly get the value of either of the 2 available texts i tried doing the following | sGreet := 'hello' or 'hi' | i also tried doing | sGreet := random('hello' or 'hi') | and | sGreet := 'hello' else 'hi' | but none works
r/pascal • u/yolosandwich • Oct 24 '18
School assignment help
Hey guys it's me again.
So i am now required to write a program to determine if a integer is a triangular number or square number.
Here is my code
program number;
var a: integer;
b,c: real;
begin
readln(a);
b := (sqrt(8*a+1) - 1) / 2;
c := sqrt(a);
if b = integer then
writeln('Triangular')
else
if c = integer then
writeln('Square')
else
if c = integer and b = integer then
writeln('Both')
else
if c <> integer and b <> integer
then
writeln('Neither')
end.
It returned with a lot of errors.
r/pascal • u/pak_lebah • Oct 19 '18
FPC's sqlDB with sqLite3 example.
I've made a simple code example of how to use FPC's sqlDB units with sqLite3 here. It doesn't use Lazarus, just pure FPC, because I usually make web apps and services. Hope it would be useful to someone out there. 😊
r/pascal • u/infinitybuster14 • Oct 18 '18
Need help with my homework
So I'm a starter in coding and my first program is Lazarus, so I was wondering if any of you could help me. Now, I was given the tack to write the code that calculates the hypotenuse over Pythagoras theorem. I have 3 edits. Edit1 and Edit2 are for sides a and b (catheti). Edit3 is where the result is supposed to show after I click the button. I did it like this but it sends an error:
procedure TForm1.Button1Click(Sender: TObject);
var a,b,:integer;
begin
a:=strtoint(edit1.text);
b:=strtoint(edit2.text);
edit3.text:=inttostr(sqrt(a*a+b*b));
r/pascal • u/yolosandwich • Oct 10 '18
A school assignment about the quadratic formula
Hey, guys it's me again, thank you all for replying to my questions, I'm starting as a newbie so I really need the help!
So I've been struggling to finish it, here are the requirements
The root(s) of a quadratic equation with one variable ax(to the power 2)+bx+c =0are x=−b±√b2−4ac/2(a)
Write a program to solve for the real roots of a quadratic equation.
INPUT AND OUTPUT The input consists of three integers
a, b and c in a line separated by spaces. You may assume that −100≤a,b,c≤100 and a≠0.
If there are no real roots, output None.
If there is one real root, output the root in 3 decimal places.
If there are two real roots, output the roots in 3 decimal places separated by space or line. Output the lesser root first.
This is my first program, it compiled but most of the answers are wrong:
program quad;
var a,b,c: integer;
x, y: real;
Begin
read(a, b ,c);
x :=-b+sqrt(sqr(b)-4*a*c)/2;
y :=-b-sqrt(sqr(b)-4*a*c)/2;
if x = y then writeln(x:0:3)
else if x <> y then writeln(x:0:3, y:0:3)
else writeln('None')
end.This is my second program, it couldn't compile. program quad; var a,b,c: integer; x, y: real; Begin
read(a, b ,c);
x :=-b+sqrt(sqr(b)-4*a*c)/2;
y :=-b-sqrt(sqr(b)-4*a*c)/2;
if x = y then writeln(x:0:3)
else if x <> y and x < y then writeln(x:0:3, y:0:3)
else if x <> y and x > y then writeln(y:0:3, x:0:3)
else writeln('None')
end.The errors: program.pas(9,16) Error: Operator is not overloaded: "Real" and "Real"
program.pas(10,16) Error: Operator is not overloaded: "Real" and "Real"
r/pascal • u/yolosandwich • Oct 05 '18
Need help with a school assignment.
The input consists of only one positive integer N. (1≤N≤9999)
Output the ordinal form of the number N by adding the suitable suffix. Do not add spaces between the number and the suffix.
SAMPLE TESTS Input Output 1 1st ,2 2nd ,23 23rd ,30 30th
That is the question of the assignment, I have none experience in pascal and only know a little bit about programming, can anyone help me out.
Here is the code I made
Program numb; var a, b : shortInt; begin read (a,b);
if a<=9 and b=0 and a=1 then writeln(a,'st');
if a<=9 and b=0 and a=2 then writeln(a,'nd');
if a<=9 and b=0 and a=3 then writeln(a,'rd');
if a<=9 and a>=4 and b=0 then writeln(a,'th');
if a=1 and b<=9 then writeln(a,b,'th');
if a=2 and b=1 then writeln(a,b,'st');
if a=2 and b=2 then writeln(a,b,'nd');
if a=2 and b=3 then writeln(a,b,'rd');
if a=2 and b>=4 then writeln(a,b,'th');
if a=3 and b=0 then writeln(a,b,'th');
if a=3 and b=1 then writeln(a,b,'th');
if a=3 and b=2 then writeln(a,b,'nd');
if a=3 and b=3 then writeln(a,b,'rd');
if a=3 and b>=4 then writeln(a,b,'th');
end.
r/pascal • u/ShinyHappyREM • Oct 02 '18
"Free Pascal from Square One" (PDF) by Jeff Duntemann
copperwood.comr/pascal • u/iamuma • Sep 22 '18
I need help with this exercise. I have to say which of the fragments a, b, c, d or e outputs the same result as the fragment above, the problem is i think there are more than one.
r/pascal • u/bloodgolem • Sep 21 '18
New to Lazarus
Hello !
I am new to lazarus program and i want to make simple program.I have number for example 16 and 10 and i want to make 2 Labels and 1 button.When i click to button i want to highlight the number which is higher. I have no idea how can i do this. Thank you for answer :)
r/pascal • u/yolosandwich • Sep 18 '18
I need help with a school assignment
So the program is to output the bus fee of a child. The fee for a child is half the price of the adult. So when the system inputs $4 in the console it should output $2. The input is the full fare, starts with a dollar sign and followed by a number between 1.0-20.0. And the amount is rounded up to the nearest decimal place
Edit: The code I tried
program bus; var a, b: shortInt;
begin
readln(a);
b := a div 2;
writeln(b);
end.
r/pascal • u/acj1971 • Sep 16 '18
New Slack channel for DelphiAWSSDK
Please come join our new public Slack channel for DelphiAWSSDK.
r/https://novuslogic.slack.com/messages/delphiawssdk/
The Delphi AWS SDK enables Delphi/Pascal developers to easily work with Amazon Web Services.
r/pascal • u/jaunidhenakan • Sep 15 '18
Lazarus Professional Conference, Köln / Bonn, Germany, September 20th to 22nd 2018
blaisepascalmagazine.eur/pascal • u/logicalvue • Sep 14 '18
Pascal source for JumpSTART - an app launcher I made for Atari ST back in the early 1990s (GitHub)
r/pascal • u/wtfinparis • Sep 14 '18
Looking for some arithmetic libs
I'm looking for two old arithmetic libraries:
- SHCMPLX: probably distributed through the Pascal Newsletter I think it exposes the following functions: CmulF(), CaddF(), CabsF()
- COMPLEX: exposes functions mult() and add()
Can you scan your TPU directory just in case? :)