4DToday.com
Home Directory Classifieds Reference Archives
Site Info
About 4DToday.com
Contact Us
Version française
Quote
Developers (723)
4D Developers (591)
Web Developers (334)
Tools Publishers (201)
Instructors (166)
Web Hosts (58)
Resellers (90)
Software Publishers (300)
Search Developers
Products (384)
Plug-Ins (104)
Components (48)
Code Libraries (9)
Books (7)
Tools (42)
Vertical Applications (149)
Search Products
User Groups
All User Groups (23)
Classified Ads (11)
Help Wanted (3)
Opportunities Wanted (8)
Hardware Wanted (0)
Hardware for Sale (0)
Software Wanted (0)
Software for Sale (0)
Other (0)
Resources
4D
4D, Inc.
4D International
4D Wiki
4D Partner Central
4D Beginner's Center
4D Online Documentation
4D 2004 Example Applications
4D Example Databases
4D BugDisplayer
4D, Inc. Training
Message Lists
4D Mailing Lists
4D Tech Google Group
iNUG Archives (Nabble)
iNUG Archives (Gmane)
iNUG Message Index
Other
4D Code Exchange
4D Resources
Sviluppo4D.it (Italy)
4D Sources (4D Plugin API, 4D Pop & Miyako
Quote
I don't usually eat breakfast. I prefer to be asleep during the hours that it is served.
John Grisham, The Last Juror  
  Suggest a Quote  
Developer News
There are no news items at this time.
 Submit Future News    Archive 
Technical Tip
Starting a Method in a New Process
If you have a method that must always run in a new process, rather than creating one method only to launch another method in a new process, here's a technique that will allow the method to launch itself in a new process.

At the start of the method, just test to see if the method has received one more parameter than it would normally expect. If not, launch the method again using the New process function, and pass an extra parameter. When the Count parameters test is done again, the extra parameter lets the method know it should run its primary function.

For example, a method that doesn't require any parameters might look something like this:

  // EXAMPLE METHOD
  // Created by Wayne Stewart (May 1, 2015)
  //  Method is an autostart type
  //     me@us.com
  // ----------------------------------------------------

C_LONGINT($1;$ProcessID_i;$StackSize_i)

If (False//  Copy this to your Compiler Method!
C_LONGINT(EXAMPLE METHOD ;$1)
End if

  // ----------------------------------------------------

$StackSize_i:=512*1024

If (Count parameters=1)

ALERT("This is my Example Method")

Else
  // This version allows for any number of processes
  // $ProcessID_i:=New Process(Current method name;$StackSize_i;Current method name;0)


  // On the other hand, this version allows for one unique process
$ProcessID_i:=New process(Current method name;$StackSize_i;Current method name;0;*)

RESUME PROCESS($ProcessID_i)
SHOW PROCESS($ProcessID_i)
BRING TO FRONT($ProcessID_i)
End if

To automate this when programming add the following Macro to your macros file.



<macro name="AutoStart">
<text>` <method_name/>
` Created by <user_os/> (<date format="6"/>)
`  Method is an autostart type
`     me@us.com
` ----------------------------------------------------

C_LONGINT($1;$ProcessID_i;$StackSize_i)

if(false)  //  Copy this to your Compiler Method!
C_LONGINT(<method_name/> ;$1  )
end if

` ----------------------------------------------------

$StackSize_i:=512*1024

If (Count parameters=1)
<caret/>
Else
` This version allows for any number of processes
` $ProcessID_i:=New Process(Current method name;$StackSize_i;Current method name;0)

` On the other hand, this version allows for one unique process
$ProcessID_i:=New Process(Current method name;$StackSize_i;Current method name;0;*)

RESUME PROCESS($ProcessID_i)
SHOW PROCESS($ProcessID_i)
BRING TO FRONT($ProcessID_i)
End if
</text>
</macro>

  Submit a Tip    Archive 
Spotlight
ANZAC Day 100 Years Remembrance
ANZAC Day 100 Years Remembrance Anzac Day is a national day of remembrance in Australia and New Zealand, and is commemorated by both countries on 25 April every year to honour members of the Australian and New Zealand Army Corps (ANZAC) who fought at Gallipoli in Turkey during World War I. It now more broadly commemorates all those who died and served in military operations for their countries. Anzac Day is also observed in the Cook Islands, Niue, and Tonga.
  Suggest a Spotlight  
Survey Results
Today, we asked you...
When did you start using 4D?
Survey Results

Your vote: (no vote)
Total votes received: 56
  Suggest a Survey  
Events
There are no events scheduled for the upcoming fortnight.
  Submit an Event