How to send command to terminal ?

Questions regarding syntax

Re: How to send command to terminal ?

Postby Henning » Sun Dec 05, 2010 2:32 pm

@Peter

When you have the Form Editor up:

Select one CommandButton on the Form. To the right in the Property Window you see Name, that is the name used in the Code Editor.
A little down under Special you see Caption, that is the text shown on the button. Default is the Control Type.

At the lowest right there are the controls you can add to the form. Caution, be sure to select the Arrow after placing the control, or every click in the form will add another copy of the same control.

After placing, naming, and so on, dubbleclick on a CommandButton and it will add the Sub to handle the OnEvent in the Code Editor.

Now you can have two CommandButtons named "StartWithXponder", StartWithPonder" and labeled "START With Xponder", "START With Ponder"

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

Re: How to send command to terminal ?

Postby Slowdown » Sun Dec 05, 2010 2:49 pm

@Henning,
As you explained, i have placed the project so Peter can use your guide with the project.
Regards
Slowdown for now i'm back
Slowdown
 
Posts: 347
Joined: Sat May 02, 2009 6:48 pm
Location: Netherlands

Re: How to send command to terminal ?

Postby dollyknot » Sun Dec 05, 2010 4:38 pm

Now I have found the property window in the view menu, things are making a little more sense. Thanks both.
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 » Sun Dec 05, 2010 6:25 pm

Aaaaahhh, when rereading your posts, I/we should have seen that you didn't have it visible....

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

Re: How to send command to terminal ?

Postby dollyknot » Thu Dec 09, 2010 2:42 pm

Hello both,

I have been trying to adapt Slowdown's example for FileCopy.kbasic with no success, I can run it okay as a stand alone program, but as soon as I try to incorporate its code into my code it throws up errors.

The problem is xboard has no GUI for choosing a PGN file to examine, I have managed to get

Private Sub CommandButton1_OnEvent()
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

To work by manually setting GameCode to a string, what I would like to do, is to get the relevant part of Slowdown's code, to set the GameCode String via the file choosing GUI.

Little update, don't need -ponder -xponder to be set, because you can set it and unset it in the Xboard GUI.

But the ability to set the time limit on xboard/crafty I am using already.
Regards,

Peter.

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

Re: How to send command to terminal ?

Postby Slowdown » Thu Dec 09, 2010 8:55 pm

Hi Peter,

Can you post your code perhaps i can help you with the filecopy part.
(did take a look at the example)
This is an example showing how to use random file access, you better use File.Copy()
see http://www.kbasic.com/doku.php?id=file#copy
Think it will be a lot more useful for you.
Regards
Slowdown for now i'm back
Slowdown
 
Posts: 347
Joined: Sat May 02, 2009 6:48 pm
Location: Netherlands

Re: How to send command to terminal ?

Postby dollyknot » Fri Dec 10, 2010 11:14 am

Slowdown wrote:Hi Peter,

Can you post your code perhaps i can help you with the filecopy part.
(did take a look at the example)
This is an example showing how to use random file access, you better use File.Copy()
see http://www.kbasic.com/doku.php?id=file#copy
Think it will be a lot more useful for you.


Hello Slowdown,

I went the link you kindly posted and could make no sense of it at all.

The code that follows works ok but does not do what I want.

Private Sub CommandButton1_OnEvent()
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 following line is the command line, that assembles the correct instructions to boot up xboard with crafty as its engine and to load the game at /home/peter/Desktop/Gamelibrary/KasTopImm.pgn.

The String GameCode has been set to this for proof of concept.

ReturnCode = shell("/usr/games/xboard -fcp crafty -lgf " & GameCode & " -scp crafty", FALSE)

In your example for FileCopy.kbasic You click on the left hand button and a very nice visual file chooser appears, you navigate to the directory containing the file you want, you click on the file you want to copy, the program must record this variable somehow, I want to be able to set GameCode to the file that is clicked on with the mouse.
Regards,

Peter.

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

Re: How to send command to terminal ?

Postby Slowdown » Fri Dec 10, 2010 3:12 pm

Will create a filecopy with File.Copy()
Will use the same buttons, form ect.ect
But give me some time.
Regards
Slowdown for now i'm back
Slowdown
 
Posts: 347
Joined: Sat May 02, 2009 6:48 pm
Location: Netherlands

Re: How to send command to terminal ?

Postby Slowdown » Fri Dec 10, 2010 7:11 pm

As promessed,
Code: Select all
Public FromMyFile as String
Public ToMyFile as String

Private Sub Form_OnOpen()
  CopyFileTo.enabled = False
  ProGressBar1.visible = False
End Sub

Private Sub CopyFileFrom_OnEvent()
  FromMyFile = OpenDialog.GetFile()
  If FromMyFile Then
    CopyFileTo.enabled = True
  End If
End Sub

Private Sub CopyFileTo_OnEvent()
  ToMyFile = SaveDialog.GetFile()
  If ToMyFile Then
    CopyThisFile
  End If
End Sub

Private Sub CopyThisFile()
  File.Copy (FromMyfile, ToMyFile)
End Sub


Complete project,
Attachments
FileCopy3.zip
filecopy project
(1.51 KiB) Downloaded 136 times
Regards
Slowdown for now i'm back
Slowdown
 
Posts: 347
Joined: Sat May 02, 2009 6:48 pm
Location: Netherlands

Re: How to send command to terminal ?

Postby Henning » Fri Dec 10, 2010 7:38 pm

@dollyknot

And there is your variable, FromMyFile is your GameCode :)
For your app, use only that part of the code.
Code: Select all
Private Sub CopyFileFrom_OnEvent()
  FromMyFile = OpenDialog.GetFile()
  If FromMyFile Then
    GameCode = FromMyFile
  End If
End Sub


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

PreviousNext

Return to Coding Questions

cron