Page 1 of 1

How i use the Delete()-procedure in JS ?

Posted: 10 Jul 2012 17:53
by micha_he
How do I use the Delete()-procedure from javascript ?
I have already tested, but i do not understand the Syntax "Delete(var s: String; from, count: Integer): String" :-(

I want to delete the leftmost char from a given string .... but:

Code: Select all

var_str = Delete(var_str, 1, 1);
brings only the error message "Expression expected" !

Help..., Please.

Re: How i use the Delete()-procedure in JS ?

Posted: 10 Jul 2012 18:39
by pjj
Still grappling with replace in a string? :wink: Try DeleteStr instead of Delete; works for me.

Re: How i use the Delete()-procedure in JS ?

Posted: 10 Jul 2012 19:32
by Rickard Johansson
Must be an error in the Fast script documentation. I don't think anything is returned from the Delete function. It should be just

Code: Select all

var s = "My string";
Delete(s,1,3);

Re: How i use the Delete()-procedure in JS?

Posted: 10 Jul 2012 20:04
by pjj
The code you propose triggers "Expression expected" error. It should be (as I mentioned above):

Code: Select all

var s = "My string";
DeleteStr(s,1,3);

Re: How i use the Delete()-procedure in JS ?

Posted: 10 Jul 2012 20:18
by Rickard Johansson
OK. "Delete" is apparently an operator in JavaScript, so you have to use "DeleteStr" instead. "Delete" works fine in a Pascal script though.

Re: How i use the Delete()-procedure in JS ?

Posted: 10 Jul 2012 20:55
by micha_he
Thanks, DeleteStr() do it...