Welcome to %s forums

BrainModular Users Forum

Login Register

FastScript - Script Function Updates

Tell us what you'd like Usine to do
Post Reply
sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 05 Nov 2017, 16:16

String Manipulation Suggestions:

pos ( ) :integer
I think it would be useful to add an argument to the pos( ) string position search function to ignore the case. It does not seem there is a good method to search while ignoring the case.

TString IndexOf
The TString.indexOf would benefit greatly from a sub-string search, as well as the ignore case argument as described above for the pos ( ).

These two search functions if updated I believe would enhance the String Manipulation greatly in the Fastscripts.

Also,
I don't think I've ever seen a function return an array. Is this because of issues with dynamic array sizing? Can functions pass :array of integer, etc...
I was also thinking that beyond a positional search that possibly there could be
a more detailed string search. Example

--------------------------------------------------------------------------------------------------------------------
function StrSearch(source: string, sub :string, ignoreCase :bool): array of Int32;
--------------------------------------------------------------------------------------------------------------------
You could then search for the substring (sub) within the (source) text, using True to ignore the case. The result will find the first position and the last match of the sub-string and return the index positions in an array of Result [0..1].
PSEUDO

Code: Select all

var result           : array [0..1] of integer;
var inputString    :string;
inputString := 'This is where the password starts'';

result := StrSearch( inputString , 'Pass' ,  1 );

//result[0] returns = 19 where 'p' begins regardless of case.
//result[1] returns = 22 because 'pass' ended at position 22_ 
//irregardless of 'password'
//Alternately, result[2] could be the count of matches
The results of this would be much more compatible with other string manipulation functions like the Copy who expects position and count where you could easily extract.

Just some ideas and suggestions I wanted to share. Doing some scripting and sometimes these things just got to write down. :D

-s
"Every act of creation is first an act of destruction." -Picasso

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 09 Nov 2017, 20:45

I don't know if this is really possible, as I believe Olivier is using an existing pascal library....

So my workaround also may not be possible. But I would love some sort of 'include' function, that could load some procedures that I always like to have in my scripts..... if that were possible, you could create your own methods to do these things, and not have to paste them into every script.
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

User avatar
oli_lab
Member
Posts: 1263
Location: Brittany, France
Contact:

Unread post by oli_lab » 09 Nov 2017, 21:58

http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 11 Nov 2017, 16:05

I agree woodslanding.
I wish there was a Config/Script/Functions and a Config/Script/Procedure directory that we could use.
It would be nice to place these and be able to reference as our own functions and procedures.
As add-ons it would be nice to have shared scripts as well. Definitely reduce redundancy and I think make the FastScript more useful.

Thanks Oli!
I'll give it a shot.

-s
"Every act of creation is first an act of destruction." -Picasso

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 11 Nov 2017, 17:37

unfortunately I have to keep the standard pascal as much as possible and I'm not sure it's a good idea to 'invent' new function an a so new language.
- for pos :

Code: Select all

pos(uppercase(s1),uppercase(s2))
does the trick for ignore case.

- I'm not sure I understand the difference between IndexOf and Pos.

- array's

Code: Select all

function mystuff:array of integer;    
var i : integer;    
begin                 
  setArraylength(result,10);
  for i := 0 to 9 do result[i] := i;
end;

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests