Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Passing arguments into the simulator
Started by prographodeveloper Nov 07 2019 01:58 AM

No replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

prographodeveloper

[GLOBAL: userInfoPane.html]
prographodeveloper
  • Contributor

  • 312 posts
  • Corona SDK

This took me a while to figure out, so I'm posting it here incase it helps someone else.

You may want to pass information from the OS into the simulator, obviously this will not work on a device, however there are situations where you might want to do this - for example, automated testing.

You cannot pass command line arguments "args" is always empty. However, you can make an OS call. So you can set an environmental variable, then read it from the simulator.

 

export TESTNUMBER=3

 

execute simulator on command line...

/Applications/Corona/Corona\ Simulator.app/Contents/MacOS/Corona\ Simulator ~/Projects/x1 -no-console YES 

In main.lua:

local test=io.popen"echo $TESTNUMBER":read'*l'

print(">> " .. test)

 

 


  • Michael Flad likes this


[topic_controls]
[/topic_controls]