How do I use SendApplicationMessage

Discuss any general programming issues here
Post Reply
User avatar
Redlion
Posts: 125
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

How do I use SendApplicationMessage

Post by Redlion »

Hi all,

If i have and application say a Directory Program, how would I go about openning up the selected file, in an editor that I wrote.

Here are my thoughts,
Directory Program

Code: Select all

@OPTIONS {RegisterApplication = True}
.
.
.
Column1$, Column2 = mui.DoMethod("lvl" .. ActiveList, "GetEntry", "Active")
  If Column2 = -1
     SystemRequest(" EDIT ERROR ! ", " You can not Edit a Directory", "OK",  #REQICON_ERROR)
  Else
    Editor$ = "DH0:Hollywood_Programs/HWEditor"
    Execute(Editor$, "")
    SendApplicationMessage("DH4:Hollywood_Programs/HWEditor, Column1$)
  Endif
Editor Program

Code: Select all

@OPTIONS {RegisterApplication = True}
.
.
.
t, n, console = GetCommandline()
If n > 0
   File$ = t[0]
   moai.Set("editor", "Text", (FileToString(File$)), "Nonotify", True)
Endif
But I can not seem to get it to work.

I get an error
Cannot find Application DH0:Hollywood_Programs/HWEditor
File HWtemp.hws (current line:493 - In function SendApplicationMessage)

Has anyone got a working example that I can have a look at.

Cheers
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
User avatar
Redlion
Posts: 125
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

Re: How do I use SendApplicationMessage

Post by Redlion »

Hi All,

I figured it out, I was using the wrong Function.

GetFileArgument() is what I needed.

Here is how it works

In the Directory Program

Code: Select all

Case "edit"
      Column1$, Column2 = mui.DoMethod("lvl" .. ActiveList, "GetEntry", "Active")
      LvlFrom$ = mui.Get("lvs" .. ActiveList, "Contents")
      If Column2 = -1
        SystemRequest(" EDIT ERROR ! ", " You can not Edit a Directory","OK", #REQICON_ERROR)
      Else
        Editor$ = "DH4:Hollywood_Programs/HWEditor"
        Execute(Editor$, LvlFrom$ .. Column1$)        
      EndIf
and in the Editor Program

Code: Select all

File$ = GetFileArgument()
IF File$ <> ""
  moai.Set("editor", "Text", (FileToString(File$)), "Nonotify", True)
Endif

moai.Set("win", "Activeobject", "editor")

/*** main loop! **********************************************************************************/
Repeat
  WaitEvent
Forever
Cheers
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
Post Reply