Environment: which applies when?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
sritcp
Posts: 368
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Environment: which applies when?

Post by sritcp » Sat Jun 15, 2019 12:55 am

I’d like to understand when the different environments operate: e.g., consider “development”, “standalone application”, and “mobile”. Which one applies when:

i) testing using the iOS simulator on Mac
ii) testing with iOS device connected to the Mac
iii) standalone installed on the iOS device

Thanks,
Sri

Klaus
Posts: 11211
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Environment: which applies when?

Post by Klaus » Sat Jun 15, 2019 8:59 am

Hi Sri,

for all three BOTH applies:
the environment = "standalone application" AND the environment = "mobile"


Best

Klaus

bogs
Posts: 3818
Joined: Sat Feb 25, 2017 10:45 pm

Re: Environment: which applies when?

Post by bogs » Sat Jun 15, 2019 12:16 pm

Heya Sri,

*If* your sure you don't mean 'engine', you can stick in somewhere (probably openCard) something like

Code: Select all

answer the environment
...which will tell you exactly where your program is working in.
Selection_001.png
An interesting situation developed....
Image

sritcp
Posts: 368
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: Environment: which applies when?

Post by sritcp » Sat Jun 15, 2019 2:19 pm

May be I wasn't clear about my confusion!

Suppose I want to play a video in an iOS app, being developed on a Mac.
The code might be

Code: Select all

if the environment is "development" then
show player 1
start player 1
else if the environment is "mobile" then
play video tVideoURL
end if
Would it be appropriate to use "mobile" if I am testing on a simulator? or would the program consider the environment to be "development", as we are not really testing it on an iOS device?
Are "standalone" and "mobile" interchangeable in the above example?

Thanks,
Sri

bogs
Posts: 3818
Joined: Sat Feb 25, 2017 10:45 pm

Re: Environment: which applies when?

Post by bogs » Sat Jun 15, 2019 3:07 pm

OH!

Sorry, I sure don't know much about the simulators and how they work, but, you certainly could still find out what environment the simulator is using with what I posted.

*IF* the answer is mobile, then try the tUrl code. How long could it take to test? (Again, I have no idea how the simulators work! I suppose it could take hours :P )

...But, I know a few who don't use the simulators at all for testing, and I suppose that if you really wanted it to be a 'mobile' environment, you could test directly on the device itself (did I mention I don't develop on mobile?_) :D
Image

Klaus
Posts: 11211
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Environment: which applies when?

Post by Klaus » Sat Jun 15, 2019 3:19 pm

Ah, OK, if the environment = "mobile" it CANNOT be "development" at the same time.
And the simulator should report "mobile".

Is that what you mean?

sritcp
Posts: 368
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: Environment: which applies when?

Post by sritcp » Sat Jun 15, 2019 4:06 pm

Klaus:

It is not "development" and "mobile" at the same time!

See, "play video" works only on mobile, where it plays a video fullscreen.
"Player" object works only on desktop OS.
So, while developing I put in "if the environment is ...." clause, so it works on both (while testing).
If the simulator considers its environment as "mobile", then "play video" should run on the simulator, resulting in a fullscreen (i.e., stack size) video.

So, my question was both practical and conceptual. I wondered when I would use "standalone" instead of "mobile". I guess "standalone" is to be used for desktop standalone. (The environment options seem to be a mishmash of OSs and device types. I don't see a function for determining the OS. There is only a systemVersion)

Regards,
Sri

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5116
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Environment: which applies when?

Post by jacque » Sat Jun 15, 2019 5:11 pm

The OS is returned in "the platform".

Only the IDE is considered "development", the mobile environment is anything that is running the mobile version of the OS whether it's a phone, simulator, or emulator.

Note that the iOS simulator finds files using the same paths as the IDE (that is, the Mac Finder locations) where a real phone uses a different internal path. The best way to build a file path is to use the specialFolderPath function which will sort out the differences for you. In particular, use specialFolderPath("resources") to find videos and keep the videos in the same folder, or a subfolder, of the mainstack.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Klaus
Posts: 11211
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Environment: which applies when?

Post by Klaus » Sat Jun 15, 2019 5:43 pm

Hi Sri,

if not "mobile" then it must be desktop, so this should do the job:

Code: Select all

...
if the environment = "mobile" then
   play video tVideoURL
else
  ## Desktop: IDE or Standalone
  show player 1
  start player 1
end if
...
Best

Klaus

sritcp
Posts: 368
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: Environment: which applies when?

Post by sritcp » Sat Jun 15, 2019 6:58 pm

jacque wrote:
Sat Jun 15, 2019 5:11 pm
... In particular, use specialFolderPath("resources") to find videos and keep the videos in the same folder, or a subfolder, of the mainstack.
The dictionary says, "On iOS systems, only create files in the "documents", "cache" and "temporary" folders. Be careful not to change or add any files within the application bundle. The application bundle is digitally signed when it is built, and any changes after this point will invalidate the signature and prevent it from launching."

If my app is designed to periodically add videos and text files that are part of program resources (as opposed to user-created files), where would I put them? Evidently, not in "resources" folder (due to signature invalidation, above). Keeping it in "documents" folder doesn't make sense, as I wouldn't want the user to be able to access them outside of the app.

Thanks,
Sri

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5116
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Environment: which applies when?

Post by jacque » Sun Jun 16, 2019 5:56 pm

On mobile the documents folder is not available to anyone (or any other app) because it's inside the app sandbox. To share resources outside the sandbox you'd use specialFolderPath("external documents"). Files in documents are safe unless the user has rooted the android device or jailbroken the iPhone, unless the user is very focused on cracking your particular app and has the skills to do so. There's no failsafe way around that for any app.

I'd store the files in documents if you want to be sure they are permanently available. If they are intended only for the current session then cache or temporary are a good choice.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

sritcp
Posts: 368
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: Environment: which applies when?

Post by sritcp » Mon Jun 17, 2019 1:32 am

That helps. (Although there is still a great deal of iOS fog in my mind!)
Thank you.

Sri.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”