Posted by fwhilton in SWF Studio V3 on Sep 11 2008, 01:25 pm

I can not get this to work on the most basic sample.

1) Have Test.exe (this runs the shell.excute)
2) Have Junk.exe (this is what is shelled)
3) I have ssCore.init and synchronousCommands = true



on(release){
    ssCore.Shell.execute({path:"Junk.exe", winState:'hidden'});
}



There is no other code in both exe's
The Junk.exe does appear, but it is not suppose to.

????


Posted by fwhilton in SWF Studio V3 on Sep 11 2008, 01:36 pm

I checked the results and it is returning false.

So it is no working properly.
I followed the code in the example help as best I could.

:)


Posted by fwhilton in SWF Studio V3 on Sep 11 2008, 01:42 pm

Well.. i tried the exact sample in the help file... and that works using

ssCore.Shell.execute({path:"windows://notepad.exe", winState:"hidden"});

So, what is wrong with my path?

:)


Posted by northcode in SWF Studio V3 on Sep 11 2008, 01:43 pm

SWF Studio EXE files force themselves to appear and get the input focus. If you want Junk.exe to be hidden, use the start hidden option on the Application Tab when you build Junk.exe.

Also, what you've supplied in the path for the call to shell.execute is just a file name, not a path, try "startdir://junk.exe".

Oh, and stop talking to yourself :evilgrin:


Posted by fwhilton in SWF Studio V3 on Sep 11 2008, 01:45 pm

I doulble checked my result, and it is returning true.

So why is the app still displaying?

:)


Posted by fwhilton in SWF Studio V3 on Sep 11 2008, 01:47 pm


QUOTE: from northcode;45423
SWF Studio EXE files force themselves to appear and get the input focus. If you want Junk.exe to be hidden, use the start hidden option on the Application Tab when you build Junk.exe.

Also, what you've supplied in the path for the call to shell.execute is just a file name, not a path, try "startdir://junk.exe".

Oh, and stop talking to yourself :evilgrin:


I can't do that... because the project I am working on (template exe) has to be able to display when the user runs it.

I want EXE1 (IDE) to hide the template while I write to it.

:)


Posted by fwhilton in SWF Studio V3 on Sep 11 2008, 01:48 pm


QUOTE: from northcode;45423
SWF Studio EXE files force themselves to appear and get the input focus. If you want Junk.exe to be hidden, use the start hidden option on the Application Tab when you build Junk.exe.

Also, what you've supplied in the path for the call to shell.execute is just a file name, not a path, try "startdir://junk.exe".

Oh, and stop talking to yourself :evilgrin:


Oh... I didn't realize i was talking to myself.

Sorry.

:)


Posted by northcode in SWF Studio V3 on Sep 11 2008, 01:49 pm

Yes you can. Make it start hidden and pass it a command line argument to tell it what mode it's running in. If it sees a command line argument then it's in template mode and stays hidden. If it doesn't get a command line argument then the user started it, so have it display itself.


Posted by fwhilton in SWF Studio V3 on Sep 11 2008, 01:52 pm


QUOTE: from northcode;45428
Yes you can. Make it start hidden and pass it a command line argument to tell it what mode it's running in. If it sees a command line argument then it's in template mode and stays hidden. If it doesn't get a command line argument then the user started it, so have it display itself.

I know what passing arg is.
But, how do I do it inside an exe?
And what how do I tell which mode I am in (using code)?

:)


Posted by northcode in SWF Studio V3 on Sep 11 2008, 01:55 pm

You are launching the EXE so you can send it data (via sendData) so when you start it that way it's in "programmable" mode. All you do is add a command line argument to the call to Shell.execute so it gets passed to the exe when it starts.

When the user starts the modified EXE, they won't pass it the same command line argument so when you write the code for the template you make it look at the command line argument to decide what to do (stay hidden or show itself).


Posted by fwhilton in SWF Studio V3 on Sep 11 2008, 06:45 pm

I have stumbled across another issue along these lines.

When I click the "Create EXE", I first have to find the window from the running apps (using hwnd etc)

I then look for the title on each window.

I am getting strange behavior of not finding and saving. I really can not nail what it really is doing.

So, I want to know... does finding the hwnd and window title use the current window title or the saved title in the scratch area.

I am asking, because when you send data to EXE2 the data is not actually saved until EXE2 is closed.

Sometimes it works, sometimes my EXE2 says "undefined" when it loads and displays if the user changes the title consectivetly.

This seems to be where all my troubles are coming from.
If I can nail the saving of the title, launching of EXE and how the user handles the created exe, then I will be well on my way.

:)


Posted by fwhilton in SWF Studio V3 on Sep 11 2008, 10:47 pm

I have an extensive debug log of a weird issue.

I HAVE FINALLY... got the window to close!! :)

However, it closes in the wrong place because the hwnd runs in the wrong place, yet I have the function higher up in my code routine...

NOTICE the 2nd TEMPLATE section (in blue), that should be happening in the "OnSend" function.

It seems, because it takes so long to get the hwnd, that the code after the OnSend executes before it is done getting the hwnd.

My app should do this ( all this is in button click, except OnSend and WindowList functions)...
- Create Output dir
- OnSend (getWinList, Hwnd, SendData to EXE2 and close it, save scratch)
- delete old template.exe
- copy template to output dir
- save txt file for exe
- open new template exe

Debug LOG:

<font color='Blue'>MAIN IDE</font>
create dir?
 <B><font color='red'>onSend</font></B><font color='SeaGreen'><-- below hwnd (in red) should be here. EXE2 should close here</font>
delete exe
copy exe
save data file
<font color='blue'>TEMPLATE</font>
load file
<font color='Blue'>MAIN IDE</font>
open exe file
 <B><font color='Red'>...........1706116   VISIBLE   template   ThunderRT6FormDC
HWND: 1706116</font></B>
<font color='blue'>TEMPLATE</font>
t: mystr1=CLOSE
txt: mystr1=CLOSE
wState: CLOSE
recieve data from IDE
close app   <----- EXE2 should close here
save template data


Why is the hwnd function returning so late?
So, everything from the (red) down (above) should happen in the OnSend function.

Here is my simplfied code...

MAIN IDE (EXE1)

ssCore.init();
ssDefaults.synchronousCommands = true;

function OnSend(){
   ssCore.SysInfo.getWindowList({showHidden:false}, {callback:onWindowList});
}

function onWindowList(return_obj, callback_obj, error_obj){
   var xtarget = 0;
   var rows = return_obj.result.split("\r");
   var cols;
   var hwnd,status,caption,classname;
   var tName;
   tName = "template";
   for (var i=0; i<rows.length; i++){
      cols = rows[i].split("\t");
      hwnd = cols[0];
      status = cols[1];
      caption = cols[2];
      classname = cols[3];
      if (caption.indexOf(tName) != -1){
         xtarget = hwnd;
      }
   }
   doSend(xtarget);
}

