Announcement

Collapse
No announcement yet.

read from folder and write it to menubar

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • jassing
    replied
    Originally posted by GoOgLe View Post
    u r new to ams but u know coding much more than me jassing... i am new to coding and i am trying really hard to find solutions...

    still learning
    You'll never learn it if you have everyone else do it... But you've now got the code to load up a menu with file names, and then run it when selected...
    Good luck; I'll keep an eye out on the ams forums from time to time to see if something else interesting pops up.

    -j

    Leave a comment:


  • GoOgLe
    replied
    u r new to ams but u know coding much more than me jassing... i am new to coding and i am trying really hard to find solutions...

    still learning

    Leave a comment:


  • jassing
    replied
    Originally posted by jackdaniels View Post
    Not Tested But It Must Be Something Like That

    Code:
    if e_ID > 1000 then
    	runID=e_ID-1000
    	result = File.Run(runID, "", "", SW_SHOWNORMAL, false);
    end
    Since I'm new to AMS (actually; just found the menu question interesting) I'm not even following that code.. but I just tried this in the On Menu action:


    Code:
    if e_ID > 1000 then
      File.Run(e_ItemInfo.Text );
    end

    Leave a comment:


  • jackdaniels
    replied
    Not Tested But It Must Be Something Like That

    Code:
    if e_ID > 1000 then
    	runID=e_ID-1000
    	result = File.Run(runID, "", "", SW_SHOWNORMAL, false);
    end

    Leave a comment:


  • jassing
    replied
    Originally posted by GoOgLe View Post
    when i click the menubar it doesnt run the file ???
    Google -- you said nothing about what you wanted to do with the menu once you filled it... I gotta say; I feel like we're doing your work for you....

    Just because you put some words in a menu; it doesn't mean that AMS will know what to do with it. YOu'll need to add code to the page's "Script/ On Menu" section.

    This will enable you to do SOMETHING with it when your user selects a menu item. You will need to evaluate the menu's text (from the menu item ID) and then use File.Run()

    -josh

    Leave a comment:


  • holtgrewe
    replied
    Yeh, it requires string manipulation.

    this is not tested, but this will give you the general idea.


    Code:
    sLength=String.Length(""..yourstring)  -- find the length of your string 
    sStartPos=String.ReverseFind(""..yourstring, "\\", true) -- reverse find the "\"
    shortName  = String.Mid(""..yourstring,  sStartPos +1, sLength)
    Play around with this, you should be able to get it to work for you.

    hth

    Leave a comment:


  • GoOgLe
    replied
    when i click the menubar it doesnt run the file ???

    Leave a comment:


  • jassing
    replied
    Originally posted by GoOgLe View Post
    thanks jassing & holtgrewe

    another question is it possible to hide path of the file ??? just show the name of it...



    example: App.exe

    Absolutely -- have a look at the File.SplitPath() and write a function around it that returns just the file name & extension.

    Leave a comment:


  • GoOgLe
    replied
    thanks jassing & holtgrewe

    another question is it possible to hide path of the file ??? just show the name of it...



    example: App.exe

    Leave a comment:


  • holtgrewe
    replied
    To test for empty table try:

    Code:
    if (tFiles) then
    	-- your code
    else
    	Dialog.Message("No Files!", "") -- or whatever	
    end
    after the File.Find...

    hth
    Last edited by holtgrewe; 03-22-2008, 09:36 AM.

    Leave a comment:


  • GoOgLe
    replied
    thanks jassing

    @jackdaniels
    i would say the same thing;
    perfect code but if no exe in folder u get error

    Leave a comment:


  • jackdaniels
    replied
    jassing thanks alot alot for answering
    but i have one more problem with it... if i the folder doesnt include any exe file i get that error !!!

    Leave a comment:


  • jassing
    replied
    You're lucky, I had to pay for it; but there was wifi at the place I'm at...

    This works for me... hope it does for you.

    Code:
    tblMenu = Application.GetMenu();
    local nNewitem = Table.Count(tblMenu)+1;
    tblMenu[nNewitem] ={};
    tblMenu[nNewitem].Text = "&Available Files";
    tblMenu[nNewitem].ID = 1000;
    tblMenu[nNewitem].Checked = false;
    tblMenu[nNewitem].Enabled = true;
    tblMenu[nNewitem].SubMenu = {};
    
    local tFiles = File.Find( _SystemFolder, "*.exe");
    local x = 0;
    for x = 1,Table.Count(tFiles) do
    	tblMenu[nNewitem].SubMenu[x] = {};
    	tblMenu[nNewitem].SubMenu[x].Text = tFiles[x];
    	tblMenu[nNewitem].SubMenu[x].ID = 1000+x;
    	tblMenu[nNewitem].SubMenu[x].Checked = false;
    	tblMenu[nNewitem].SubMenu[x].Enabled = true;
    end
    
    Application.SetMenu(tblMenu);

    Leave a comment:


  • jassing
    replied
    Originally posted by GoOgLe View Post
    i dont get error but i dont files listed either !!!
    OK - you had said it errored for you; that supprised me; but not getting files; that doesn't -- as I don't fully know how to work with Menu's yet. I'll check it out. be patient; might not be until next week.

    -josh

    Leave a comment:


  • GoOgLe
    replied
    i dont get error but i dont files listed either !!!

    Leave a comment:

Working...
X