Page 1 of 1

Posted: 05 Nov 2017, 16:16
by sephult
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

Posted: 09 Nov 2017, 20:45
by woodslanding
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.

Posted: 09 Nov 2017, 21:58
by oli_lab

Posted: 11 Nov 2017, 16:05
by sephult
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

Posted: 11 Nov 2017, 17:37
by senso
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;