/////////////////////////////////////////////
//close the app if open /////////////////////
/////////////////////////////////////////////
function doSend(xtarget){

   var hwnd = Number(xtarget);
   if (hwnd != 0) {
      var t:LoadVars = new LoadVars();
      t.mystr1 = "CLOSE";
      ssCore.App.sendData({hwnd:hwnd, data:t.toString()});
   } else {
      ssDebug.trace("didn't find window to close");
   }
}

function CreateTXT(){
   //SIMPLFIED (REMOVED CODE)/////////////////////
   ///////////////////////////////////////////////

   //chk if folder exists
   
   //get window, send data and close if open
   // --------------> EXE2 should be delete in this function <-------------------
   OnSend();
   
   //delete current exe
      
   //copy new exe to folder
      
   //save data file for exe
   
   //open exe
}


TEMPLATE (EXE2)

ssCore.init();
ssDefaults.synchronousCommands = true;

//SIMPLIFIED (REMOVED CODE) ////////////////////////
///////////////////////////////////////////////////

//load text file from ide

// reads data from scratch area

// RECIEVE DATA FROM IDE //////////////////////////
/////////////////////////////////////////////////////////

function OnDataEvent(return_obj, callback_obj, error_obj){
   ssDebug.trace("TEMPLATE");
   var txt;
   var wState;
   wState = "";
   txt = return_obj.result;
   ssDebug.trace("txt: " + txt);
   var myTxt:LoadVars = new LoadVars();
   myTxt.decode(txt);
   wState = myTxt.mystr1;
   ssDebug.trace("wState: " + wState);
   if (wState == "CLOSE"){
      ssDebug.trace("recieve data from IDE");
      ssCore.App.quit();
   } else {
      ssDebug.trace("recieve data DID NOT WORK");
   }
}
ssCore.App.setNotify({event:"OnData"}, {callback:OnDataEvent});

// calls the save data function when closed

// saves data to scratch area


ALSO.... how would I implement the commandline arg to the template exe to make it hidden (which I know is set in SWFS tab) and then visible to the user. I understand the theory, but I not real sure as to what code I use to send and get it. I looked in the help file and found a little on getCommandLine(), but notmuch on sending command lines.

Do you have a small example of what I am looking for?

:)


Posted by northcode in SWF Studio V3 on Sep 12 2008, 12:00 am

Inside the OnSend function you are asking for the window list by calling getWindowList asynchronously. There is no guarantee that the window list will be available by the time OnSend returns (where you call it). If that's what you want then you have to call it synchronously.

When you start an application (like you do from a command prompt) you can pass arguments on the command line, e.g.


 <B>C:></B> c:\windows\system32\notepad.exe c:\test.txt


When you do this programmatically the "c:\test.txt" is the command line you want to pass to notepad. In VB (since you know VB) you would do it like this:


Shell "c:\windows\system32\notepad.exe c:\test.txt"


In SWF Studio you use Shell.execute to do the same thing, like this:


ssCore.Shell.execute({path:"c:\\windows\\system32\\notepad.exe", arguments:"c:\\test.txt"});


If you are using Shell.execute to start a SWF Studio application then the command line that is passed in (whether it is done manually at a prompt, or programmatically as with Shell.execute) is available in ssGlobals.ssCmdLine or by calling ssCore.App.getCommandLine.

ssCore.Win.show will make a hidden application visible again.


Posted by fwhilton in SWF Studio V3 on Sep 12 2008, 08:04 am


QUOTE: from northcode;45435
Inside the OnSend function you are asking for the window list by calling getWindowList asynchronously. There is no guarantee that the window list will be available by the time OnSend returns (where you call it). If that's what you want then you have to call it synchronously.

Okay, I thought by calliing it at the begining "sycn = true" that all calls were sync.

So, I assume then that by the paramobjects I am passing, that "that" call is actully acync? Right?

QUOTE:

When you start an application (like you do from a command prompt) you can pass arguments on the command line, e.g.


 <B>C:></B> c:\windows\system32\notepad.exe c:\test.txt


When you do this programmatically the "c:\test.txt" is the command line you want to pass to notepad. In VB (since you know VB) you would do it like this:


Shell "c:\windows\system32\notepad.exe c:\test.txt"


In SWF Studio you use Shell.execute to do the same thing, like this:


ssCore.Shell.execute({path:"c:\\windows\\system32\\notepad.exe", arguments:"c:\\test.txt"});


If you are using Shell.execute to start a SWF Studio application then the command line that is passed in (whether it is done manually at a prompt, or programmatically as with Shell.execute) is available in ssGlobals.ssCmdLine or by calling ssCore.App.getCommandLine.

ssCore.Win.show will make a hidden application visible again.


I understand CMD.. arg.
I am just not sure what argument to throw at EXE2 to make it visible.


ssCore.Shell.execute({path:"template.exe", arguments:"?????????????"});


If I use sendData, how do I use shell.execute with sendData. Those seem like totally different functions.

:)


Posted by fwhilton in SWF Studio V3 on Sep 12 2008, 09:35 am

Okay... I got the sync windowlist to work.
It is now firing in the right spot and my window closes in the right spot.

I may still need a little help with sending the cmdline to a hidden window. But, I am working on it.

Q:
Now... in post #11 (above) I asked how HWND finds the window title. Visible title or saved title in exe?
I've always understood what is visible. But, how does SWFS find a window?

It matters to my project because their is a timing issue with closing exe2 and displaying again, while sending data to the window before it is saved.

:)


Posted by fwhilton in SWF Studio V3 on Sep 12 2008, 09:49 am

Tim, the examples you are giving are for just launching apps (with a file).

I am trying to figure out how to tell EXE2 to show (because it is hidden from SFWS IDE).

All I am thinking (and I am sure this is wrong) is..

ssCore.Shell.execute({path:"template.exe", arguments:ssCore.Win.show()});

Sorry, but I do not understand what arg goes in the arg param.

I looked at the help file for ssGlobals.ssCmdLine and there is nothing there for arg's or example code.

:)


Posted by AGo in SWF Studio V3 on Sep 12 2008, 10:07 am

ssGlobals.ssCmdLine will contain the string you passed to exe2 via the arguments parameter. so all you have to do is to compare ssCmdLine with the argument that´s send by your other app and if those match, call ssCore.Win.show


Posted by fwhilton in SWF Studio V3 on Sep 12 2008, 10:47 am


QUOTE: from AGo;45442
ssGlobals.ssCmdLine will contain the string you passed to exe2 via the arguments parameter. so all you have to do is to compare ssCmdLine with the argument that's send by your other app and if those match, call ssCore.Win.show

