How to show a form lazarus / 61-Beginners ---------------------------------------------------------------------- Doe · 2021-01-10 13:07 Hello guys, I was trying to test my units by checking the GUI interface. I write "Introduction.ShowModal" and the code is compared, but the error message appeared. Project NEA raised exception class "External:SIGSEGV'. In file 'NEA.lpr' at line 18: Introduction.ShowModal; code below: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program NEA; {$mode objfpc}{$H+} uses  {$IFDEF UNIX}{$IFDEF UseCThreads}  cthreads,  {$ENDIF}{$ENDIF}  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Interfaces, mainmenu,  intro, mvariablecheck, wvariablecheck, InputSUVforA, InputSUVforT,  inputsuaforv, inputsuafort, inputsutforv, inputsutfora, inputsvaforu,  inputsvafort, inputsvtforu, inputsvtfora, inputsatforu, inputsatforv,  inputuvafors, inputuvafort, inputuvtfora, inputuvtfors, inputuatfors,  inputuatforv, inputvatfors, inputvatforu, at, vt, va, ut, ua, uv, st, sa, sv,  su, answers, answeru, answerv, answera, answert; begin  Introduction.ShowModal;end.    [Edited to add code tags - please see How to use the Forum.] ---------------------------------------------------------------------- Handoko · 2021-01-10 13:39 Your code does not seem to be a normal GUI application. Is it a console mode program? If it is a 'normal' GUI application you should start you project by doing this: Lazarus main menu > File > New > Project > Application Then Lazarus will auto generate the code of your main Pascal file, which should look like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1; {$mode objfpc}{$H+} uses  {$IFDEF UNIX}{$IFDEF UseCThreads}  cthreads,  {$ENDIF}{$ENDIF}  Interfaces, // this includes the LCL widgetset  Forms, unit1  { you can add units after this }; {$R *.res} begin  RequireDerivedFormResource:=True;  Application.Scaled:=True;  Application.Initialize;  Application.CreateForm(TForm1, Form1);  Application.Run;end. If you want to write console mode program that has GUI interface, that's difficult. Don't do it unless you have good reasons for it. ---------------------------------------------------------------------- lucamar · 2021-01-10 14:25 Quote from: Doe on January 10, 2021, 02:07:30 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program NEA; {$mode objfpc}{$H+} uses  {$IFDEF UNIX}{$IFDEF UseCThreads}  cthreads,  {$ENDIF}{$ENDIF}  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Interfaces, mainmenu, {... etc ...} begin  Introduction.ShowModal;end. Whatever else you're doing (or why), that there is a recipe for disaster of the type you see (SIGSEGV) unless you're absolutely sure Introduction (which I'll assume is a TForm descendant) is created in the Initialization of one of the units you use. Until you "create" an object instance you can't call any of a class's methods (and remember: a form is a class) because, simply speaking, it doesn't exists. Trying to do so leads to the normal problems of using any type before reserving memory (and for some of them other "magic"): a segmentation fault due to trying to access memory which is not there. As for the rest ..  don't know what you're trying to do but I'd follow Handoko's advice and create a GUI application like the (Pascal) gods taught us: with a Lazarus "Application" project ---------------------------------------------------------------------- Doe · 2021-01-10 17:05 I tried to use the application but I never used it before. I create a project as an application. So, where should I put the main code? I already create many units for my project but I don't know how to add them to my project. ---------------------------------------------------------------------- Handoko · 2021-01-10 18:34 GUI programs (or some call it applications) work differently as you think. In console mode programs (the things we create in the Turbo Pascal days) have a main code where we put the main loop there. There is no main code or main loop in GUI programs. To write GUI program you need to understand how the event system works. For example if you want to write a simple clock, you can use a TTimer component. Put a TTimer component on the form, then you write you code to show time on the OnTimer event. You can download an example and try to understand here: https://forum.lazarus.freepascal.org/index.php/topic,52780.msg389815.h tml#msg389815 You can study from this link below, there you can find Lazarus video tutorials in the Helpful Learning Resources section: https://wiki.freepascal.org/Portal:New_Users ---------------------------------------------------------------------- Doe · 2021-01-10 19:12 I made a menu and I want the program to show the introduction page after I choose Introduction and click confirm. The program shows the main menu but when I click the confirm, Error message 'Project NEA raised exception class "External:SIGSEGV'.' How to solve this? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program projectNEA; {$mode objfpc}{$H+} uses  {$IFDEF UNIX}{$IFDEF UseCThreads}  cthreads,  {$ENDIF}{$ENDIF}  Interfaces, // this includes the LCL widgetset  Forms, PNEA,  mainmenu  { you can add units after this }; {$R *.res} begin  RequireDerivedFormResource:=True;  Application.Scaled:=True;  Application.Initialize;  Application.CreateForm(TMeanMenu,MeanMenu);  Application.Run;end. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit MainMenu; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,  Menus, Intro; type   { TMeanMenu }   TMeanMenu = class(TForm)    Confirm: TButton;    Introduction: TRadioButton;    Label1: TLabel;    Motion: TRadioButton;    Wave: TRadioButton;    Finish: TRadioButton;    Menu1: TRadioGroup;    procedure ConfirmClick(Sender: TObject);    procedure Label1Click(Sender: TObject);  private   public   end; var  MeanMenu: TMeanMenu; implementation {$R *.lfm} { TMeanMenu } procedure TMeanMenu.Label1Click(Sender: TObject);begin end; procedure TMeanMenu.ConfirmClick(Sender: TObject);begin  If Introduction.checked=true then  Begin    FIntroduction.Show;  end; end; end. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Intro; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Menus; type   { TFIntroduction }   TFIntroduction = class(TForm)    Back: TButton;    Label1: TLabel;    Label2: TLabel;    Label3: TLabel;    Label4: TLabel;    Label5: TLabel;    Label6: TLabel;    Label7: TLabel;    Label8: TLabel;    Label9: TLabel;    procedure FormCreate(Sender: TObject);  private   public   end; var  FIntroduction: TFIntroduction; implementation {$R *.lfm} { TFIntroduction } procedure TFIntroduction.FormCreate(Sender: TObject);begin end; end. [Edited to add code tags - please see How to use the Forums.] ---------------------------------------------------------------------- tetrastes · 2021-01-10 20:36 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program projectNEA; {$mode objfpc}{$H+} uses  {$IFDEF UNIX}{$IFDEF UseCThreads}  cthreads,  {$ENDIF}{$ENDIF}  Interfaces, // this includes the LCL widgetset  Forms, PNEA,  mainmenu, Intro  { you can add units after this }; {$R *.res} begin  RequireDerivedFormResource:=True;  Application.Scaled:=True;  Application.Initialize;  Application.CreateForm(TMeanMenu,MeanMenu);  Application.CreateForm(TFIntroduction,FIntroduction);  Application.Run;end.