Changeset 353 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Aug 5, 1999, 3:40:42 PM (26 years ago)
Author:
ercodmgr
Message:

Petites amelioration + readstdin Reza 6/8/99

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/piacmd.cc

    r349 r353  
    291291usage += "  > unset varname          # clear variable definition \n";
    292292usage += "  > echo string            # output string \n";
     293usage += "  > alias name string      # define a command alias \n";
     294usage += "  > readstdin varname      # reads a line from stdin into $varname \n";
    293295usage += "  > foreach varname string-list # Loop \n";
    294296usage += "  > foreach varname i1:i2[:di]  # Integer loop  \n";
    295297usage += "  > foreach varname f1:f2[:df]  # Float loop  \n";
    296298usage += "  > end                         # end loops \n";
    297 usage += "  > listvars   # List of variable names and values \n";
    298 usage += "  > listcommands # List of all known commands \n";
    299 usage += "  > exec filename  # Execute commands from file \n";
     299usage += "  > listvars      # List of variable names and values \n";
     300usage += "  > listalias     # List of alias names and values \n";
     301usage += "  > listcommands  # List of all known commands \n";
     302usage += "  > exec filename # Execute commands from file \n";
    300303usage += "  > shell comand_string  # Execute shell command \n";
    301304usage += "  > help <command_name>  # <command_name> usage info \n";
     
    488491    else  {
    489492      char prompt[64];
    490       sprintf(prompt, "foreach-%d> ", felevel);
     493      sprintf(prompt, "foreach-%d? ", felevel);
    491494      mImgApp->GetConsole()->SetPrompt(prompt);
    492495      }
     
    673676  cout << endl;
    674677  }
     678
     679else if (kw == "readstdin") {
     680  if (tokens.size() < 1) { cout << "PIACmd::Interpret() Usage: readstdin varname" << endl;  return(0); }
     681  if ((tokens[0].length() < 1) || !isalpha((int)tokens[0][0]) ) {
     682    cerr << "PIACmd::Interpret()/Error Variable name should start with alphabetic" << endl;
     683    return(0);
     684    }
     685  char buff[128];
     686  fgets(buff, 128, stdin);
     687  buff[127] = '\0';
     688  mVars[tokens[0]] = buff;
     689  }
     690
    675691else if (kw == "listvars") {
    676692  cout << "PIACmd::Interpret()  Variable List , VarName = Value \n";
     
    680696  cout << endl;
    681697  }
    682 else if (kw == "listvars") {
     698else if (kw == "listalias") {
     699  cout << "PIACmd::Interpret()  Alias List , AliasName = Value \n";
     700  CmdVarList::iterator it;
     701  for(it = mAliases.begin(); it != mAliases.end(); it++) 
     702    cout << (*it).first << " = " <<  (*it).second << "\n";
     703  cout << endl;
     704  }
     705else if (kw == "listcommands") {
    683706  cout << "---- PIACmd::Interpret()  Command Variable List ----- \n";
    684707  CmdExmap::iterator it;
Note: See TracChangeset for help on using the changeset viewer.