Guest User

Untitled

a guest
Jun 21st, 2017
84
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' Favourite creater 0.85
  2. ' 06/21/17 by cyperghost
  3. ' greetings to vika, meleu, cott, buzz, seklth
  4. ' this is a full functional version
  5. ' wait for more features!
  6. '
  7. ' Added:
  8. ' Nicer looking favnames (SYSTEM - romname)
  9. ' launch abilitiy close to runcommand.sh
  10. ' Favnames or now lowercase
  11. ' FAVs can called by bash if there is no description available (rename .sh files from ports to .fav and copy them to Favourite folder)
  12. ' FAVs will be deleted by specific call via "-del" Parameter as LAST parameter, if there is no FAV-file present nothing happens
  13. ' FAVs will not be created if there is a file already present, to get rid of this use "-del" parameter as last
  14. ' FAVs deletion will be indicated by small text message!
  15. '
  16. ' TODO vor version 1.0: Read out <command> list directly from es_systems.cfg
  17. '
  18. ' This is my last release of Favourite creater for RetroPie
  19. '
  20. ' In the near future favourite support may be in ES
  21. ' Personally I created this piece of software to favourite MAME ROWs
  22. '
  23. ' Please feel free to contribute
  24. ' but
  25. ' Respect the work of others!
  26.  
  27. #INCLUDE "vbcompat.bi" 'Needed for FILEEXISTS()
  28. dim as string path_fav,rom_fav, system_fav, rom_name, rom_favname, runcommand, sysbash
  29. dim as integer idx, z
  30.  
  31. ' Codeblock for debug: what commands are used
  32. ' Uncomment for debug
  33. 'print "ROOT DIR: ";command(0)
  34. 'print "FAV PATH: ";command(1)
  35. 'print "ROM PATH: ";command(2)
  36. 'print "ROM SYST: ";command(3)
  37. 'print "SYS CALL: ";command(4)
  38.  
  39. select case ucase(right(command(1),4))
  40. case ".FAV" 'Act as launcher for FAV files
  41. rom_favname=command(1)
  42.  
  43. open rom_favname for input as #1
  44. line input #1,rom_name
  45. line input #1,system_fav
  46. line input #1,sysbash
  47. close #1
  48.  
  49.  
  50. for z=1 to len(rom_favname)
  51. if mid(rom_favname,z,1)="/" then idx=z
  52. next z
  53. path_fav=left(rom_favname,idx)
  54.  
  55. open path_fav+"runcommand_systems.txt" for input as #1
  56. do
  57. line input #1,runcommand
  58. loop until eof(1) or InStr(runcommand,system_fav)<>0
  59. close #1
  60.  
  61. If InStr(runcommand,system_fav)=0 and sysbash<>"" then shell sysbash:end
  62. If InStr(runcommand,system_fav)=0 then shell "bash "+chr(34)+rom_favname+chr(34):end
  63.  
  64.  
  65. sysbash=mid(runcommand,1,InStr(runcommand, "%ROM%")-1)+chr(34)+rom_name+chr(34)+Mid(runcommand,InStr(runcommand, "%ROM%")+Len("%ROM%"),Len(runcommand))
  66. shell sysbash
  67.  
  68. case else 'create or delete fav-files
  69. path_fav=command(1)
  70. rom_fav=command(2)
  71. system_fav=command(3)
  72. sysbash=command(4)
  73.  
  74. for z=1 to len(rom_fav)
  75. if mid(rom_fav,z,1)="/" then idx=z
  76. next z
  77.  
  78. rom_name=mid(rom_fav,idx+1,len(rom_fav))
  79.  
  80. for z=1 to len(rom_name)
  81. if mid(rom_name,z,1)="." then idx=z
  82. next z
  83.  
  84. rom_favname=ucase(system_fav)+" - "+left(rom_name,idx-1)+".fav"
  85.  
  86. 'possibility to kill and add favorites
  87. 'Build FAV file
  88. 'FILEEXISTS knows two states -1 for file not found, 0 for file found
  89.  
  90. select case fileexists (path_fav+rom_favname)
  91. case -1
  92. if ucase(sysbash)="-DEL" then
  93. kill path_fav+rom_favname
  94. print "FAV file deleted: "& rom_favname
  95. else
  96. print "FAV file "& rom_favname &" already exists. Nothing happend!"
  97. end if
  98.  
  99.  
  100. case 0
  101. open path_fav+rom_favname for output as #1
  102. print #1, rom_fav
  103. print #1, system_fav
  104. print #1, sysbash
  105. close #1
  106. print "FAV file "& rom_favname &" created in "& path_fav
  107. end select
  108. end select
RAW Paste Data