Page 1 of 1 1
Topic Options
#214214 - 2023-04-18 09:16 PM Running a script from memory?
jassing Offline
Just in Town

Registered: 2023-04-18
Posts: 3
Loc: Washington State, USA
is it possible to run a script from memory? The documentation seems to only reference loading a script from a file. (possible I missed something)
Top
#214215 - 2023-04-19 02:03 AM Re: Running a script from memory? [Re: jassing]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
I don't think so. Maybe describe what you are trying to do, or give an example in another language that can do it.
Top
#214216 - 2023-04-20 10:36 AM Re: Running a script from memory? [Re: jassing]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
It needs to be put in memory first. A script as a function will be loaded in memory when started from a file and can then be called upon by other code in that same session. As far as I always understood and used things a function is loaded into memory and will be executed from there when it is used by other code.

Edited by Mart (2023-04-20 10:58 AM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#214217 - 2023-04-20 11:43 PM Re: Running a script from memory? [Re: Allen]
jassing Offline
Just in Town

Registered: 2023-04-18
Posts: 3
Loc: Washington State, USA
 Originally Posted By: Allen
I don't think so. Maybe describe what you are trying to do, or give an example in another language that can do it.


Lua let's you load a script from memory (not a file) so you can dynamically create the script in your program, then load into Lua & run it. It never needs to land in a file to be read...
The stuff I read seems to indicate that you have to write a file 1st, then load it.

Top
#214218 - 2023-04-21 02:28 AM (NA) Re: Running a script from memory? [Re: jassing]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
It needs to get into "memory" from somewhere. Something that I do is run a script (from a file) that then uses my URL function to get code from a web server. That code sits in an in-memory string that I can then run via the Kix Execute command. Likewise, I can load INI data from a web server without ever having to save the INI data to a file.

This allows me to have a single "script" on an endpoint, which is tokenized, and then dynamically request another script to execute. The actions of the script can change based on the environment and task required. Each script can request web-config content as well. Here's a simple concept:
 Code:
$aResponse = Url('Some.web.site/file.kix', 'GET')  ; get the script
$Script = $aResponse[0]  ; this is the script as a string from the BODY element
$aResponse = Url('Some.web.site/file.ini', 'GET')  ; get the INI file
$aIni = Split($aResponse[0], @CRLF)  ; INI data as an array of lines from the BODY element
Global $aINIDATA ; global so it can be available in the Execute function
$aINIDATA = IniArray($aIni) ; Create an in-memory representation of the INI file
$Value = ReadIniArray($aINIDATA, 'SECTION_NAME', 'Value Name')  ; works just like ReadProfileString!
Execute($Script)
Of course, there should be some error checking involved from the URL call. @ERROR is set, as well as $Response[2] being the HTTP response code.

If you search for "SIT" - the System Interrogation Tool we collectively wrote some 15 years ago, it dynamically loads and initializes code modules that add capabilities to a core app. You can deploy the main app and two modules for limited functionality or add modules at-will to change or expand the functionality of the core application. Each module had a set of functions and a few variable declarations. Those variables defined the entry points and capabilities of the module. Every module worked the same way, so different people could write different modules. This might provide some additional ideas.

I'm a bit familiar with LUA, but don't know the context you're referencing. Can you refer to a document page?
_________________________
Actually I am a Rocket Scientist! \:D

Top
#214262 - 2023-07-18 03:36 PM Re: (NA) Re: Running a script from memory? [Re: Glenn Barnas]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
 Originally Posted By: Glenn Barnas

If you search for "SIT" - the System Interrogation Tool we collectively wrote some 15 years ago, it dynamically loads and initializes code modules that add capabilities to a core app. You can deploy the main app and two modules for limited functionality or add modules at-will to change or expand the functionality of the core application. Each module had a set of functions and a few variable declarations.


Not sure how far you've updated the program Glenn, but here was one of the last updates I had.


Readme last updated: 10:00 AM 2/3/2004

SIT - System Inquisition Tool (AKA Spanish Inquisition tool)
SMIT - System Management & Inquisition Tool
Interrogates a specific Windows system
Uses KiXtart scripts and the KixForms GUI snap-in DLL

Developed and written by Glenn Barnas

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 466 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.039 seconds in which 0.016 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org