May 05, 2024, 08:29:29 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Translate Ibasic Pro to Aurora

Started by Wijnand, January 10, 2006, 07:37:52 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Wijnand

I'm trying to learn the Aurora language and I need a little bit of help to get going. I'm trying to port a dll from Ibasic to Aurora but I can't get it going.
The Ibasic code is this:
' DEFINITIONS OF STANDARD STRINGS AND INTERGER
' USED BY PLUGIN
Global ReturnString
Def ReturnString as STRING
Global g_hwndParent
Def g_hwndParent as STRING
Global newp
Def newp as STRING
Global g_sAppDir
Def g_sAppDir as string
Global g_sScriptString
Def g_sScriptString as string
Global g_nScriptInt
Def g_nScriptInt as int
Global g_theForm
Def g_theForm as string
CONST DLL_PROCESS_ATTACH = 1
CONST DLL_PROCESS_DETACH = 0
CONST DLL_THREAD_ATTACH = 2
CONST DLL_THREAD_DETACH = 3
Global w1
DEF w1 as WINDOW
'*************************************************************************
' EXPORT SECTIONÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, ***
'*************************************************************************
'*** Export section: Functions mentioned here will be available to MMB ***
'*** If you add functions do not forget to add them here alsoÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ***
'*************************************************************************
'--- MMB inferface functions DO NOT DELETE THESE!! ---
export Copyright
export GetShortInfo
export GetInfo
export GetType
export SetFile
export GetFile
export SetData
export GetInt
EXPORT DllMain
export Show
'export Hide
'*************************************************************************
'---- Export section for your own functions ----
export MultiFileOpen
export FileOpen
export FileSave

'*************************************************************************
'*** DECLARATION OF FUNCTIONSÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ***
'*************************************************************************
' Declaration of functions: Functions need to be delcared in order toÂÃ,  ***
' work properly.ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, ***
'*************************************************************************
'--- MMB interface funtions DO NOT DELETE THESE!! ---
declare cdecl Copyright(), string
declare cdecl GetShortInfo(),string
declare cdecl GetInfo(),string
declare cdecl GetType(),int
declare cdecl SetFile(s as string),string
declare cdecl GetFile(s as string),string
declare cdecl SetData(i as int),int
declare cdecl GetInt(i as int),string
declare cdecl DllMain(hModule AS INT,reason AS INT,lpReserved AS INT),INT
declare cdecl Show(), string
'declare cdecl Hide(), string
'
'*************************************************************************
'
'--- Declare here your own functions ---
declare cdecl MultiFileOpen(filename as string), string
declare cdecl FileOpen(filename as string), string
declare cdecl FileSave(filename as string), string

'*************************************************************************
' ACTUAL FUNCTIONS GO HEREÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, ***
'*************************************************************************
'--- MMB Interface functions DO NO DELETE THESE!! ---
'--- DllMain: This function is used to properly interface with MMB ---
SUB DllMain(hModule AS INT,reason AS INT,lpReserved AS INT),INT
ÂÃ,  ÂÃ, SELECT reason
ÂÃ,  ÂÃ,  ÂÃ,  case DLL_PROCESS_ATTACH
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, hInstance = hModule
ÂÃ,  ÂÃ,  ÂÃ,  case DLL_THREAD_ATTACH
ÂÃ,  ÂÃ,  ÂÃ,  case& DLL_THREAD_DETACH
ÂÃ,  ÂÃ,  ÂÃ,  case& DLL_PROCESS_DETACH
ÂÃ,  ÂÃ, ENDSELECT
ÂÃ,  ÂÃ, RETURN TRUE
ENDSUB

'--- Copyright: Here you can place copyright information
sub Copyright(), string
ReturnString="Copyright (c) 2005 W.M. Medendorp"
Return ReturnString
endsub

'--- GetShortInfo: Short description of your plugin
sub GetShortInfo(), string
ReturnString="MMB PlugIn SDK for IBasic Pro"
Return ReturnString
endsub

'--- GetInfo: Short description of your plugin
sub GetInfo(), string
ReturnString="MMB PlugIn SDK for IBasic Pro"
Return ReturnString
endsub

'--- GetType: Leave this always at 0
sub GetType(),int
Return 0
endsub

'--- SetFile: Used by function "PluginSet("PlugIn","string$)
sub SetFile(s as string), string
g_sScriptString = s
Return g_sScriptString
endsub

