Purpose
Display data read via a web service

Solution
Call up the web service via CopyText and a suitable URL

Compared to a solution via JavaScript or VB, the CopyText approach is easy to implement, although not sufficient for advanced applications.

As an example we translate a text using the "deepl.com" API.

InputScript

GuiXT
// text to translate (example from Wikipedia)

Set V[t1] "Thomas Alva Edison (Feb 11, 1847 – Oct 18, 1931) "
Set V[t2] "was an American inventor and businessman. "
Set V[t3] "He has been described as America's greatest inventor. "
Set V[t4] "He developed many devices in fields such as "
Set V[t5] "electric power, mass communication, sound recording, "
Set V[t6] "and motion pictures. These inventions include "
Set V[t7] "the phonograph, the motion picture camera, "
Set V[t8] "and early versions of the electric light bulb. "
Set V[t9] "They have had a widespread impact on the world. "
Set V[t10] "He applied organized science and teamwork to invention, "
Set V[t11] "working with many researchers and employees. "
Set V[t12] "He established the first industrial research lab."
	
Set V[full1] "&V[t1]&V[t2]&V[t3]&V[t4]&V[t5]"
Set V[full2] "&V[t6]&V[t7]&V[t8]&V[t9]&V[t10]"
Set V[full3] "&V[t11]&V[t12]"

Set V[fulltext] "&V[full1]&V[full2]&V[full3]"

// build deepl-URL (we use a free developer key)

Set V[apiBase] "https://api-free.deepl.com/v2/translate?"
Set V[auth] "auth_key=6f7a5e2d-8989-ae5e-998f-132d9dxxxxxx:fx"
Set V[lang] "&source_lang=EN&target_lang=DE"
Set V[text] "&text=&V[mytext1]"

Set V[url] "&V[apiBase]&V[auth]&V[lang]&V[text]"

 

 

// translate

CopyText fromFile="&V[url]" toText="result"

 

 

// extract translated text from JSON format
//  (Alternative: JavaScript/VB call)

Set text[delimiter] "X"

ReplaceText "delimiter" from="X" toHexCode="1A"

ReplaceText "result" from="" to="&text[delimiter]"

CopyText fromText="result" toString="mytext2" _ 
	line=2 delimiter="&text[delimiter]"

 

 

// display text

Message "&V[mytext2]"

 

 

Return

 

 

Components
InputAssistant + Controls