Results 1 to 2 of 2

Thread: Simple Scripting language

  1. #1
    Join Date
    Jul 2012
    Posts
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Simple Scripting language

    I am trying to make a simple scripting laungange in qt that you can change variables from c++ in the script and the return it back so far this what I have:
    Qt Code:
    1. QString Script = "def SH_Script Print hello hey; Print hey;";
    2.  
    3. if(Script.startsWith("def SH_Script", Qt::CaseInsensitive))
    4. {
    5. Script.replace(QRegExp("def SH_Script"), "");
    6. QStringList Lines = Script.split(";");
    7. QStringList Words[Lines.count()];
    8.  
    9. for(int i = 0; i < Lines.count(); i++)
    10. {
    11. Words[i] = Lines.at(i).split(" ");
    12.  
    13. for(int w = 0; w < Words[i].count(); w++)
    14. {
    15. if(Words[i].at(w) == "Print")
    16. {
    17. for(int h = 0; h < Words[i].count(); h++)
    18. {
    19. if(Words[i].at(h) == "Print")
    20. {
    21. Words[i].removeAt(h);
    22. }
    23. }
    24.  
    25. QString output;
    26. for(int a = 1; a < Words[i].count(); a++)
    27. {
    28. output += Words[i].at(a) + " ";
    29. }
    30.  
    31. qDebug() << output << endl;
    32. output = "";
    33. }
    34.  
    35. else if(Words[i].at(w) == "def")
    36. {
    37. //creates a new varible
    38. }
    39.  
    40. else if(Words[i].at(w).startsWith('$'))
    41. {
    42. //refers to a varible
    43. }
    44.  
    45. else if(Words[i].at(w).startsWith("--"))
    46. {
    47. Words[i].clear();
    48. }
    49. else if(Words[i].at(w) == " ")
    50. {
    51. //reconizing space instead of errors
    52. }
    53. else if(Words[i].at(w) == "")
    54. {
    55. //reconizing space instead of errors
    56. }
    57. else
    58. {
    59. qDebug() << "syntax error at line:" << i;
    60. }
    61. }
    62. }
    63. }
    64. else
    65. {
    66. qDebug() << "Not decarled as a SH Script";
    67. }
    To copy to clipboard, switch view to plain text mode 

    Any suggestions or help would be great

  2. #2
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Simple Scripting language

    have you seen this thread? http://www.qtcentre.org/threads/698-...pts-at-runtime

    i see that QSA is depricated the new sript is QtScript

Similar Threads

  1. Replies: 4
    Last Post: 22nd December 2010, 11:04
  2. Qt Scripting Potentialities (ProcessingJS+QT)
    By gabon in forum Qt Programming
    Replies: 4
    Last Post: 17th May 2010, 09:44
  3. Scripting question
    By EricF in forum Qt Programming
    Replies: 2
    Last Post: 31st January 2008, 14:54
  4. Scripting engine
    By stevey in forum Qt Programming
    Replies: 2
    Last Post: 27th October 2006, 11:36
  5. Scripting questions
    By fullmetalcoder in forum General Discussion
    Replies: 1
    Last Post: 22nd May 2006, 13:02

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.