What is the Ada command line redirector that is analogous to “>”?

后端 未结 3 1671
醉梦人生
醉梦人生 2021-01-25 01:37

Ada noob here (and also not so hot with the command line in general). I am looking for the Ada command line redirector that would be analogous to \">\" in DOS.

I am r

相关标签:
3条回答
  • 2021-01-25 02:07

    William Whitaker's Words includes an interactive command line interpreter, but it looks like you want to control it from another program using command-line mode. The exact details depend your chosen environment. As a concrete example using bash, instead of reading from @<file>, which always writes to WORD.OUT, execute words followed by a list of words on standard input; the results appear on standard output:

    $ ./words amo amas
    am.o                 V      1 1 PRES ACTIVE  IND 1 S    
    amo, amare, amavi, amatus  V (1st)   [XXXAO]  
    love, like; fall in love with; be fond of; have a tendency to;
    
    am.as                N      1 1 ACC P F                 
    ama, amae  N (1st) F   [XXXDO]    lesser
    bucket; water bucket; (esp. fireman's bucket);
    am.as                V      1 1 PRES ACTIVE  IND 2 S    
    amo, amare, amavi, amatus  V (1st)   [XXXAO]  
    love, like; fall in love with; be fond of; have a tendency to;
    

    From standard output, you can also redirect the results to a file; from python, you might use commands or subprocess; in Java you might use exec() or ProcessBuilder, for example:

    ProcessBuilder pb = new ProcessBuilder("./words", "amo", "amas", "amat");
    

    0 讨论(0)
  • 2021-01-25 02:07

    I didn't think to check Github first, but there is some very good information at the William Whitaker WORDS project site, including a user guide here:

    http://mk270.github.io/whitakers-words/operational.html.

    What I learned that I had to do was this: While running Words in a Windows command line, enter "#" to change the parameters.

    So start here: William Whitaker's WORDS beginning interface

    Then enter "#" to change the parameters and mode of the program and hit enter. You will be presented with each parameter sequentially and you can enter "n" to keep the current parameter setting (which could be set to either yes or no) or "y" to change the parameter setting (to either yes or no).
    [William Whitaker's WORDS changing the parameters][2]

    After you go through all the parameters, you'll be asked if you want to save the parameter changes. The image below shows this. [William Whitaker's WORDS saving all the new parameter settings][3]

    Don't get mixed up by thinking that you can enter "y" or "n" as the parameter setting. You are entering "y" or "n" about whether to change the current parameter setting.

    Once you've set the Write_Output_To_File parameter to "y" you can run Words with a command like this:

    @InputLatinWordList.txt

    WORDS will generate a file called WORD.out that you can open up as a text file to rename it.

    0 讨论(0)
  • 2021-01-25 02:27

    The package Ada.Command_Line is for receiving command line arguments, when an Ada program starts. What you are interested in is most likely Ada.Text_IO (chapter A.10 in the RM).

    More specifically, you will need to declare a variable for representing the file you are going to redirect standard output to:

    Redirection : Ada.Text_IO.File_Type;
    

    Then create and open it:

    Ada.Text_IO.Create (File => Redirection,
                        Name => "latin.words",
                        Mode => Ada.Text_IO.Out_File);
    

    Finally you can redirect standard output:

    Ada.Text_IO.Set_Output (File => Redirection);
    
    0 讨论(0)
提交回复
热议问题