So... like this?

ssCore.Shell.execute({path:"template.exe", arguments:"ShowMyApp"});

Then somehow, compare it on the EXE2 side?
:)


Posted by AGo in SWF Studio V3 on Sep 12 2008, 10:51 am

right, somehow,...


Posted by fwhilton in SWF Studio V3 on Sep 12 2008, 10:54 am

I also have another issue...

Currently it looks like I am using onQuit aycn.

ssCore.App.setNotify({event:'onQuit'}, {callback:'saveData', scope:this});

However, my data is saved after some other functions fire off. As Tim suggested above for my hwnd issue (which is fixe dusing sync)

I want to convert this to sycn too. But, how do I call a function using it sync??

var returnObject = ssCore.App.setNotify({event:'onQuit'});

Where do I call a function from the sync line above?

I am closing the EXE2 and it saves the scratch area. But, I need it to finish before moving on in my code.

:)


Posted by northcode in SWF Studio V3 on Sep 12 2008, 10:56 am

The command line arguments are like a blank canvas, you can pass whatever you like and interpret the command line however you like.

But if you're building an EXE that users will launch then you can't rely on the command line being set to "ShowMyApp" or anything else. You want to use the command line to signal to EXE2 that it's running in a special mode when YOU start it (so it stays hidden) and when the USER starts the app by double clicking on it there won't be anything on the command line and that is your signal to make EXE2 show itself by calling ssCore.Win.show.

Unless I'm missing something about how you're going to use EXE2 I'm not sure how where the confusion is coming from.


Posted by fwhilton in SWF Studio V3 on Sep 12 2008, 10:59 am


QUOTE: from AGo;45446
right, somehow,...

I know how to do IF's (I wasn't asking that) :)

I mean... do I use onData (setNotfiy) or something like that. Or am I suppose to sendData first??

This is how I am thinking it... (exe2 is hidden by SWFS ide setting)

- Click button
- shell.execute (send arg: "KeepMyAppHidden")
- Inside EXE2 If.... ???? (do I use getCommandLine?)
- If true then keep hidden, else keep user will se it

:)


Posted by fwhilton in SWF Studio V3 on Sep 12 2008, 11:17 am


QUOTE: from northcode;45448
The command line arguments are like a blank canvas, you can pass whatever you like and interpret the command line however you like.

But if you're building an EXE that users will launch then you can't rely on the command line being set to "ShowMyApp" or anything else. You want to use the command line to signal to EXE2 that it's running in a special mode when YOU start it (so it stays hidden) and when the USER starts the app by double clicking on it there won't be anything on the command line and that is your signal to make EXE2 show itself by calling ssCore.Win.show.

Unless I'm missing something about how you're going to use EXE2 I'm not sure how where the confusion is coming from.


Okay... This is what I am doing.
FYI... I have the template.exe (exe2) visible to show you. But I am hoping that it will be invisble so I can give the illusion that I am creating an exe without them seeing it. However, they will see it after "pretend compile".

1) User clicks "Create EXE" button
2) (now remember, lets pretent EXE2 is hidden)
3) Checks to see if EXE2 is open, if it is close it .
4) Delete last EXE and copy another one to output folder
5) Open exe2
6) Sends data to it
7) Close it and save to scratch area
6) Then it displays to the user in a saved state.

If the user has it opens, and they click the Create EXE again, my code then closes it and goes through the process again.

[ATTACH]1469[/ATTACH]

Does this make sense?
I am using two apps
1) MainIDE (EXE1)
2) Template.exe (EXE2) (this is what the user would distribute)

:)


Posted by fwhilton in SWF Studio V3 on Sep 12 2008, 06:02 pm

I was wondering, what progression does a compiled exe execute from start to finish (when window display)?

Example...

1) EXE is initialized
2) internal scratch area is read
3) rest of binary (code) is read from within file
4) Window is displayed

I need to know, because I need to know where I can put code that excutes after an exe has displayed or just prior to it displaying.

I cannot seem to get my window to hide using...
ssCore.Win.hide();

Yet, I can excute this code in a button.

???


Posted by northcode in SWF Studio V3 on Sep 12 2008, 06:10 pm

1. the app starts
2. your main movie is loaded
3. you read the data from the scratch area and do stuff with it

If you use the "start hidden" option then YOU have control over what
happens after step 2. You can do anything you want before calling Win.show to make your application visible.


Posted by AGo in SWF Studio V3 on Sep 12 2008, 06:10 pm

as a rough estimation, the window is displayed after you call Win.show or at latest after all script on the first frame was executed, but before any timer code is executed.
Not sure if calling Win.hide in the first frame will stop that (never tried it, if I need a hidden window I start it as hidden and make it visible as soon as I want it to be). The NC guys may shed some light on that.

The scratch area is only read when you want to read it.

the swf will be fully extracted and loaded prior your first code line is executed.

edit: Tim scores again,...


Posted by fwhilton in SWF Studio V3 on Sep 12 2008, 06:26 pm


QUOTE: from northcode;45453
1. the app starts
2. your main movie is loaded
3. you read the data from the scratch area and do stuff with it

If you use the "start hidden" option then YOU have control over what
happens after step 2. You can do anything you want before calling Win.show to make your application visible.


Well, that is what I thought... however... the window doesn't display.
I read from scratch area... compare... and nothing happens

See code...

function readData(){
   var r;
   r = ssCore.Scratch.read();
   if (r.success){
      var txt;
      txt = r.result;
      var myTxt:LoadVars = new LoadVars();
      myTxt.decode(txt);
      <font color='RoyalBlue'>access.text = myTxt.myaccess;</font>
      str1.text = myTxt.mystr1;
      str2.text = myTxt.mystr2;
      <font color='Red'> <B>if (access.text == "DEV"){
         ssCore.Win.hide();
      } else {
         ssCore.Win.show();
      }</B></font>   
               } else {
      ssDebug.trace('ERROR: '+r.Error.description);
   }
}


I have it the hidden flag check in SWFS Application tab. So it is staying hidden.

I know there is data in the access.text because I am looking at it.

??? (confused)
Why doesn't it work?

:)


Posted by northcode in SWF Studio V3 on Sep 12 2008, 06:55 pm

Does the LoadVars decode method execute synchronously or does it generate an event on the LoadVars object that you have to wait for? If you can post your EXE somewhere, I'll download it and run it in the debugger to see if I can find anything obvious.


Posted by fwhilton in SWF Studio V3 on Sep 12 2008, 06:59 pm


QUOTE: from northcode;45456
Does the LoadVars decode method execute synchronously or does it generate an event on the LoadVars object that you have to wait for?

It is sycn... immediatetly

I am almost getting it.... check back in 15 minutes or so.

