Recent

Author Topic: "BEGIN" expected but "END" found  (Read 1356 times)

yyttyy

  • New Member
  • *
  • Posts: 18
"BEGIN" expected but "END" found
« on: November 14, 2020, 11:10:29 pm »
Help me please. I am tired of this error. Maybe I am blind, but i can't see problem:
Code: Pascal  [Select][+][-]
  1. unit ButtonWidget;
  2.  
  3. interface
  4.  
  5.  
  6.  
  7. implementation
  8.  
  9. uses glib2, gdk2pixbuf, gdk2, gtk2, ButtonWidgetHeader in
  10.     '/home/yarik/Desktop/Zhuzhculator' +
  11.     '/Prog/Units/ButtonWidgetUnit/ButtonWidgetHeader.pp';
  12.  
  13. procedure gtk_button_widget_class_init(class : PGtkButtonWidgetClass);
  14. procedure gtk_button_widget_init(button_widget : PGtkButtonWidget);
  15. procedure move_cursor(widget : PGtkWidget; event : PGdkEventCrossing;
  16.                       user_data : gpointer);
  17. procedure click_cursor(widget : PGtkWidget; event : PGdkEventButton;
  18.                        user_data : gpointer);
  19.  
  20. type
  21.     signals = (CLICK_BUTTON_SIGNAL, LAST_SIGNAL);
  22.     SigArr = array[CLICK_BUTTON_SIGNAL..LAST_SIGNAL] of guint;
  23.  
  24. var
  25.     date_type : GType = 0;
  26.     date_info : TGTypeInfo;
  27.     parent_class : PGtkWidgetClass = nil;
  28.     button_widget_signals : SigArr;
  29.     hand_cursor : PGdkCursor = nil;
  30.     GTK_BUTTON_WIDGET_NORMAL : gint = 0;
  31.     GTK_BUTTON_WIDGET_ACTIVE : gint = 1;
  32.  
  33. procedure button_widget_signals_init();
  34. begin
  35.     button_widget_signals[LAST_SIGNAL] := 0;
  36. end;
  37.  
  38. procedure init_date_info();
  39. begin
  40.     date_info.class_size := SizeOf(TGtkButtonWidgetClass);
  41.     date_info.base_init := nil;
  42.     date_info.base_finalize := nil;
  43.     date_info.class_init := TGClassInitFunc (@gtk_button_widget_class_init);
  44.     date_info.class_finalize := nil;
  45.     date_info.class_data := nil;
  46.     date_info.instance_size := SizeOf(TGtkButtonWidget);
  47.     date_info.n_preallocs := 0;
  48.     date_info.instance_init := TGInstanceInitFunc (@gtk_button_widget_init);
  49. end;
  50.  
  51. function gtk_button_get_type() : GType;
  52. begin
  53.     if (date_type = 0) then
  54.     begin
  55.         init_date_info();
  56.         date_type := g_type_register_static(
  57.             GTK_TYPE_EVENT_BOX, 'GtkButtonWidget', @date_info, 0
  58.             );
  59.     end;
  60.     gtk_button_get_type := date_type;
  61. end;
  62.  
  63.  
  64.  
  65. procedure gtk_button_widget_class_init(class : PGtkButtonWidgetClass);
  66. var
  67.     widget_class : PGtkWidgetClass;
  68.  
  69. begin
  70.     widget_class := GTK_WIDGET_CLASS(class);
  71.     parent_class := g_type_class_peek_parent(class);
  72.     class^.click_button := nil;
  73.     button_widget_signals[CLICK_BUTTON_SIGNAL] :=
  74.         g_signal_new(
  75.         'click_button',
  76.         G_OBJECT_CLASS_TYPE(G_OBJECT_CLASS(class)),
  77.         G_SIGNAL_RUN_FIRST,
  78.         @class^.click_button - pointer(class),
  79.         nil,
  80.         nil,
  81.         @g_cclosure_marshal_VOID__VOID,
  82.         G_TYPE_NONE,
  83.         0);
  84. end;
  85.  
  86. procedure gtk_button_widget_init(button_widget : PGtkButtonWidget);
  87. begin
  88.     button_widget^.state := GTK_BUTTON_WIDGET_NORMAL;
  89.     button_widget^.color := nil;
  90.     button_widget^.clicked := false;
  91.     gtk_widget_set_events (GTK_WIDGET(button_widget), GDK_ENTER_NOTIFY_MASK
  92.                            or GDK_LEAVE_NOTIFY_MASK);
  93.     g_signal_connect (G_OBJECT(button_widget), 'button-press-event',
  94.                       G_CALLBACK(@click_cursor), nil);
  95.     g_signal_connect (G_OBJECT(button_widget), 'enter-notify-event',
  96.                       G_CALLBACK(@move_cursor), nil);
  97.     g_signal_connect (G_OBJECT(button_widget), 'leave-notify-event',
  98.                       G_CALLBACK(@move_cursor), nil);
  99. end;
  100.  
  101. procedure move_cursor(widget : PGtkWidget; event : PGdkEventCrossing;
  102.                       user_data : gpointer);
  103. begin
  104.     if (event^._type = GDK_ENTER_NOTIFY) then
  105.     begin
  106.         if (hand_cursor = nil) then
  107.         begin
  108.             hand_cursor := gdk_cursor_new(GDK_HAND2);
  109.             gdk_window_set_cursor(widget^.window, hand_cursor)
  110.         end;
  111.         GTK_BUTTON_WIDGET(widget)^.state := GTK_BUTTON_WIDGET_ACTIVE;
  112.     end;
  113.     if (event^._type = GDK_LEAVE_NOTIFY) then
  114.         GTK_BUTTON_WIDGET(widget)^.state := GTK_BUTTON_WIDGET_NORMAL;
  115. end;
  116.  
  117. procedure click_cursor(widget : PGtkWidget; event : PGdkEventButton;
  118.                        user_data : gpointer);
  119. begin
  120.     if (event^._type = GDK_BUTTON_PRESS) then
  121.         g_signal_emit(GTK_BUTTON_WIDGET(widget),
  122.                       button_widget_signals[CLICK_BUTTON_SIGNAL], 0)
  123. end;
  124.  
  125. function gtk_button_widget_new() : PGtkWidget;
  126. var
  127.     w : PGtkWidget;
  128. begin
  129.     w := GTK_WIDGET(g_object_new(GTK_TYPE_BUTTON_WIDGET, nil));
  130.     gtk_button_widget_new := w;
  131. end;
  132. end.

winni

  • Hero Member
  • *****
  • Posts: 2799
Re: "BEGIN" expected but "END" found
« Reply #1 on: November 14, 2020, 11:20:24 pm »
Hi!

The error message tells the x and  position of the error.

This might help you.
And it helps all others here if you show use the whole error message.

Winni

Blaazen

  • Hero Member
  • *****
  • Posts: 3034
  • POKE 54296,15
    • Eye-Candy Controls
Re: "BEGIN" expected but "END" found
« Reply #2 on: November 14, 2020, 11:23:46 pm »
The implementation keyword is on the wrong place. It must be down, below the type section. It can be above or below var section.

EDIT: It must be at least below uses. It simply depends what you want, interface is like public, implementation is like private.
« Last Edit: November 14, 2020, 11:38:07 pm by Blaazen »
Lazarus 2.3.0 rmain-2_3-280-g5db1922e37 FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

 

TinyPortal © 2005-2018