Log In  

Cart [#54893#] | Code | 2018-08-09 | License: CC4-BY-NC-SA | Embed

Just a simple program I made to test the limits of the LS() command. It cannot see anything other than .p8 and .png files because of the LS() program's limitations. It can load another program and run it if it is in the carts directory. You can also return to it again from that cart in the menu.

You must download it for it to see anything.

P#54894 2018-08-09 07:02 ( Edited 2018-08-21 01:51)

You don't have to yell!

function _draw()
 cls()
 if stat(102)==0 then
  dr_boxes()
  dr_files()
  dr_menu()
  rect(2,0,81,127)
  rect(81,0,89,127)
  rect(89,0,127,32)
  controls()
 else
  print("this does not work on the bss.")
  print("you must download it to see anything.")
 end
end
P#54901 2018-08-09 11:43 ( Edited 2018-08-09 15:45)
:: dw817

HWD, I think you can do:

"LS *.*"

and it will work to show all files in the directory.

P#55106 2018-08-13 20:48 ( Edited 2018-08-14 00:48)

I tried, but I can't get LS to work with that in code. Do you give that '.' as an argument for LS?
This is my code:

list=ls(*.*)
for i=1, #list do
 print(list[i])
end

I tried it in quotations as well, but that didn't print out anything.

P#55406 2018-08-20 05:32 ( Edited 2018-08-20 09:32)
:: Felice

In lua code, rather than the command line, you'd have to pass a string, so you'd need to put quotes around the wildcard pattern.

I don't think the code version of ls() takes an argument, though. In fact, when I just tested it, if you give it an argument, it returns nil instead of a list.

Also, even if it took an argument, you probably wouldn't use "*.*". That particular pattern is kind of a relic of DOS days, when every file intrinsically had a 3-letter extension. You had to type it that way. These days, "*" is what you want if you want to see every file, especially outside of Windows, where "*.*" will limit you to seeing files that literally have a dot in them. Windows tends to quietly treat "*.*" as "*" to make life easier for people with old habits.

P#55426 2018-08-20 15:05 ( Edited 2018-08-20 19:06)

Hope you don't mind the thread hijack, but on a related note I think it'd be nice if the runtime version of ls returned directories as well (either via a parameter or just leave the parsing up to us), especially as cd can be used at runtime.

P#55435 2018-08-20 21:51 ( Edited 2018-08-21 01:51)

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-11-13 00:23 | 0.016s | 2097k | Q:30