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

Ask questions about how to create a script or swap scripts with other users.
Post Reply
User avatar
micha_he
Posts: 570
Joined: 24 Jul 2011 12:16
Location: Helmstedt, NDS, Germany

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

Post 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.
User avatar
pjj
Posts: 2109
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

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

Post by pjj »

Still grappling with replace in a string? :wink: Try DeleteStr instead of Delete; works for me.
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus
User avatar
Rickard Johansson
Site Admin
Posts: 6577
Joined: 19 Jul 2006 14:29

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

Post 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);
User avatar
pjj
Posts: 2109
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

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

Post 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);
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus
User avatar
Rickard Johansson
Site Admin
Posts: 6577
Joined: 19 Jul 2006 14:29

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

Post 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.
User avatar
micha_he
Posts: 570
Joined: 24 Jul 2011 12:16
Location: Helmstedt, NDS, Germany

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

Post by micha_he »

Thanks, DeleteStr() do it...
Post Reply