15 MIN UPDATE: I got it to work once by accident.
I have to rearrange some code sequinences so that it accounts for hidden and if it is open.

Thanks
:)


Posted by fwhilton in SWF Studio V3 on Sep 12 2008, 07:54 pm

I think I got my sequence of code blocks right.

However, it doesn't seem to be closing the app when it is running and hidden.

Is there any issues with trying to do that?
I can close it fine when it is visible, but not hidden.

:)


Posted by fwhilton in SWF Studio V3 on Sep 12 2008, 08:58 pm

Okay, I found the problem.

My EXE2 is in hidden mode, I need to launch the app. I use this line...

ssCore.Shell.execute({path:'startdir://Output\\' + xFile, waitForWindow: <B><font color='Red'>true</font></B>});

The MainIDE code stops after it launches and runs the EXE2. The template EXE is open and hidden, but, code execution stops. Therfore I can't close the app.

And... If kill the template.exe running process (CTR+ALT+DEL), then code in my MainIDE finishes executing.

But, If I change waitforwindow to FALSE... it keeps going, but, now it executes the code afterwards and my code gets out of sync.

What do I do?

I am almost there!!
arrrrrrrrrhhhhhhhhhh :)


Posted by northcode in SWF Studio V3 on Sep 12 2008, 11:05 pm

The waitForWindow argument tells Shell.execute to wait for the target applications main window to appear. When you launch your application in hidden mode, the window won't appear, so your main app just waits (because that's what you told it to do).

There are a couple of things you can do to get around this. The easiest is probably to use App.sendData to find the application that you just launched and have it send you back its window handle.

If you set the broadcast flag of App.sendData to true it will send a message to all running SWF Studio applications, but you don't need to know their window handles for this to work, App.sendData will find them for you.

So here's what you have to do...

In EXE1, launch EXE2 (don't set waitForWindow) but pass your HWND (EXE1's HWND) on the command line to EXE2 so it knows how to talk to you + whatever else you're sending so it knows to start in hidden mode.

In EXE2, read the command line and get the HWND of the calling application that started it (EXE1) and send your HWND (EXE2's HWND) back to the caller so it can send the startup parameters.

An application can get its own HWND from ssGlobals.ssHWND.


Posted by fwhilton in SWF Studio V3 on Sep 12 2008, 11:11 pm

I got everything pretty much working (hiding & displaying)

However... my HWND code is spotty. Sometimes the HWND is correct and sometimes it isn't. It is inconsistant. And I do open and close EXE2 couple of times in a process.

Here it is...

//GET HWND FROM WINDOW LIST

function getHWND(){
   ssDebug.trace("get HWND window list");
   var return_obj = ssCore.SysInfo.getWindowList({showHidden:true});
   //var return_obj = ssCore.SysInfo.getWindowList({showHidden:false});
   ssDebug.trace(return_obj.result);
   
   //DECLARE VAR
   var cmdLine = "";
   var xMode = "";
   var xtarget = 0;
   
   var xrows = return_obj.result.split("\r");
   var xcols;
   var xhwnd,xstatus,xcaption,xclassname;
   var tName;
   tName = "template";
   for (var i=0; i<xrows.length; i++){
      xcols = xrows[i].split("\t");
      xhwnd = xcols[0];
      xstatus = xcols[1];
      xcaption = xcols[2];
      xclassname = xcols[3];
      if (xcaption.indexOf(tName) != -1){
         xtarget = xhwnd;
      }
   }
   ssDebug.trace("HWND#: " + xtarget);
}


Posted by fwhilton in SWF Studio V3 on Sep 13 2008, 08:34 am

I noticed something... not sure what to do about it (Windows thing?)

After I close EXE2 (which is hidden) using HWND and setNotify...
Then I run EXE2 (template) and display it visibly.

If the user closes EXE2 manually and then clicks the create exe button again...
When my code in EXE1 looks to see if EXE2 is still open, it returns TRUE (it still thinks it is open)

Hmmm.... How do I refresh the HWND list so that it is acurate in EXE1 (Main IDE)??

:)

UPDATE 1: My HWND returned a number that is not in the window list (hwnd#: 1443588). It seems that was the number when it was open. So... how do I refresh the window list or MainIDE app??

UPDATE 2: Fixed... I wasn't clearing the HWND var before every lookup.

UPDATE 3: I found another problem... HWND was picking up my FLA named template. So, there was two "template" files.
So, I am going to allow a user to name his own Window Title and what if he happens to name it an exact name that may be alreading in the window list?

:)


Posted by fwhilton in SWF Studio V3 on Sep 13 2008, 11:08 am

Here is my code that works, but not perfectly.
I use Ago's sleep plugin too.

Can anyone see how I can do this better?

MAINIDE.EXE

//IMPORTS
ssCore.init();
ssDefaults.synchronousCommands = true;

//STARTUP
stop();

var cmdLine = "";
var xMode = "";
var xtarget = 0;

// START BASIC FUNCTION ROUTINES
function CreateEXE(){
   
   var cmdLine = "";
   var xMode = "";
   var xtarget = 0;
   
   //chk if dir exists
   chkDir();
   
   //get window list and hwnd
   getHWND();
      
   //which mode are we in and execute
   doMode();
}

//CHECK IF DIR EXISTS
function chkDir(){
   ssDebug.trace("DIR? ----------- START --------------------------------------------------");
   var r = ssCore.FileSys.dirExists({path:"startdir://Output"});
   if (r.success == true){
      ssDebug.trace("dir exist");
      //nothing here - already exists
   } else {
      ssDebug.trace("create dir");
      //pause code
      ssDebug.trace("pause....");
      ssCore.AGosTools.sleep({ms:1000});
      ssCore.FileSys.createDir({path:"startdir://Output"});
   }
}

//GET HWND FROM WINDOW LIST
function getHWND(){
   ssDebug.trace("GET HWND ------------------------------------");
   
   var return_obj = ssCore.SysInfo.getWindowList({showHidden:true});
   //var return_obj = ssCore.SysInfo.getWindowList({showHidden:false});
   ssDebug.trace(return_obj.result);
      
   var xrows = return_obj.result.split("\r");
   var xcols;
   var xhwnd,xstatus,xcaption,xclassname;
   var tName;
   tName = "Template EXE";
   for (var i=0; i<xrows.length; i++){
      xcols = xrows[i].split("\t");
      xhwnd = xcols[0];
      xstatus = xcols[1];
      xcaption = xcols[2];
      xclassname = xcols[3];
      if (xcaption.indexOf(tName) != -1){
         xtarget = xhwnd;
      }
   }
   ssDebug.trace("hwnd#: " + xtarget);
}

