Interesting url that translates text to Morse Code. I know PS has a beep with parameters, but is there a way for WB to play back the code as beeps in a script. below doesn't use Newtonsoft or Jim's Extender but the dots/dashes can be isolated into a list, array or map. Can they be either translated or played back in WB.
;Winbatch 2020 - URL translates text to Morse Code
;Stan Littlefield 2/9/2021
;/////////////////////////////////////////////////////////////////////////////////////
gosub udfs
IntControl(73,1,0,0,0)
Msg = 'Winbatch 2021'
cUrl = "https://api.funtranslations.com/translate/morse.json?text=":Msg
request = Createobject("WinHttp.WinHttpRequest.5.1")
request.Open("GET", cUrl, @False )
request.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
request.SetRequestHeader("Accept", "application/json")
request.Send()
jdata = request.ResponseText
request = 0
Message("Json Morse Code",parseit(GetJSON(jdata)))
Exit
;====================================================================================
:WBERRORHANDLER
request=0
geterror()
Message("Error Encountered",errmsg)
Exit
;====================================================================================
:udfs
#DefineSubRoutine geterror()
wberroradditionalinfo = wberrorarray[6]
lasterr = wberrorarray[0]
handlerline = wberrorarray[1]
textstring = wberrorarray[5]
linenumber = wberrorarray[8]
errmsg = "Error: ":lasterr:@LF:textstring:@LF:"Line (":linenumber:")":@LF:wberroradditionalinfo
Return(errmsg)
#EndSubRoutine
#DefineFunction GetJSON(strJSON)
If strJSON == "" Then Return ""
objJSC = CreateObject ("MSScriptControl.ScriptControl")
objJSC.Language = "JScript"
objJSC.AddCode(: `function json2txt(obj,path){var txt='';for(var key in obj){if(obj.hasOwnProperty(key)){if('object'==typeof(obj[key])){txt+=json2txt(obj[key],path+(path?'|':'')+key);}else{txt+=path+'|'+key+','+obj[key]+'\n';}}}return txt;}`)
Return objJSC.Eval(: `json2txt(` : strJSON : `,'')`)
; JS code from Patrick Fisher at "http://stackoverflow.com/questions/10221229/list-all-keys-and-values-of-json" ; 2012-04-19T03:48:24.
#EndFunction
#DefineFunction parseit(json)
text = json
text = StrReplace(text,",","=")
text = StrReplace(text,"|","")
text = StrReplace(text,@LF,@CRLF)
Return text
#EndFunction
Return
;====================================================================================