'--- GetFile: Used by function "PluginGet("PlugIn","string$)
sub GetFile(s as string), string
Return g_sScriptString
endsub

'--- SetData: Used by function "PluginSet("PlugIn","integer)
sub SetData(i as int),int
g_nScriptInt = i
Return g_nScriptInt
endsub

'--- GetInt: Used to retrieve interger value as string: SEE DEMO
'--- FOR MORE INFORMATION!!
sub GetInt(i as int),string
ÂÃ,  ÂÃ,  g_sScriptString = STR$(g_nScriptInt)
Return g_sScriptString
endsub

'--- Show PlugIn
sub Show(), string
REM define a window variable
REM open the window
OPENWINDOW w1,0,0,350,350,@MINBOX|@MAXBOX|@SIZE,NULL,"Simple Window",&main
REM print a message
PRINT w1,"Hello World"
REM when w1 = 0 the window has been closed
WAITUNTIL w1 = 0
END
Return
endsub

'---
REM every time there is a message for our window
REM the operating system will GOSUB here
SUB main
ÂÃ,  ÂÃ,  IF @MESSAGE = @IDCLOSEWINDOW
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  REM closes the window and sets w1 = 0
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  CLOSEWINDOW w1
ÂÃ,  ÂÃ,  ENDIF
RETURN
ENDSUB





'*** PLACE YOUR OWN FUNCTIONS HERE ****
'--- Dialog to open multiple files
sub MultiFileOpen(filename as string), string
DEF filenames[10000]:ISTRING
DEF filter,filetemp:STRING
DEF pos:int
filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt||"
filenames = filerequest("Select Multiple Files",0,1,filter,"txt",@MULTISELECT)
pos=len(filenames)
Temp$=left$(filenames,pos-1)
g_sScriptString = Temp$
Return g_sScriptString
endsub

'--- Dialog to open single file
sub FileOpen(filename as string), string
DEF filenames[10000]:ISTRING
DEF filter,filetemp:STRING
DEF pos:int
filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt||"
filenames = filerequest("Select File",0,1,filter,"txt")
g_sScriptString = filenames
Return g_sScriptString
endsub

'--- Dialog save file
sub FileSave(filename as string), string
DEF filenames[10000]:ISTRING
DEF filter,filetemp:STRING
DEF pos:int
filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt||"
filenames = filerequest("Save File",0,0,filter,"txt")
g_sScriptString = filenames
Return g_sScriptString
endsub


If anyone can get me going that would be great and much appreciated.

Greetz,

Wijnand

Zen

Are there any parts in particular you dont understand?

Lewis

Parker

The window part will take a little conversion, since it's implemented differently in Aurora, but other than that, just add semicolons to the end of lines (statements), and add braces {} to the compound statements, like SUB, SELECT, IF, etc. The ENDSUB, ENDSELECT, etc as a result aren't needed.

Wijnand

The difficult parts for me are:
- the export of the functions to be accesible by other programs
- the proper declarations of functions

It would be nice if I can get an example for the things mentioned above. I can then work further from there.
I just need a little push in the right way.

Thanks in advance,

Wijnand

Zen

I can give you some help. I have not yet delved in very deep into the GUI side yet. Things like function declarations are not too difficult.

In IBasic you would have something like...


SUB FunctionName(Arg1 as STRING,Arg2 as UINT),INT

......

RETURN TRUE

ENDSUB


This would convert to this in Aurora...

sub FunctionName(string Arg1,unsigned int Arg2),int {

....

return true;

}


IBasics ISTRING type in aurora is a dstring. declared the same though. dstring mystring[1000];

In the DLL's you do not need a DLLMain function as this is all hidden and created when the DLL is compiled. As for exports im not too sure but i think it would ust be the export keyword followed by the name of the function you wish to export.

Like parker said, for the GUI side of things it is a little different as Aurora uses OOP as compared to IBasic which uses procdural code. The best thing i could recomend for the GUI is study the examples. Thats is what i will be doing once i finish some more of the common classes.

If there is anything else you are stuck with just let us know.

Lewis

LarryMc

Lewis

Quotesub FunctionName(string Arg1,unsigned int Arg2),int {

....

return true;

}
Don't you toss the 'sub' also?
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Parker

Only when it's a class method.
sub MyFunction()
{

}
...
MyClass::MyFunction
{

}