//SET MODE WE ARE IN
function doMode(){
   ssDebug.trace("DOMODE ------------------------------------");
   if (xtarget == 0){
      ssDebug.trace("doMode: NONE");
      xMode = "NONE";
      //cmdLine = "onStart"
   } else {
      ssDebug.trace("doMode: OPEN");
      xMode = "OPEN";
      cmdLine = "onClose"
   }
   exeMode();
}

//EXECUTE MODE WE ARE IN
function exeMode(){
   ssDebug.trace("EXEMODE ------------------------------------");
   ssDebug.trace("xMode: " + xMode);
   if (xMode == "NONE"){
      delcopyexe();
      ShowEXE();
      delExeFile();
      ShowEXE();
   } else {
      if (cmdLine == "onStart"){
         //doStart(xtarget);
         ssDebug.trace("cmdLine: onStart");
      } else {
         ssDebug.trace("cmdLine: onClose");
         doClose(xtarget);
         delExeFile();
         ShowEXE();
      }
   }
}

//DEL-COPY-SAVE NEW EXE/TXT TO OUTPUT FOLDER
function delcopyexe(){
   ssDebug.trace("DEL-COPY-SAVE ------------------------------------");
   
   //save exeFile.txt
   ssDebug.trace("save exeFile.txt");
   ssDebug.trace("pause....");
   var exeFile
   exeFile = "exeFile.txt";
   var t:LoadVars = new LoadVars();
   t.myaccess = "USER";
   t.mystr1 = str1.text;
   t.mystr2 = str2.text;
   ssCore.FileSys.writeToFile({path:"startdir://Output\\" + exeFile, data:t});
   
   //pause code
   ssCore.AGosTools.sleep({ms:2000});
   
   //delete current exe
   ssDebug.trace("delete exe");
   ssDebug.trace("pause....");
   var xFile:String;
   xFile = "template.exe";
   ssCore.FileSys.deleteFile({path:'startdir://Output\\' + xFile});

   //pause code
   ssCore.AGosTools.sleep({ms:2000});

   //copy new exe to folder
   ssDebug.trace("copy exe");
   ssDebug.trace("pause....");
   ssCore.FileSys.copyFile({from:"startdir://template.exe", to:"startdir://Output\\" + xFile});
   
   //pause code
   ssCore.AGosTools.sleep({ms:2000});
}

//CLOSE EXE WHEN OPEN
function doClose(xtarget){
   ssDebug.trace("CLOSE EXE ------------------------------------");
   var xhwnd = Number(xtarget);
   if (xhwnd != 0) {
      var t:LoadVars = new LoadVars();
      t.mystr = "CLOSE";
      ///ssDebug.trace("t: " + t);
      ssDebug.trace("closing window...");
      ssDebug.trace("pause....");
      ssCore.App.sendData({hwnd:xhwnd, data:t.toString()});
      //ssCore.Win.sendMessage({target:"Template EXE", message:"Kill"});
      
      //pause code
      ssCore.AGosTools.sleep({ms:7000});
   
   } else {
      ssDebug.trace("didn't find window to close");
   }
}

//DELETE EXEFILE
function delExeFile(){
   ssDebug.trace("DELETE EXEFILE.TXT ------------------------------------");
   ssDebug.trace("pause....");
   var exeFile;
   exeFile = "exeFile.txt";
   ssCore.FileSys.deleteFile({path:'startdir://Output\\' + exeFile});
   
   //pause code
   ssCore.AGosTools.sleep({ms:2000});
}

//DISPLAY EXE TO USER
function ShowEXE(){
   ssDebug.trace("SHOW EXE ------------------------------------");
   ssDebug.trace("pause....");
   
   var xFile:String;
   xFile = "template.exe";
   ssCore.Shell.execute({path:'startdir://Output\\' + xFile, waitForWindow:true});
   
   //pause code
   ssCore.AGosTools.sleep({ms:7000});

}

/*
function doStart(xtarget){
   var hwnd = Number(xtarget);
   if (hwnd != 0) {
      var t:LoadVars = new LoadVars();
      t.mystr = "START";
      ssDebug.trace("t: " + t);
      ssCore.App.sendData({hwnd:hwnd, data:t.toString()});
      ssDebug.trace("start app");
   } else {
      ssDebug.trace("didn't find window to start");
   }

}
*/


TEMPLATE.EXE

stop();
ssCore.init();
ssDefaults.synchronousCommands = true;

ssDebug.trace("TEMPLATE ------------------------------------");
var exeFile;
exeFile = "exeFile.txt";

loadfile();

//load text file from ide
function loadfile(){
   ssDebug.trace("LOAD EXEFILE.TXT? ------------------------------------");
   ssDebug.trace("pause....");
   var r = ssCore.FileSys.readFile({path:"startdir://" + exeFile});
   if (r.success == true){
      var txt;
      txt = r.result;
      var myTxt:LoadVars = new LoadVars();
      myTxt.decode(txt);
      access.text = myTxt.myaccess;
      str1.text = myTxt.mystr1;
      str2.text = myTxt.mystr2;
      ssDebug.trace("loaded exeFile.txt");
      ssDebug.trace("quit template");   
      ssCore.App.quit();
      
   } else {
      ssDebug.trace("no exeFile.txt to load");
      readData();
   }
}

// reads data from scratch area
function readData(){
   ssDebug.trace("READ SCRATCH DATA ------------------------------------");
   ssDebug.trace("pause....");
   var r;
   r = ssCore.Scratch.read();
   if (r.success){
      var txt;
      txt = r.result;
      var myTxt:LoadVars = new LoadVars();
      myTxt.decode(txt);
      access.text = myTxt.myaccess;
      str1.text = myTxt.mystr1;
      str2.text = myTxt.mystr2;
      if (access.text == "USER"){
         ssDebug.trace("USER");
         //ssCore.Win.hide();
         ssCore.Win.show();
      } else {
         ssDebug.trace("DEV");
         //ssCore.Win.hide();
         //ssCore.Win.show();
         ssCore.App.quit();
      }
   } else {
      ssDebug.trace('ERROR: '+r.Error.description);
   }
}

function OnDataEvent(return_obj, callback_obj, error_obj){
   ssDebug.trace("TEMPLATE ------------------------------------");
   ssDebug.trace("recieved data from IDE");
   var txt;
   var wState;
   wState = "";
   txt = return_obj.result;
   var myTxt:LoadVars = new LoadVars();
   myTxt.decode(txt);
   wState = myTxt.mystr;
   ssDebug.trace("wState: " + wState);
   if (wState == "CLOSE"){
      ssDebug.trace("quitting app");
      ssDebug.trace("pause....");
      ssCore.App.quit();
   } else {
      ssCore.Win.show(); //ssCore.Win.hide()
   }
}
ssCore.App.setNotify({event:"OnData"}, {callback:OnDataEvent});

