Working with strings in FM

8 views
Skip to first unread message

paul.s...@telenet.be

unread,
Feb 24, 2023, 5:22:10 AM2/24/23
to filtermeister
Hi All,


This question might be lower than basic, but after countless number of attempts I don't care to be laughed at. It still remains a mist to me how strings behave in FM. There is a long list of string functions available, but alas no added lines of code of how to apply it in FM.

strcpy( str0, "RED, GREEN, BLUE");
This works,   setCtlTextv( 100, "    %s", str0);   reads correctly. But there are only 20 predefined variables in FM...

Therefore:
when I create a new char variable such as   char aa[ 256];
it reads shifted repeats from other char variables. What is wrong?

Since FM is C+ based, but not entirely works as C+, examples of C+ are rejected in the compiler.

- - - - - - - - - - - - - - - - - - - - - -

Question:
Would there be somebody so kind to list up some elementary, but in FM working examples of
1.   How to simply put a line of text into a variable, other than the 20 predefined ?
2.   And eventual: practical example of how to extract a selection, how to convert a character into a number, etc... ?


Thanks in advance !
Paul

Duncan Suss

unread,
Feb 25, 2023, 8:17:23 AM2/25/23
to FilterMeister Mailing List (FMML)
Hi Paul,

My understanding is that you'd use malloc() and free() for this.


On the wiki page for malloc, there's this snippet of code:

%ffp
OnFilterStart:
{
    // Allocate a string for
    // 255 characters
    char* buffer_1 = malloc(255);

    // ... I think you could use
    // strcpy( buffer_1, "RED, GREEN, BLUE");
    // setCtlTextv( 100, "    %s", buffer_1);

    free(buffer_1);
}

I hope this helps - it's been a long time since I did any FM coding, my apologies if this is the wrong way to do it.

Duncan

paul.s...@telenet.be

unread,
Feb 26, 2023, 9:01:05 AM2/26/23
to filter...@googlegroups.com
Thanks Duncan,

I have made several attempts including minor variations, but immediately a warning of memory acces violation appears, with an ultimate crash of Photoshop if you force to continu. In the best case, the text I tried for testing appeared correctly, but not without all these warnings. So we still missing something essential, or maybe this feature in FM might be limited to the 20 premade str0 to str19?

I can work arround those string functions and look for different solutions, but nonetheless I would like to get these strings see to work!

Again, does somebody still have somewhere some code that works like it should do, to use as a basic example?


Regards,
Paul

Van: "Duncan Suss" <dunc...@gmail.com>
Aan: "FilterMeister Mailing List (FMML)" <filter...@googlegroups.com>
Verzonden: Zaterdag 25 februari 2023 14:17:23
Onderwerp: [FMML2] Re: Working with strings in FM

--
You received this message because you are subscribed to the Google Groups "FilterMeister Mailing List (FMML)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to filtermeiste...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/filtermeister/f350977b-6698-4935-af1a-5c0dfd4965d2n%40googlegroups.com.

Duncan Suss

unread,
Mar 4, 2023, 9:58:15 AM3/4/23
to FilterMeister Mailing List (FMML)
Paul - I just remembered something which might be a partial explanation of what you are seeing.

Windows introduced a security feature called "DEP" (data execution protection, I think) that prevents programs from running code which they generated dynamically into memory. I don't remember when this was introduced - somewhere between XP and 7 I think.

Sorry I can't be any more help - I don't have a PC with a host for FM these days.

Duncan


paul.s...@telenet.be

unread,
Mar 7, 2023, 3:41:47 AM3/7/23
to filtermeister
In anyway, thanks for the info!
As told I will find a solution to work this around and obtain the same goal.

Beside this, does anybody have some examples or old material from working with text features in FM? A lot of string functions are listed in the Wiki, but as far I can see there are no decent demo codes available.

To bring some news: I recently succeeded to develop a technique for stable speed measurements of functions and pieces of code in FM. Since the concept is a comparison between an empty scan with a similar scan including the test object, the results are device independent. The name I sticked on it is called the 'Time increase factor', or Ti for short. It works really very precise, with a repeatability near 1 procent. It revealed already some interesting surprises! I'm actually further finishing this tool. Within some weeks I will post some results. I would like to add these Ti factors step by step in the Wiki. It's undoubtedly of great help to make the right choices in building a new filter with maximized response and creates at least awareness of the speed penalty you get when the coding is messy.


Greetings to all,
Paul

Van: "Duncan Suss" <dunc...@gmail.com>
Aan: "FilterMeister Mailing List (FMML)" <filter...@googlegroups.com>
Verzonden: Zaterdag 4 maart 2023 15:58:02
Onderwerp: Re: [FMML2] Re: Working with strings in FM

paul.s...@telenet.be

unread,
Mar 7, 2023, 9:53:58 AM3/7/23
to filter...@googlegroups.com
Hi John - Thanks for your response.
Don't you have some examples that demonstrates text items with this?

Greetings

Van: "John Weldy" <jwe...@frontiernet.net>
Aan: "paul simoens" <paul.s...@telenet.be>
Verzonden: Dinsdag 7 maart 2023 15:30:40

Onderwerp: Re: [FMML2] Re: Working with strings in FM

Hi Paul -- Just reading your note and more than likely you have tried this, but I have always used putArrayString and getArrayString FM calls to handle strings.   I shall be interested in your work.  I am an active listener on FMML, but rarely make comments.  Good luck with your efforts.

Cheers

John
Reply all
Reply to author
Forward
0 new messages