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: 529
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: 1784
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: 6001
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: 1784
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: 6001
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: 529
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...

chal1oye
Posts: 1
Joined: 26 Nov 2013 10:42

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

Post by chal1oye »

Still grappling with replace in a string? :wink: Try DeleteStr instead of Delete; works for me.

ashleygull
Posts: 1
Joined: 29 Dec 2014 06:46

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

Post by ashleygull »

It looks like the state of the Macro system is questionable, full of bugs,
and things that do not work, and more or less unusable.

Is that true?
gull

Post Reply