[Gambas-user] Scripter some Updates

Brian G brian at westwoodsvcs.com
Sun Mar 21 05:14:10 CET 2021


Added --convert-script which will create a project from a script 
gbs3 --convert-script <script name> [<Directory to create project in>] 
if project directory is not provided it will be created in the env["PWD"] directory 

Updated 'Use' to allow evaluated expressions as library and component names 
Use User.home &/ "MyLibs" , ... ' is now correctly evaluated 

If a project directory path is provided in place of a script name scripted will execute the project like a script 

Added -p --pluggin which will create a loadable component with a file name of the script.gambas and a class of the same name 
with public sub _Call(...) instead of Public Sub Main() 

It can be used like this 
gbs3 -p <Script name> [<Output Plugin directory>] 
the output directory is optional, if not provided the plugin will be put into User.home &/ ".local/lib/gamabas3/pluggin 
for the cached executable and linked back to the plugin directory. 

The Plugin script looks like this: 

TestPlugin.gbs_________________________________________ 
#!/usr/bin/env gbs3 
'Auto Generated Script 03/09/2021 17:23:23.708 Version (0.0.0) 
#Script Version="1.0.1" 
' Gambas module file 
Dim s As String = "sdfdfsdfdfssdfdsf" 
Dim i As Variant = s 
testptr(i) 
for each s as string in param 
testptr(s) 
next 
Public Sub testptr(data As Variant) 
Dim j As Pointer 
j = VarPtr(data) 
Print "Input =", j, data 
End 
Public Sub _new() 
print "defined" 
end 
_______________________________________________________________________ 
The Calling script or section of your app code looks like this 
_______________________________________________________________________ 

#!/usr/bin/gbs3 
' Gambas Script File Created 03/21/2021 01:47:18.491 

exec ["gbs3","-p",user.home &/ "Scripts/TestPlugin.gbs"] wait 
component.load(user.home &/ ".local/lib/gambas3/TestPlugin.gambas") 
dim cClass as Class = class.load("TestPlugin") 
dim xx as object = cClass.new() 

xx("asadd","adadssad","rrrrrr") 

QUIT 0 
catch 
Print error.text&"\n" & error.where 


"Failure is the key to success; 
each mistake teaches us something" .. Morihei Ueshiba 
Brian G 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210320/676310f7/attachment.htm>


More information about the User mailing list