// calls the save data function when closed
ssCore.App.setNotify({event:'onQuit'}, {callback:'saveData', scope:this});

// saves data to scratch area
function saveData(){
   ssDebug.trace("SAVE SCRATCH DATA ------------------------------------");
   ssDebug.trace("pause....");
   var r;
   //r = ssCore.Scratch.write({data:data_ta.text});
   var t2:LoadVars = new LoadVars();
   t2.myaccess = access.text;
   t2.mystr1 = str1.text;
   t2.mystr2 = str2.text;
   r = ssCore.Scratch.write({data:t2.toString()});   
   ssDebug.trace("close template.exe");
   if (r.success == true){
      ssCore.App.forceQuit();
   } else {
      ssDebug.trace('ERROR: '+r.Error.description);
   }
}


Posted by fwhilton in SWF Studio V3 on Sep 13 2008, 11:27 am

The reason I did it this way is because ...

1) When using sendData from EXE1 to EXE2 you have to get the HWND. No problem, I can create a basic EXE this way.

2) The problem came when I wanted to change the Window Title of EXE2. Changing the title was easy.

3) But, because EXE2 is not saved until you close it, getting the hwnd & window title using sendData was difficult because it isn't saved yet.

I had a lot of trouble with it locking up, not reciving sendata, because the window title changed.

It just wasn't that easy dealing with the title.

If somebody can enighting me on how to handle that, please tell me how. And with some code if you can.

:)


Posted by AGo in SWF Studio V3 on Sep 14 2008, 08:49 am

let's stop that here now, I'll throw you an example together within the next few hours,...

I assume Flash 8 and AS 2?


Posted by fwhilton in SWF Studio V3 on Sep 14 2008, 09:05 am

My model code from above is taken from the LocalSend example on NC site.

Using the LocalSend example out of the box
I had two issues....

1) I can't set the Window Title dynamically. I used the data.text to set the window title with and try to find it with HWND. I want my user to be able to name his own window title.

That doesn't work because HWND has to find the window before it can senddata to the exe.

So, in my model the only way to get around that is to save and close it before they can go and change it again. Thus all the functionality I added to it. That makes the prcocess slower, with delayed screen redraws.

It's all the opening closing I have to do to just be able to find the window title if it's changed using HWND.

2) Using the LocaSend example out of the box (and making it hidden in SWFS settings), I am trying to use Win.Show to make it visible using the data.text. That works fine

On my model, on first start up there is no scratch area, so, depending if I am in DEV (keep hidden) or USER (make visible) is tricky. I ty to capture it on send data, but the EXE hangs and it doesn't do the onData.

Because I am trying to set thw window title dynamically through the user, I have been doing it the way I am (opening-saving-closing - then reopening to user is he chooses)

For the most part, I have it some what working, but it still quirky depending on what the user might do. I can't leave it to the user to leave it open and close it himself to make life easier... so I have to control the entire process of the create exe.

I know it seems like I am doing alot, but I am trying to simulate the creation of an EXE without the user seeing what is going on.

:)


Posted by fwhilton in SWF Studio V3 on Sep 14 2008, 09:06 am


QUOTE: from AGo;45488
let's stop that here now, I'll throw you an example together within the next few hours,...

I assume Flash 8 and AS 2?


Ago... how about If I send you my source, so you can see what I am trying to do?

UPDATE:
Here is source
REMOVED ZIP FILE (not good example see AGo's below)

:)


Posted by AGo in SWF Studio V3 on Sep 14 2008, 09:15 am


QUOTE: from fwhilton;45490
Ago... how about If I send you my source, so you can see what I am trying to do?


naahh please not, spare me ;)

Check back in like a hour,...


Posted by AGo in SWF Studio V3 on Sep 14 2008, 10:46 am

here you go

the basic idea is: mainide has the template exe integrated (see the files tab), then extract it if needed, passes the data to the template, the template programs itself, quits, and voila the magic is done.

if you have any questions let me know, but the whole code is less then 150 lines ;)

hmm, since the attachment try lead to a memory overflow on the server I uploaded it here

http://www.northcode.com/forums/files/andre-fwhilton.spx


Posted by fwhilton in SWF Studio V3 on Sep 14 2008, 12:52 pm

Sorry I am late... (I had to step out for awhile)

Okay... The cmdLine is a lot diffeent then I envisioned.
That pretty much does what I am looking for and close to what I was doing, but just a little different.
Your not using WindowList (Yea!!!)

Q's (based on your model)

1) What do you recommend for coding so that I can check if they have the created exe open?

2) I noticed you created the data to send internally; I should be able to use a normal txt file if I want, right?

3) Can I replace the way I put my data together using LoadVars? (I think i could)

What do you recommend for speed and effciency?

Thanks again
:)


Posted by fwhilton in SWF Studio V3 on Sep 14 2008, 12:58 pm


QUOTE: from AGo;45493
here you go

the basic idea is: mainide has the templat exe intregrated (see the files tab), then extract it if needed, passes the data to the template, the template programs itself, quits, and voila the magic is done.

if you have any questions let me know, but the whole code is less then 150 lines ;)

hmm, since the attachment try lead to a memory overflow on the server I uploaded it here

www.next-faction.de/andre/fwhilton.spx


I just noticed on the files tab, that the template exe is not listed there. It still worked though. I should beable to put it back and load it from there.

UPDATE... NEVER MIND! I had the tempate spf open and noth the MainIDE

:)


Posted by AGo in SWF Studio V3 on Sep 14 2008, 01:07 pm

1) I´d set up a LocalConnection as soon as the client starts, and periodicaly check if the mainIDE can connect to the client.

2) Not sure what you mean here. The layout ("Files" Tab in the SWF Studio IDE)
is used to include additional files into your projector. I used it to add the template exe into the mainIDE, so I can extract it whenever I need it and don´t
need to worry that the template.exe is distributed with the mainIDE or is placed
in a specific directory or such,... The layout of mainIDE.spf should contain the template.exe, while the layout of template.spf is empty.

3) you mean LoadVars.toString()/.decode() ? Sure. Just make sure you have a unique identifier at the very beginning of the arguments string (like I had with "WRITEME" or whatever that was ;) ) to be able to clearly identify if
the user passed any arguments or if the mainIDE called yourExe

edit: my answer was related to your original version of question 2, since you now edited it to another question:
2) sure, you can either pass the data directly (as in 3.) or only pass a filename of a file to be loaded by the template.exe for reading


Posted by fwhilton in SWF Studio V3 on Sep 14 2008, 01:10 pm


QUOTE: from AGo;45496
1) I'd set up a LocalConnection as soon as the client starts, and periodicaly check if the mainIDE can connect to the client.

