IonicWind Software

IWBasic => GUI Central => Topic started by: aurelCB on March 15, 2010, 04:01:56 AM

Title: Test version of ABasic
Post by: aurelCB on March 15, 2010, 04:01:56 AM
Hi all...
I decide to translate ABasic from Creative to Emergence Basic becose i need more speed.
And i must say that works very fast.
I add in attachment testing version that you can see how work.
Work with strings in Ebasic is little bit different then in Cbasic and little bit weird.
I have some problems with compiling EBasic programs ,from time to time i recive this
message:
QuoteCompiling...
AOne4.eba
No Errors

Linking...
Emergence Linker v1.12 Copyright ÂÃ,© 2009 Ionic Wind Software
Generating C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\AOne4.exe
Error: Unable to open output file C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\AOne4.exe
Error(s) in linking C:\Documents and Settings\All Users\Documents\Emergence BASIC\projects\AOne4.exe

I recive this error message after something is wrong and when i fix error i normaly try recompile program again but sometimes i
recive this error and sometimes not. ???
I'm not sure where is problem?
Do i something wrong?
After fixing error i first save file to disk then recompile- is this right way or not?
I use latest version of EBasic 1.737 comunity edition on XP sp2.

all best ...
Aurel
Title: Re: Test version of ABasic
Post by: Copex on March 15, 2010, 04:21:46 AM

if you run and compile a program then try to compile and run the program again you get this error. when you execute a program on windows it locks the process, ensure all processes for the compiles executable are closed before recompiling.
Title: Re: Test version of ABasic
Post by: peterpuk on March 15, 2010, 04:41:54 AM
You might need to start Task Manager by CTRL-ALT-DEL and check if your program is still running as a process. This is usually the cause for me when the compiler cannot create the output file after executing the program.
Title: Re: Test version of ABasic
Post by: Johnny on March 15, 2010, 05:23:26 AM
Happened to me also, once or twice before... :-\
There exist a great tool to see all running processes, and their relationships (which program started which other programs).
It gives much more information than the original task manager.
It's also very easy and fast to stop a "runaway" program with this tool.  :)
http://technet.microsoft.com/nl-nl/sysinternals/bb896653%28en-us%29.aspx (http://technet.microsoft.com/nl-nl/sysinternals/bb896653%28en-us%29.aspx)

Greetings,
Johnny
Title: Re: Test version of ABasic
Post by: Copex on March 16, 2010, 09:18:23 AM
http://processhacker.sourceforge.net/  is a handy alternative.
Title: Re: Test version of ABasic
Post by: WayneA on July 06, 2010, 04:22:46 PM
Cool stuff, I'm glad you've finally decided to move to ebasic for this project. The old aurelbasic was a little slow for my tastes ;)

Looking good!
Title: Re: Test version of ABasic
Post by: sapero on September 08, 2010, 03:04:36 PM
This is my idea for you:enum VARIABLE_TYPE
VARTYPE_CHAR
VARTYPE_WORD
VARTYPE_INT
...
VARTYPE_ARRAY  = 0x40000000
VARTYPE_SIGNED = 0x80000000
endenum

type variable
VARIABLE_TYPE VariableType ' char/word/int/...
int ElementSize ' 4 for integers...
int NumberOfElements ' 1 for just an integer or int[1], 2 for int[2]...

' optional union for variable value.
union
' signed nonarray
schar cValue
sword wValue
int iValue
int64 i64Value
' todo: float, double, real80 ...
' unsigned nonarray
char ucValue
word uwValue
uint uValue
uint64 ui64Value
' other
pointer pValue ' string/wstring/arrays
endunion
' todo: other fields
istring name[1]
endtype

pointer new_variable = new(char, len(variable) + len(variable_name))
settype new_variable, variable
...
Title: Re: Test version of ABasic
Post by: LarryMc on September 08, 2010, 03:07:55 PM
I was typing this while Sapero was posting his response ;)

Just off the top of my head without giving it much thought.

If you are keeping all your variables in a linked list then why can't you have your linked list have an element that stores a pointer to another linked list for each variable that is an array.

