---
title: "Survey design and xPath: automatically detect tablet/PC?"
url: "https://openforis.support/questions/1402/survey-design-and-xpath-automatically-detect-tabletpc"
tags: ["collect"]
status: "answered"
score: 0
answer_count: 3
asked: "2017-10-19T02:34:08"
last_activity: "2018-06-08T12:04:07"
source: "Open Foris Support - Q&A Forum"
license: "Copyright Open Foris, 2026. Some rights reserved under creative commons license."
---

# Survey design and xPath: automatically detect tablet/PC?

Asked by Lauri (OF) on 2017-10-19

Hi Team,

I plan to add guidance for slope correction values of plot radii (i.e. a function showing message as a text field) based on given slope angle, but that will be needed only in Mobile but not in Collect on desktop/laptop. Is there any way to detect the platform by using xPath language?  

Regards, Lauri


## Answer (score 0, by Stefano (OF) on 2017-10-19)

Link: https://openforis.support/questions/1402/survey-design-and-xpath-automatically-detect-tabletpc/1405

Hi Lauri,  
Having a custom XPath function to determine if you are running on Collect on the mobile device is already in our plans.  
When this function will be available, how do you want to display the text field message to the user?  
Thanks,  
Open Foris Team


## Answer (score 0, by Lauri (OF) on 2017-10-20)

Link: https://openforis.support/questions/1402/survey-design-and-xpath-automatically-detect-tabletpc/1406

It can be shown on Mobile as a text field using a function, but not included in data export. 

-Lauri


## Answer (score 0, by Lauri (OF) on 2018-06-08)

Link: https://openforis.support/questions/1402/survey-design-and-xpath-automatically-detect-tabletpc/1822

In the newest Collect v 3.22.1 there are now new custom Environment functions:

- env:desktop() : returns true if Collect runs on a desktop computer, false otherwise (e.g. in Android)

- env:mobile() : opposite of env:desktop()

and Mathematical functions:

 - asin/acos/atan : arc sine, arc cosine and arc tangent of a specified angle
 -----
An example: showing slope correction for 15m plot radius when slope more than 5 degrees (or less than -5):

 - add numeric field "slope" (unit: degrees)
 - add text field for a text message on Mobile
 - select "Calculated"
 - unselect "Include in data export"
 - add Relevant expression:
  
     `env:mobile() and math:abs(slope)>5`
  
 - add Calculated expression 
 
 `format-number(15 div math:sqrt(math:cos(math:abs(slope))),"0.00")`

 and Apply when rule:

   env:mobile() and `math:abs(slope)>5` 

This may need some further development, but the basic idea is here. 

regards, Lauri
