Hi Stefan,
I've been using your ScriptCommunicator for quite some time, and now I have a need to do the following:
I have a string that has CRLF embedded (\N), example:
Chemistry: LiPo Serial Number: 3755 Manufacture Date: 2017/5/30 Num ID Code Rev 0 &HFFFF 54, 43 1 &H8325 38, 25 2 &H8324 38, 25 3 &H8318 38, 25
I would like to do something like (can do the below in javascript -but not in qtscript):
varf myData = Chemistry: LiPo Serial Number: 3755 Manufacture Date: 2017/5/30 Num ID Code Rev 0 &HFFFF 54, 43 1 &H8325 38, 25;
Chemistry: LiPo Serial Number: 3755 Manufacture Date: 2017/5/30 Num ID Code Rev 0 &HFFFF 54, 43 1 &H8325 38, 25
var NEWLINE = String.fromCharCode(13, 10);
var myArray = myData.split("\n"); for (var i = 0; i < myArray.length; i++) { scriptThread.sendString(myArray[i]); scriptThread.sendString(NEWLINE); }
Is there a way I can essentially do the above, so that I do not need to do something like:
varf myData = 'Chemistry: LiPo \ Serial Number: 3755 \ Manufacture Date: 2017/5/30 \ Num ID Code Rev \ 0 &HFFFF 54, 43 \ 1 &H8325 38, 25';
I don't want to have to do a '\' manually for every line (there could be 50+ of them).
I know this is more of a qtscript question, but I couldn't find anything about this on google, etc. -any ideas or suggestions?
Thanks, George H. (U.S.A. Massachusetts) 05/30/2017 2:44pm ET
You seem to have CSS turned off. Please don't fill out this field.
Anonymous
it looks like when I just posted my previous message, the backquote (also called grave accent) were taken out, so actually should have been:
varf myData =[backquote here]Chemistry: LiPo Serial Number: 3755 Manufacture Date: 2017/5/30 Num ID Code Rev 0 &HFFFF 54, 43 1 &H8325 38, 25[backquote here];
-sorry for the confusion.
Thanks, George H. (U.S.A. Massachusetts) 05/30/2017 2:56pm ET
Hi George,
you can save your string in a text file and then read it:
var myData =scriptFile.readFile("your path");
In the second part of your code you replace "\n' with '\r\n" and then you send the result (is this correct?). I would do it like this:
myData = myData.replace(/\n/gm, "\r\n"); scriptThread.sendString(myData);
Greetings from Germany Stefan
that's an interesting idea -I will give it a try. Thank you!
Thanks, George H. (U.S.A. Massachusetts) 05/31/2017 1:55pm ET
View and moderate all "General Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
Hi Stefan,
I've been using your ScriptCommunicator for quite some time, and now I have a need to do the following:
I have a string that has CRLF embedded (\N), example:
Chemistry: LiPo
Serial Number: 3755
Manufacture Date: 2017/5/30
Num ID Code Rev
0 &HFFFF 54, 43
1 &H8325 38, 25
2 &H8324 38, 25
3 &H8318 38, 25
I would like to do something like (can do the below in javascript -but not in qtscript):
varf myData =
Chemistry: LiPo Serial Number: 3755 Manufacture Date: 2017/5/30 Num ID Code Rev 0 &HFFFF 54, 43 1 &H8325 38, 25
;var NEWLINE = String.fromCharCode(13, 10);
var myArray = myData.split("\n");
for (var i = 0; i < myArray.length; i++) {
scriptThread.sendString(myArray[i]);
scriptThread.sendString(NEWLINE);
}
Is there a way I can essentially do the above, so that I do not need to do something like:
varf myData = 'Chemistry: LiPo \ Serial Number: 3755 \ Manufacture Date: 2017/5/30 \ Num ID Code Rev \ 0 &HFFFF 54, 43 \ 1 &H8325 38, 25';
I don't want to have to do a '\' manually for every line (there could be 50+ of them).
I know this is more of a qtscript question, but I couldn't find anything about this on google, etc. -any ideas or suggestions?
Thanks,
George H. (U.S.A. Massachusetts)
05/30/2017 2:44pm ET
View and moderate all "General Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
Hi Stefan,
it looks like when I just posted my previous message, the backquote (also called grave accent) were taken out, so actually should have been:
varf myData =[backquote here]Chemistry: LiPo Serial Number: 3755 Manufacture Date: 2017/5/30 Num ID Code Rev 0 &HFFFF 54, 43 1 &H8325 38, 25[backquote here];
-sorry for the confusion.
Thanks,
George H. (U.S.A. Massachusetts)
05/30/2017 2:56pm ET
Hi George,
you can save your string in a text file and then read it:
var myData =scriptFile.readFile("your path");
In the second part of your code you replace "\n' with '\r\n" and then you send the result (is this correct?). I would do it like this:
myData = myData.replace(/\n/gm, "\r\n");
scriptThread.sendString(myData);
Greetings from Germany
Stefan
Last edit: Stefan Zieker 2017-05-31
View and moderate all "General Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
Hi Stefan,
that's an interesting idea -I will give it a try. Thank you!
Thanks,
George H. (U.S.A. Massachusetts)
05/31/2017 1:55pm ET