That way you could add an upperbound function for relays and also do REDIM.
I just don't know how fast it would be and how well it would fit in with your other code.

With that setup you could have
Dim d[10] as int
....
x=43
redim d[x]
....

for y=0 to ubound(d)
  ....
next y


LarryMc
Title: Re: Test version of ABasic
Post by: LarryMc on September 09, 2010, 06:54:00 AM

Aurel
I just addressed INT and not strings.
Strings really would just duplicate INT as you have already done.
This should be enough to give you a better idea of what
I was thinking based upon what you have already done.
No promise it will work for you.
my code is not 100% complete
You would have to add a little code to make it work
Hope this helps
LarryMc


'define LList which hold Variable Type ----------------------------------------------------------
TYPE VariableType
   STRING varname
   INT    vartype /* vartype 1 is number
vartype 2 is string
vartype 3 is number array
vartype 4 is string array */
ENDTYPE
' create VARTYPE LIST
VarTypeList=ListCreate()
POINTER typeVar
SETTYPE typeVar,VariableType

'DEfine Linked List for INT variable (i call them INT but infact hold floats-----
TYPE intType
   STRING intName
   FLOAT   intValue
pointer intArray
ENDTYPE
TYPE intTypeArray
   int intNdex
   FLOAT   intValue
ENDTYPE
' create INT LIST
intList=ListCreate()
POINTER intVar
SETTYPE intVar,intType


SUB defineINT  :' DEFNUM a[15] b c d
'check error-----------------------------------------------------------------
STRING sign1
IF GW2="" | GW2=" "
errortype="Error:No parametars after DEFNUM!"
showerror()
error=1:RETURN
ENDIF
sign1 = LEFT$(GW2,1)
IF INSTR("!#$%&/()=?*+,;:\|<>{}~^", sign1)<> 0
errortype="Error:Syntax Error!"
showerror()
error=1:RETURN
ENDIF
'----------------------------------------------------------------------------
'maximum defined varibles per line is 16
IF GW2<>"" :' GW2 is first string after DEFNUM which have variable name
intVar=ListAdd(intList,NEW(intType,1))
#intvar.intArray=NULL
'check for array
pos = instr(GW2,"[")
if pos 'have an array
'get size
pos2 = instr(GW2,"]")
if pos2 = 0
'add error code here
endif
asize$=mid$(GW2,pos+1)
asize$=left$(asize$,instr(asize$,"]")-1)
' create INT Array LIST
#intvar.intArray= ListCreate( )
for x=0 to val(asize$)-1
intVarArray=ListAdd(#intvar.intArray,NEW(intTypeArray,1))
#intVarArray.intNdex=x
#intVarArray.intValue=0
next x
GW2=left$(GW2,pos-1)
endif
#intVar.intName=GW2
#intvar.intValue=0   ' <---this will not be used for arrays
'-------------------------------------
typeVar=ListAdd(VarTypeList,NEW(VariableType,1))
#typeVar.varname=GW2
#typeVar.vartype=1  :'currently vartype 1 is number,vartype 2 is string
ENDIF

'When retrieving values have to see if array
'if not array retrieve value from #intvar.intValue
'if is array retrieve value from intVar.intArray.intValue, looping until you find index match.

'UBOUND function would simply be a "FINDLAST of the array list and then get index
'REDIM would simply be FINDLAST to get last index and then add entries until new max is reached.
'if REDIM is smaller than current then loop until find current index that matches new max and delete all after that from list
Title: Re: Test version of ABasic
Post by: LarryMc on September 09, 2010, 11:00:35 AM
Aurel

I set it up for zero based indexing of arrays the way IWB and CB are.
It would be very easy for you to make it 1 based indexing for the arrays.

LarryMc
Title: Re: Test version of ABasic
Post by: aurelCB on September 09, 2010, 11:21:31 AM
QuoteI set it up for zero based indexing of arrays the way IWB and CB are.
It would be very easy for you to make it 1 based indexing for the arrays.

Not problem at all...
Im very used to zero based indexing... ;)
Title: Re: Test version of ABasic
Post by: LarryMc on September 11, 2010, 05:43:21 AM
Try this