2) Not sure what you mean here. The layout ("Files" Tab in the SWF Studio IDE)
is used to include additional files into your projector. I used it to add the template exe into the mainIDE, so I can extract it whenever I need it and don't
need to worry that the template.exe is distributed with the mainIDE or is placed
in a specific directory or such,... The layout of mainIDE.spf should contain the template.exe, while the layout of template.spf is empty.

3) you mean LoadVars.toString()/.decode() ? Sure. Just make sure you have a unique identifier at the very beginning of the arguments string (like I had with "WRITEME" or whatever that was ;) ) to be able to clearly identify if
the user passed any arguments or if the mainIDE called yourExe


I had the tempate spf open and not the MainIDE

Okay.... I will play with this and see what happens.

BTW... yours runs so much efficient then the way I was doing it.

I let you know how it goes!
Thanks Again AGO!

:)


Posted by AGo in SWF Studio V3 on Sep 14 2008, 01:19 pm


QUOTE: from fwhilton;45497

BTW... yours runs so much efficient then the way I was doing it.


Who would have guessed,.. ;) (scnr)

Good luck


Posted by fwhilton in SWF Studio V3 on Sep 14 2008, 05:04 pm

LocalConnection vs HWND (WindowList)
Which is better?

What if the user creates two different EXE's and they are both open?
How would LocalConn know the difference?

I need to be able to see if EXE is opened that user has enter in IDE.

:)


Posted by AGo in SWF Studio V3 on Sep 14 2008, 05:07 pm

why do you need to know that anyway? To kill the childs if they are open and to be replaced?


Posted by fwhilton in SWF Studio V3 on Sep 14 2008, 05:11 pm


QUOTE: from AGo;45503
why do you need to know that anyway? To kill the childs if they are open and to be replaced?

Yes... just like in other enviroments (even SWFS)
If the user tries to create the same EXE again, it won't if it is opened (generates error).

I guess I could just handle the error and tell the user to close it.
But I would rather just close it myself.

UPDATE 1: Here is the exact error that your code generates when extracting exe...

QUOTE:
"the extraction failed: LAYOUT_ERROR_COULD_NOT_CREATE_DESTINATION_FILE"

I guess I could just KILL the exe couldn't I?

UPDATE 2: No, I need Window Title to KILL. User could change title. The error generates because it sees the same exe name.
Can I kill by exe name instead of title?

:)


Posted by AGo in SWF Studio V3 on Sep 14 2008, 05:21 pm

so why don't you just kill it?

however a more gratefull solution would be to establish a local connection, and then send a message to the client to tell the user that the app will be now killed ;) Evben easier would be to just broadcast a message to all running instances using App.sendData, so you don't need to mess with multiple LCs.


Posted by fwhilton in SWF Studio V3 on Sep 14 2008, 05:31 pm

Well... KILL IT works!!

var fName;
fName = exeName_txt.text + ".exe"
ssCore.SysTools.killApp({application:fName});


Well, it may not be graceful, but it is just a few lines of code and I know it is gone!

Haven't used LocalConnection yet.... maybe later I will experiement with it.

So... THAT pretty much gives me what I really am looking for.

NO HWND WindowList
So efficient... I was doing it all wrong!

THANKS AGO!!

:)


Posted by fwhilton in SWF Studio V3 on Sep 14 2008, 05:55 pm

I need some education. I understand that the data passed needs a seperator.
However, I need some enlightment on the sections of code hightlight in red.

//figure out which separator we need
var sep = <font color='Red'> <B>chooseSeparator</B></font>(s1_txt.text+s2_txt.text);
var dataToBePassed = sep+s1_txt.text+sep+s2_txt.text;
   
//extract temp exe to new location
ssCore.Layout.extractFile({resource:"\\template.exe", destination:"startdir://Output\\"+exeName_txt.text+".exe"},
{<font color='red'> <B>sep:sep</B></font>, dataToWrite:dataToBePassed, callback:onExtracted});

//CHOOSE SEPERATOR
<font color='red'> <B>function chooseSeparator(data:String):String {
var seps:Array = ["|", ">", "<", "#", "*", "~", "+", "ß", "ä", "ö", "!", "$", "%"];
var chosed:String;
do {
    chosed = String(seps.shift());
} while (data.indexOf(chosed) != -1);
return chosed;
}</B></font>


I don't need to know about arrays.
But, why are you using an array to select a char.
Why couln't you just use "&" like regular flash data does.

Just curious

:)


Posted by fwhilton in SWF Studio V3 on Sep 14 2008, 06:29 pm

Okay I have figure out the selecteing of sep. Not sure why you need to do that. I can just do sep = "|";

Now... what is the link between these two statements (beside datToWrite - I understand that)?

{sep:sep, dataToWrite:dataToBePassed, ...}

and

ssCore.Shell.execute({waitForExit:true, arguments:"WRITEMENOW"+ <B><font color='Red'>c</font>.sep+<font color='red'>c</font>.dataToWrite</B>, path:r.destination}, ....);

What does the "c" represent?
I can not seem to debug.trace it. I keep getting undefined or object.

I undertsnad the char as such..
r = result, c = callback, e = error

If it is callback, why do we need them in the excute line?

I am learning alot here.

:)


Posted by AGo in SWF Studio V3 on Sep 14 2008, 07:21 pm

okay, first why I need the chooseSeparator function.
You got the idea, I need to be able to separate my data after I combined it into one single string.
Of course I could just use a single char like | or &, but what would happen if the user enters one of these chars into the textfields? The separation wouldn´t be possible anymore, unless I escape the chars somehow..
So what I do is to let Flash decide which separator to use. I give it a choice of possible separator chars (that´s what the array is containing) If one of the separators is not contained in the array I found a good delimiter char and used it. It´s not foolproof but close enough and I was too lazy to code anything more complicated with escaping chars and stuff ;)

For your second question:
As you see the mainIDE processes everything async, so the application does
not freeze during the execution of my commands. However that means that I need to use multiple functions and thereby multiple variable scopes. A local variable declared in function a will not be available in a callback function, unless I pass it over to it*. That´s what I did. I added the data I needed
in the callback object of the command, then the data is passed automagicaly
by SWF Studio to the callback object parameter (jep, that´s what the c stands for in the argument declaration) of the callback function, where I now have it available to do whatever I like with it.
Just for the records, it would have worked as well if I´d used the error or return objects as "data transporter" but
I prefer the CB object instead of the return object so I can be sure that my code will not break if NC happens
to add exact the name of my vars as new parameters to their function in the future.

Does that makes things clearer for you?


*: Of course I could have just used global vars, but you don´t want to mess with that in larger projects, so don´t start with that even in smaller projects


Posted by fwhilton in SWF Studio V3 on Sep 14 2008, 07:58 pm


