How to send command to terminal ?

Questions regarding syntax

Re: How to send command to terminal ?

Postby dollyknot » Sat Dec 11, 2010 11:03 am

Nearly there!

This is my code

Public FromMyFile as String
Public GameCode as String
Private Sub CommandButton2_OnEvent()

FromMyFile = OpenDialog.GetFile()
If FromMyFile Then
GameCode = FromMyFile
End If
Dim GameCode as String
Dim ReturnCode as Integer
'GameCode = ("/home/peter/Desktop/Gamelibrary/KasTopImm.pgn")
ReturnCode = shell("/usr/games/xboard -fcp crafty -lgf " & GameCode & " -scp crafty", FALSE)
End Sub


The file dialogue GUI shows up ok, but when you click on the file you require, the GameCode String is set to the files name only, it needs to show the path to the file as well, like the dummy example. (The bit I have commented out)

I have been using the xboard and crafty combination for a good few years now and it has always annoyed me, that to see games and analyse them I have had to copy and paste them into xboard which is much more laborious than just clicking on them. Also when I get everything up and running, I will share my code with the Linux chess community.
Regards,

Peter.

http://dollyknot.com
dollyknot
 
Posts: 17
Joined: Thu Nov 25, 2010 1:39 pm

Re: How to send command to terminal ?

Postby Henning » Sat Dec 11, 2010 1:17 pm

No, it's not.

If the posted code is what you use, revise it to:
Code: Select all

Private Sub CommandButton2_OnEvent()
   'these are used only locally, no need for Public
  Dim FromMyFile as String
  Dim GameCode as String
  Dim ReturnCode as Integer

  FromMyFile = OpenDialog.GetFile()
  If FromMyFile Then
    GameCode = FromMyFile
    Print GameCode   'to "see" what is in the variable
  Else
    ' just to have a default value while testing, remove in finished app
    GameCode = "/home/peter/Desktop/Gamelibrary/KasTopImm.pgn"
  End If
' *** Dim GameCode as String *** here you have overridden the Public GameCode with the Local one
  ReturnCode = shell("/usr/games/xboard -fcp crafty -lgf " & GameCode & " -scp crafty", FALSE)
End Sub


/Henning
Henning
 
Posts: 262
Joined: Mon Feb 09, 2009 12:03 am
Location: Sweden

Re: How to send command to terminal ?

Postby dollyknot » Sat Dec 11, 2010 1:49 pm

Heh this works, it probably breaks every convention in the book, but I am happy with it.

Thanks for your help both.

Public FromMyFile as String
Private Sub CommandButton2_OnEvent()
FromMyFile = OpenDialog.GetFile()
Dim ReturnCode as Integer
ReturnCode = shell("/usr/games/xboard -fcp crafty -lgf " & FromMyFile & " -scp crafty", FALSE)
End Sub
Regards,

Peter.

http://dollyknot.com
dollyknot
 
Posts: 17
Joined: Thu Nov 25, 2010 1:39 pm

Previous

Return to Coding Questions

cron