#<intTypeArray>intVarArray.intNdex = x
#<intTypeArray>intVarArray.intValue = 0


LarryMc
Title: Re: Test version of ABasic
Post by: aurelCB on September 11, 2010, 03:21:34 PM
OK.
It seems that now works...
Thanks... ;)

Aurel
Title: Re: Test version of ABasic
Post by: LarryMc on September 12, 2010, 08:50:05 PM
Aurel

The way you have it implemented(like a UDT), how do you address elements in a loop like:

DEFNUM a[5]

for x =0 to 4
  a[x]=x     <-------------????????
next x


LarryMc
Title: Re: Test version of ABasic
Post by: LarryMc on September 13, 2010, 05:48:52 AM
aurel

Isn't the code above that uses NEW your internal code?

I'm talking about how a user of AurelBasic will use a loop to set/read an array element.

LarryMc
Title: Re: Test version of ABasic
Post by: WayneA on September 29, 2010, 12:15:04 PM
Hey Aurel,

Here are my string parsing functions:
Sub Split(source As String,delimiter As String,count As Int ByRef),UInt
Dim delpos=0,nexpos,dellen=Len(delimiter),i=0 As Int
Dim array As Pointer
count=FieldCount(source,delimiter)
array=New(String,count)
nexpos=InStr(source,delimiter)
If array Then
While nexpos
If i=0 Then delpos=1-dellen
*<String>array[i,0]=Left$(Mid$(source,delpos+dellen,nexpos-delpos-dellen),254)
delpos=nexpos
nexpos=InStr(source,delimiter,delpos+dellen)
i++
Wend
*<String>array[i,0]=Mid$(source,delpos+dellen)
EndIf
Return array
EndSub

Sub NthField(source As String,delimiter As String,fieldnumber As Int),String
Dim delpos,nexpos,dellen=Len(delimiter),count As Int
count=1
delpos=0
nexpos=InStr(source,delimiter)
While nexpos
If count=fieldnumber Then
If count=1 Then delpos=1-dellen
Return Mid$(source,delpos+dellen,nexpos-delpos-dellen)
Else
delpos=nexpos
nexpos=InStr(source,delimiter,delpos+1)
count++
EndIf
Wend
Return Mid$(source,delpos+dellen)
EndSub

Sub FieldCount(source As String,delimiter As String),Int
Dim delpos,nexpos,count As Int
count=0
delpos=0
nexpos=InStr(source,delimiter)
While nexpos
delpos=nexpos
nexpos=InStr(source,delimiter,delpos+1)
count++
Wend
Return count+1
EndSub


Split will be most of use in this instance. Read the entire file into a buffer then pass it to Split. The returned pointer will be a dynamic string array created with New. To reference members use the following syntax:
*<String>lines[i,0]
That ,0 needs to be there so that you don't reference individual characters.

To split on lines the delimiter needs to be "\n".

NthField works in a similar way, however if you will be randomly accessing individual lines Split is much faster. Just remember to free the memory with Delete!

*Edit, corrected Split. It didn't check the return of New for null ptr.
Title: Re: Test version of ABasic
Post by: jerryclement on August 15, 2011, 05:39:44 PM
 ;D   8)  Auriel!

JerryC
Title: Re: Test version of ABasic
Post by: billhsln on April 08, 2013, 11:05:54 AM
I don't know that I could follow what you are doing, but I would be interested in seeing if I could learn from your code.

Thanks,
Bill H.
Title: Re: Test version of ABasic
Post by: GWS on April 08, 2013, 12:54:12 PM
Hi Aurel,

You've put such a lot of work into your project .. much credit to you in getting it working to your satisfaction.  Well done.

best wishes, :)

Graham
Title: Re: Test version of ABasic
Post by: Doc on April 08, 2013, 01:42:03 PM
Quote from: aurelCB on April 08, 2013, 10:25:36 AM
Is anyone maybe interested for source code...? 

Aurel,
I don't have any funding to purchase any source code and really don't particularly need it either, but I would really like to see what you've done "under the hood".  I've never really taken the time to understand the process of building an interpreter, but t sure sound like good info to know. :)

-Doc-