Jump to content




how to make Arguments?


3 replies to this topic

#1 IsaacTBeast

  • Members
  • 86 posts
  • LocationI 'm inside your brian

Posted 28 May 2014 - 02:17 PM

Hey guys :) I am asking a pro how to make an arguments.. this is what I do and can you please help me :)

function printUsage()
   print("Usage: file -find [(File Name)]")
end
	 
local tArgs = { ... }
if #tArgs < 1 then
   printUsage()
end
local aText
local sCommand = tArgs[1]
if sCommand == "-find" then
if #tArgs >= 2 then
--- aText = tochar


#2 IsaacTBeast

  • Members
  • 86 posts
  • LocationI 'm inside your brian

Posted 28 May 2014 - 02:28 PM

This is the updated version :)

function printUsage()
   print("Usage: file -find [(File Name)]")
end
	 
local tArgs = { ... }
if #tArgs < 1 then
   printUsage()
end
local sCommand = tArgs[1]
if sCommand == "-find" then
local sPath = shell.resolve( tArgs[2] )
local tFiles = fs.find( sPath )
if #tFiles > 0 then
   for n,sFile in ipairs( tFiles ) do
	   if fs.exists( sFiles ) then
		  print("File Exists!")
	   end
   end
else
    printError( "No matching Files" )
end
end


#3 augustas656

  • Members
  • 158 posts

Posted 28 May 2014 - 02:28 PM

From what I understand, if you're trying to get a program's arguements, then you can call your table name anything not necesserily tArgs, the triple dot represents all the arguements passed to the program seperated by commas, so if you have arguements such as 123 "hello" "there", the value of the ... will be 123, "hello", "there". If you put this into a table with curly brackets it will become {123, "hello", "there"}, what exactly do you need help with, what are you trying to create?

#4 IsaacTBeast

  • Members
  • 86 posts
  • LocationI 'm inside your brian

Posted 28 May 2014 - 02:32 PM

View Postaugustas656, on 28 May 2014 - 02:28 PM, said:

From what I understand, if you're trying to get a program's arguements, then you can call your table name anything not necesserily tArgs, the triple dot represents all the arguements passed to the program seperated by commas, so if you have arguements such as 123 "hello" "there", the value of the ... will be 123, "hello", "there". If you put this into a table with curly brackets it will become {123, "hello", "there"}, what exactly do you need help with, what are you trying to create?

creating a search file for my first program :)

Nevermind xD.. I fixed it already but thanks anyways :D..





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users