PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Properties specific to the description of nfcData variables
  • Reinitialization
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
A nfcData variable is used to describe and handle the data of a nfcTag variable. The characteristics of this data can be defined and modified by several WLanguage properties.
Note: See Declaring a variable for more details on the declaration of this type of variable and the use of WLanguage properties.
Versions 24 and later
iPhone/iPad This type of variable is now available for iPhone/iPad applications.
New in version 24
iPhone/iPad This type of variable is now available for iPhone/iPad applications.
iPhone/iPad This type of variable is now available for iPhone/iPad applications.
Example
Android
// Write a url into an NFC tag
tag is nfcTag
url is nfcData
url..Type = nfcURI
url..Content = "www.pcsoft.com"
Add(tag, url)
NFCWriteTag(tag)
IF ErrorOccurred = True THEN
Error("Failure writing onto the NFC tag.", ErrorInfo())
END
Android
// Save an image in a NFC tag
tag is nfcTag
url is nfcData
url..Type = nfcMedia
url..Content = fLoadBuffer(CompleteDir(SysDirStorageCard()) + "image.png")
url..MIMEType = "image/png"
Add(tag, url)
NFCWriteTag(tag)
IF ErrorOccurred = True THEN
Error("Failure writing onto the NFC tag.", ErrorInfo())
END
// Read the data of a NFC tag
tag is nfcTag
tag = NFCReadTag()
IF NOT ErrorOccurred = True THEN
FOR EACH data OF tag..Data
SWITCH data..Type
CASE nfcText
sLanguage is string = LanguageToName(data..Language)
sText is string = data..Content
CASE nfcURI
IF StringStartsWith(data..Content, "http") THEN
BrowserRunApp(data..Content)
END
CASE nfcMedia
IF data..MIMEType ~= "image/png" THEN
fSaveBuffer(CompleteDir(SysDirStorageCard()) +  ...
"image.png", data..Content)
END
END
END
END
Remarks

Properties specific to the description of nfcData variables

The following properties can be used to handle a data of a NFC tag:
Property nameType usedEffect
ContentBinary/BufferData content. Its type depends on the value of ..Type.
If ..Type corresponds to:
  • the nfcText constant:
    • Android ..Content can be an Ansi or Unicode string.
    • Versions 24 and later
      iPhone/iPad ..Content is a Unicode string.
      New in version 24
      iPhone/iPad ..Content is a Unicode string.
      iPhone/iPad ..Content is a Unicode string.
    Android When writing the NFC tag:
    • if ..Content is an Ansi string, the text will be encoded in UTF8,
    • if ..Content is a Unicode string, the text will be encoded in UTF16.
  • the nfcURI constant, ..Content corresponds to an Ansi string.
  • the nfcMedia constant, ..Content corresponds to a buffer.
    The interpretation of the buffer data depends of MIME type associated with the nfcData variable.
  • the nfcEmpty constant: A fatal error occurs when trying to modify the ..Content property.
  • the nfcUnknown constant: A fatal error occurs when trying to modify the ..Content property.
iPhone/iPad This property is available in read-only.
LanguageIntegerLanguage of the text stored in ..Content.
This property must be used only when the type of the nfcData variable is nfcText. A fatal error will occur when reading or modifying the ..Language property of a nfcData variable of a different type.
By default, ..Language is initialized with the current language of the application.
To find out:
iPhone/iPad This property is available in read-only.
TypeInteger constantType of data, corresponding to one of the following constants:
  • nfcText: Text data.
  • nfcURI: URI data (Uniform Ressource Identifier). Can correspond to:
    • the url of a Web page (http://www.windev.com),
    • an FTP address (ftp://ftp.windev.com/),
    • a phone number (tel:0123456789),
    • an email address (mailto:adresse@mail.com), etc.
      You have the ability to use ShellExecute with this URI (for example, to open the browser when the URI corresponds to the address of a Web site).
  • nfcMedia: Media data. Can correspond to any resource identified by a MIME type (image, video, document, etc.).
  • nfcEmpty: Empty type. This type is used when creating a nfcData variable as long as no type of data was specified.
  • nfcUnknown: Unknown type.
Important note: The modification of a nfcData variable triggers the reinitialization of its content. Therefore, don't forget to specify the type before the content.
iPhone/iPad This property is available in read-only.
MIMETypeCharacter stringMIME type of the resource stored in ..Content.
The specified MIME type can correspond to:
  • a standard MIME type. More than 150 types are defined in the MIME communication standard (available on Internet). The most common values are:
    • "application/pdf": document in PDF format (*.pdf)
    • "text/html": HTML page (*.htm, *.html)
    • "text/plain": text file (*.txt)
    • "image/gif": image in GIF format (*.gif)
    • "image/jpeg": image in JPEG format (*.jpg, *.jpeg)
    • "video/mpeg": video in MPEG format (*.mpg, *.mpeg)
    • "application/msword": Word file.
    • "application/vnd.ms-excel": Excel file.
  • a custom type.
..MIMEType must be used only when the type of the nfcData variable is nfcMedia. A fatal error will occur when reading or modifying the ..MIMEType property of a nfcData variable of a different type.
iPhone/iPad This property is available in read-only.

Note: These properties can be used with one of the following syntaxes:
  • <Variable name>..<Property name>
  • <Variable name>.<Property name>

Reinitialization

You can use VariableReset to reinitialize the content of a nfcData variable.
Minimum required version
  • Version 18
Comments
Click [Add] to post a comment