QUOTE: from AGo;45509
okay, first why I need the chooseSeparator function.
You got the idea, I need to be able to separate my data after I combined it into one single string.
Of course I could just use a single char like | or &, but what would happen if the user enters one of these chars into the textfields? The separation wouldn´t be possible anymore, unless I escape the chars somehow..
So what I do is to let Flash decide which separator to use. I give it a choice of possible separator chars (that´s what the array is containing) If one of the separators is not contained in the array I found a good delimiter char and used it. It´s not foolproof but close enough and I was too lazy to code anything more complicated with escaping chars and stuff ;)

For your second question:
As you see the mainIDE processes everything async, so the application does
not freeze during the execution of my commands. However that means that I need to use multiple functions and thereby multiple variable scopes. A local variable declared in function a will not be available in a callback function, unless I pass it over to it*. That´s what I did. I added the data I needed
in the callback object of the command, then the data is passed automagicaly
by SWF Studio to the callback object parameter (jep, that´s what the c stands for in the argument declaration) of the callback function, where I now have it available to do whatever I like with it.
Just for the records, it would have worked as well if I´d used the error or return objects as "data transporter" but
I prefer the CB object instead of the return object so I can be sure that my code will not break if NC happens
to add exact the name of my vars as new parameters to their function in the future.

Does that makes things clearer for you?


*: Of course I could have just used global vars, but you don´t want to mess with that in larger projects, so don´t start with that even in smaller projects


#1) That makes sense with users possibly adding & or something like that. Now I see why...cool.

#2) I understand the "c" and what you did... cool

#3) I undertsnad gloabal var too well. I probally use them more then I should. However, it does allow me to use certain pieces of info through the entire app, where-as a function var can only be used in the function.

In VB & .NET Globals are wonderful!

So, why do you think global var are a messy matter in SWFS?

:)


Posted by AGo in SWF Studio V3 on Sep 14 2008, 08:05 pm

Sure thing, I don't say that globals are the pure evil, you just should not use them if you can avoid it as in this case. Usually what I do is to have one
_global.SETTINGS = new Object(); as central "collecting point" for everything I need to have in the global space. By that I get benefits of having the data everywhere but keep the global scope clean since I only declare a single identifier.

(That's only true for AS2 of course)


Posted by AGo in SWF Studio V3 on Sep 14 2008, 08:11 pm

Sure thing, I don't say that globals are the pure evil, you just should not use them if you can avoid it as in this case. Usually what I do is to have one
_global.SETTINGS = new Object(); as central "collecting point" for everything I need to have in the global space. By that I get benefits of having the data everywhere but keep the global scope clean since I only declare a single identifier.

(That's only true for AS2 of course)


Posted by fwhilton in SWF Studio V3 on Sep 14 2008, 08:15 pm

Just a quick Q on the chooseseperator.

How will it handle binary?

I have a sample on loading/saving binary of a swf and most it is all A-Z, 0-9 charatcers.

But what about binary that has all those funcky characters?

Could I Use a custom value for a seperator such as... "<>"?

:)


Posted by AGo in SWF Studio V3 on Sep 14 2008, 08:30 pm

Usually you handle binary data as hex-encoded strings, which only consists of 0-9 and A-F

Binaries are just numbers, just if you open them up in an text editor it tries to make sense out of it and converts them to UTF/ASCII representations, thats where the strange symbols come from


Posted by fwhilton in SWF Studio V3 on Sep 14 2008, 08:39 pm


QUOTE: from AGo;45518
Usually you handle binary data as hex-encoded strings, which only consists of 0-9 and A-F

Binaries are just numbers, just if you open them up in an text editor it tries to make sense out of it and converts them to UTF/ASCII representations, thats where the strange symbols come from


Yep... That's right, I forgot about that!!

I did try "<>" and that does work!!
UPDATE... Nope this doesn't work. It breaks it up on the "<<" and fields don't display.
I am sure I can fix that.

Man, you did a great job with this.. it leaves the code open for expansion and accounts for wierd user text.

Thanks
:)


Posted by AGo in SWF Studio V3 on Sep 14 2008, 09:00 pm

it can work with non-single-char delimiters, but you´ll need to do a little adaption

first change the delimiter in the mainIDE (which you probably already did),
then you need to adapt the template. the template expects the delimiter to be the first char (and only the first char) of the recieved data. somewhere in the coder there is something like sep = data.charAt(0). You need to change that to match your delimiter, either hardcode it or read it from the written data.


Posted by fwhilton in SWF Studio V3 on Sep 14 2008, 09:28 pm


QUOTE: from AGo;45520
it can work with non-single-char delimiters, but you´ll need to do a little adaption

first change the delimiter in the mainIDE (which you probably already did),
then you need to adapt the template. the template expects the delimiter to be the first char (and only the first char) of the recieved data. somewhere in the coder there is something like sep = data.charAt(0). You need to change that to match your delimiter, either hardcode it or read it from the written data.


Way ahead of you... but it isn't working.
I am using slice in place of charAt. I also tried hardcoding

MAIN IDE

var sep = "<<SEP>>";

EXE

//there is data from the scratch, parse it   
var xdata = data_obj.result;
ssDebug.trace("[EXE]: scratch loaded: " + xdata);
//var sep = xdata.charAt(0); //use only if using chooseseperator in IDE
var sep = "<<SEP>>"; //xdata.slice(0,7);
ssDebug.trace("[EXE]: var sep: " + sep);
var data_arr = xdata.split(sep);
//data_arr[0] and [1] will be an empty string
ssCore.Win.setCaption({text:data_arr[2]}, {sync:true});
s1_txt.text = data_arr[2];
s2_txt.text = data_arr[3];
// show the window
ssCore.Win.show();


Here is my SWFS trace (basic line)

QUOTE:
[EXE]: USER MODE -------------------------------------------------
[EXE]: scratch loaded: <><>data1<>data2


Hmmm... I hate then when something so easy should just work.
I was able to trace it out the above section just in flash...

See this (no SWF influencing at all)...

var xdata = "<<SEP>><<SEP>>data1<<SEP>>data2";
trace(xdata);
var sep = xdata.slice(0,7);
trace(sep);
var data_arr = xdata.split(sep);
trace(data_arr[2]);
trace(data_arr[3]);


Here is output

QUOTE:
<><>data1<>data2
<>
data1
data2


hmmm... I noticed that the ssDebug is stopping at line...

var sep = xdata.slice(0,7); <font color='red'> <B><--- Stops here</B></font>
ssDebug.trace("[EXE]: var sep: " + sep); <B><font color='Red'><--- doesn't display in debugger</font></B>


Posted by fwhilton in SWF Studio V3 on Sep 14 2008, 09:50 pm

Fixed...
Dummy me has to compile the MAINIDE so that the updated template is properly intergrated.

Okay... I am tired now.
I think I should be good to go for the night.

Thanks
:)