lichess.org
Donate

PGN wiever with C language

I would stay away from C/C++ and recommend something a bit more newbie/UI friendly like Javascript/Java/C#
Is Java supported by a browser in the same way of Javascript? And then....could you kind people show me two code lines of a possible javascript or java code for making a pgn wiever (for example if i would make the Ng1-f3 move) ???? Write it approximately and like i knew perfectly the programming language (IT IS NOT REAL I HAVE NOT ANY EXPERIENCE ABOUT THEM :)))

Thank you if you want to take a minute to help me to comprehend :) bye from Italy!
Hi! Few days ago I opened this discussion about the possibility of writing a simple viewer with a specific language.

Thibault suggested me Javascript and now here I am:

I made a chessboard with an html table, giving to every td an id="" (for example, a1, f7, g8....), and putting some special chess characters to represent the pieces;

after that i wrote some innerHtml functions that cancel a character from a td and write another character in a different td, simulating the mouvement of the pieces.

So, i have put in the html some buttons, related to these functions and, by clicking on them I reach on the chessboard a specific position (i.e. 1 e4 e5 with the first button; 2 Nf3 Nc6 with the second button, et cetera)

But my difficulty is now to permit to the client to show again the inner positions (for example 1 e4 e5) - altough he just clicked on the second button too.. - without refresh the page!

Someone suggested me the creation of an array.... I took also a look to the w3cschools where they talk about the addEventListener "function", or about the command (this)...

What I would like to have is simply the possibility now to create two buttons called BACK and FORWARD to go back and forward as well, in the visualization of our positions!

Thank you to Lichess' Organization and also to everyone who answered and to everyone who would answer with some suggestions

I hope to have been clear and correct, first of all, with english :P

Andrea
In my opinion you should work more on language learning. It doesn't appear you understand very well the issue of events, whatever the language is. I had the same problem as you when I was learning. I wanted to create a program without having a good understanding.

"Events understanding is essential when you work with object oriented languages". For example, in vb.NET from one of my projects:

It has a event which loads the basic window, when it's compiled and started. It starts with 2 images, one of them invisible and choose the location of the images.
The "me" word, like "this" in other languages makes reference to the class itself, so in this case paints the background in white.

Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox1.Visible = True
PictureBox2.Visible = False

PictureBox1.Location = New Point(10, 10)
PictureBox2.Location = New Point(250, 250)

Me.BackColor = Color.White
End Sub

After that you can add events like a button. This sends an action when you press a key and then the code and the"if clause" is activated, plays a sound and modifies the image:

Private Sub Button1_KeyDown(sender As Object, e As EventArgs) Handles Button1.KeyDown

cuenta += 1
' Reset the counter
If (cuenta = 3) Then
cuenta = 0
End If

If (cuenta = 1) Then
PictureBox1.Visible = True
PictureBox2.Visible = True
PictureBox2.ClientSize = New Size(100, 100)
PictureBox1.ClientSize = New Size(250, 250)
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
PlaySonido1()

Sintaxis can be different but the concept is the same in all programming languages.

This topic has been archived and can no longer be replied to.