April 25, 2024, 05:23:19 AM

News:

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


Test version of ABasic

Started by aurelCB, March 15, 2010, 04:01:56 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aurelCB

March 15, 2010, 04:01:56 AM Last Edit: April 24, 2014, 11:36:25 PM by aurelCB
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

Copex


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.
-
I really should learn how to use a spell checker! though im not sure how it will help someone who can not spell?
-
Except where otherwise noted, content Posted By Copex is
licensed under a Creative Commons Attribution 3.0 License

http://creativecommons.org/licenses/by/3.0/

peterpuk

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.
Peter

Johnny

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

Greetings,
Johnny

Copex

-
I really should learn how to use a spell checker! though im not sure how it will help someone who can not spell?
-
Except where otherwise noted, content Posted By Copex is
licensed under a Creative Commons Attribution 3.0 License

http://creativecommons.org/licenses/by/3.0/

WayneA

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!
99 little bugs in the code,
99 bugs in the code,
Fix one bug,
Compile again,
104 little bugs in the code...

All code I post is in the public domain.

sapero

September 08, 2010, 03:04:36 PM #6 Last Edit: September 08, 2010, 03:09:20 PM by sapero
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
...

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc


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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

aurelCB

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... ;)

LarryMc

Try this

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


LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

aurelCB

OK.
It seems that now works...
Thanks... ;)

Aurel

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

WayneA

September 29, 2010, 12:15:04 PM #15 Last Edit: September 29, 2010, 02:06:45 PM by WayneA
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.
99 little bugs in the code,
99 bugs in the code,
Fix one bug,
Compile again,
104 little bugs in the code...

All code I post is in the public domain.

jerryclement

Jerry - Newbie from TN

billhsln

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.
When all else fails, get a bigger hammer.

GWS

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
Tomorrow may be too late ..

Doc

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-