Jump to content

read FUNC from a file and excute them as FUNC ?!


Recommended Posts

hey guys i was wandering how can i read a func from a file and make my program execute it> AS IS !!!

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

DSo you really mean a function? Then:

#include <filename.au3>

_call_the_finction()

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Hi,

if you need read the whole function from other file (witch is not au3 file), and call it, you can't, but if you need to read just the name of function, and call it (the function is defined in your script), then you can try like this:

$FuncNameRead = FileReadLine("Test.txt", 1)

Call($FuncNameRead)

Func MyFunc()
   MsgBox(0, "", $FuncNameRead)
EndFunc

In this case the first line of file Test.txt must include this: MyFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

if you need read the whole function from other file (witch is not au3 file), and call it, you can't

I am totaly wrong, sorry, you definitly can....

as DaleHohm seguest, you can read the function even from text file:

#include <test.txt>

Test()

And the file test.txt will include this:

Func Test()

MsgBox(0, "", "")

EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

You cannot dynamically load a function at runtime. You can execute another script, but you cannot load a function from a file into the executing space.

I guess the Microsoft Script Control Object made for running dynamic code cannot do this? :) I think it can.
Link to comment
Share on other sites

I am totaly wrong, sorry, you definitly can....

as DaleHohm seguest, you can read the function even from text file:

#include <test.txt>

Test()

And the file test.txt will include this:

Func Test()

MsgBox(0, "", "")

EndFunc

BUT 'test.txt' will be INCLUDED in the script so after compilation it isn't posible to let your program run an other function by editing test.txt

so you can not run a function from a txt file dynamicly. so i think your previous post is the best one to do this.

Edited by Pakku
Link to comment
Share on other sites

BUT 'test.txt' will be INCLUDED in the script so after compilation it isn't posible to let your program run an other function by editing test.txt

so you can not run a function from a txt file dynamicly. so i think your previous post is the best one to do this.

Arjan

if you include the .txt in a zipped folder after the compilations this might work..

Link to comment
Share on other sites

if you include the .txt in a zipped folder after the compilations this might work..

Well it takes the content of the include file (open it with notepad or something) and adds that to de place where you have the line #include<file.zip> so after compilation you can edit the zip file but it has no effect

EDIT: and if this was possible, it would be VERY VERY dangeraus!

Edited by Pakku
Link to comment
Share on other sites

This is from randallac's quick sort

Func _Quick_SortColumn(ByRef $ar_Array, $First, $Last, $i_ViewColNum = 1)
    If (Not IsArray($ar_Array)) Or $i_ViewColNum > UBound($ar_Array) Or $i_ViewColNum < 1 Then
        SetError(1)
        Return ""
    EndIf
    If UBound($ar_Array) = 1 Then; If the array is only 1 element in size then we can't delete the 1 element.
        SetError(2)
        Return ""
    EndIf
    Local $vbs, $code = "function Quick_SortColumn1(ByRef SortArray, First, Last,i_ViewColNum)"
    $code &= @LF & "    dim strWrite,ar_Col,ar_Column()"
    $code &= @LF & "    ReDim Preserve ar_Column(ubound(SortArray))"
    $code &= @LF & "    Dim intPointer, booIsNumeric: booIsNumeric = True"
    $code &= @LF & "    For intPointer = First To Last"
    $code &= @LF & '        ar_Col = Split( SortArray(intPointer), "|", -1,0 )'
    $code &= @LF & "        If Not IsNumeric( ar_Col(i_ViewColNum) ) Then"
    $code &= @LF & "            booIsNumeric = False"
    $code &= @LF & "            Exit For"
    $code &= @LF & "        End If"
    $code &= @LF & "    Next"
    $code &= @LF & "    For intPointer = First To Last"
    $code &= @LF & '        ar_Col = Split( SortArray(intPointer), "|", -1,0 )'
    $code &= @LF & '            If booIsNumeric Then'
    $code &= @LF & "            ar_Column(intPointer)  = CSng( ar_Col(i_ViewColNum) )"
    $code &= @LF & "        else"
    $code &= @LF & "            ar_Column(intPointer)  =  ar_Col(i_ViewColNum)"
    $code &= @LF & "        End If"
    $code &= @LF & "    Next"
    $code &= @LF & "    Quick_SortColumn  SortArray, ar_Column,First, Last,i_ViewColNum "
    $code &= @LF & "    Quick_SortColumn1= SortArray"
    $code &= @LF & "End function   "
    $code &= @LF & "function Quick_SortColumn(ByRef SortArray, ByRef ar_Column, First, Last,i_ViewColNum)"
    $code &= @LF & "    dim Low,High,collitem,ar_Col"
    $code &= @LF & "    dim Temp,List_Separator"
    $code &= @LF & "    Low = First"
    $code &= @LF & "    High = Last"
    $code &= @LF & "    List_Separator=ar_Column((First + Last) / 2)"
    $code &= @LF & "    Do"
    $code &= @LF & "        While (ar_Column(Low) < List_Separator)"
    $code &= @LF & "            Low = Low + 1"
    $code &= @LF & "        WEnd"
    $code &= @LF & "        While (ar_Column(High) > List_Separator)"
    $code &= @LF & "            High = High - 1"
    $code &= @LF & "        WEnd"
    $code &= @LF & "        If (Low <= High) Then"
    $code &= @LF & "            Temp = SortArray(Low)"
    $code &= @LF & "            SortArray(Low) = SortArray(High)"
    $code &= @LF & "            SortArray(High) = Temp"
    $code &= @LF & "            Temp = ar_Column(Low)"
    $code &= @LF & "            ar_Column(Low) = ar_Column(High)"
    $code &= @LF & "            ar_Column(High) = Temp"
    $code &= @LF & "            Low = Low + 1"
    $code &= @LF & "            High = High - 1"
    $code &= @LF & "        End If"
    $code &= @LF & "    Loop While (Low <= High)"
    $code &= @LF & "    If (First < High) Then Quick_SortColumn  SortArray, ar_Column,First, High,i_ViewColNum "
    $code &= @LF & "    If (Low < Last) Then Quick_SortColumn  SortArray, ar_Column,Low, Last,i_ViewColNum "
    $code &= @LF & "End function   "
    $vbs = ObjCreate("ScriptControl")
    If @error Then ;Return 0; SetError(Hex(@error, 8));EndIf
        SetError(3)
        Return ""
    EndIf
    $vbs.language = "vbscript"
    $vbs.addcode ($code)
    $ar_Array = $vbs.Run("Quick_SortColumn1", $ar_Array, $First, $Last, $i_ViewColNum - 1)
    If @error Then ;Return 0; SetError(Hex(@error, 8));EndIf
        SetError(4)
        Return ""
    EndIf
    $vbs = ""
    SetError(0)
    Return 1
EndFunc   ;==>_Quick_SortColumn

as you can see you can add code to the vbs, so you probably could have the vbs code in a file read it in and addcode and run

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...