All Basic
September 08, 2010, 06:34:47 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome to the AllBasic.INFO forum!
 
   Home   Help Search Login Register  
Pages: [1] 2 3 ... 7
 1 
 on: Today at 04:20:21 PM 
Started by E.K.Virtanen - Last post by Steve A.
Parsing the statements is not the problem. Problem is to track them down from statements() and keeping track also about the line number where statement exists, unless you use lot's of ram by using huge arrays.

Yes, I agree and understand.
"If a compound statement has 3 statements in it, which one caused the error ?"

Ram usage, (IMHO),  should not be your major concern. Today, ram is cheap.
Whether 3 or 4 statements are formed on a single line, or, if they take 3 or 4 separate lines is of no consequence.
It still takes the same amount of ram to store the statements.

Quote
Mystiks idea is neat, i have tested it, it works but im wondering way to make it with less ram usage.

During parsing, each statement has to be tokenized and stored in an array, linked list or structure of some type.
If one element (integer) refers to which statement number and one element (integer) refers to what line number, that's all you need.
Not a huge waste of ram.

Quote
Aye, i agree. However i cant decide how the rest of the world thinks so i ratherly allow multiple statements per line.

I'm affraid you will never be able to please the rest of the world.
That's why there are so many different programming languages, let alone dialects.
Even languages developed at major universities have failed because they couldn't attract an audience.

It seems that unless a language has the word "Visual" in front of it, it doesn't get a lot of respect from serious programmers or institutions.
If you don't believe me, just Google: "programming jobs".

 2 
 on: Today at 01:50:27 PM 
Started by E.K.Virtanen - Last post by admin
SMF supports RSS feeds.

http://www.simplemachines.org/community/index.php?topic=25009.0

The forum also supports sending notifications to your e-mail address you used to register if you want. With each notification e-mail you have the option to terminate further notifications.

We are trying to build a Basic community here and contributing to the forum is encouraged. RSS tends to turn potential resources into lurkers.


 3 
 on: Today at 01:29:42 PM 
Started by E.K.Virtanen - Last post by Aurel
It is not too tuff like you mean EK... Wink
Just little bit of clear thinking.
Thanks Rick,yes that would be a problem..hmmm.

EK..
Not in Creative Basic then in EBasic compiler.
I define variable on this way:
first crete globaly viwed list:
Code:
' create VARTYPE LIST
VarTypeList=ListCreate()
POINTER typeVar
SETTYPE typeVar,VariableType
'typeVar=ListAdd(VarTypeList,NEW(VariableType,1))

'DEfine Linked List for INT variable --------------------------------------------
TYPE intType
   STRING intName
   FLOAT   intValue
ENDTYPE
' create INT LIST
intList=ListCreate()
POINTER intVar
SETTYPE intVar,intType

then define variable or add varible into empty list:
Code:
intVar=ListAdd(intList,NEW(intType,1))
#intVar.intName=GW2  ' GW2 is veriable name
#intvar.intValue=0       'this is variable value set to null
'-------------------------------------
        'next list hold variable name and variable type
typeVar=ListAdd(VarTypeList,NEW(VariableType,1))
#typeVar.varname=GW2
#typeVar.vartype=1

So if i need do this on way which i tell ,i probably must
add vitual internal names of array variables elements...?
if i have a[4]
then i must internaly generate 4 new varible names with values isn't?
 


 4 
 on: Today at 01:16:19 PM 
Started by E.K.Virtanen - Last post by E.K.Virtanen
Thanks rdc. I own you another one more, and that makes like...err...pretty many one mores...  Grin

 5 
 on: Today at 01:04:32 PM 
Started by E.K.Virtanen - Last post by rdc
Here is Steve's program converted to FreeBasic.

Code:

/' title: arraytst.c
      by: sarbayo, (c) 2001
    Desc: Dynamic Multi-Dimensional arrays.
          This example illustrates how to dynamically create and access,
          store to and retrieve from, multi-dimensional arrays,
          such as these Basic statements:
            <snip>
            DIM an_array(3,3,3)
            an_array(a,b,c) = value
            value = an_array(a,b,c)
            PRINT value
            <snip>

See comments.
'/

#define MAX_VARS 100
#define VAR_NAME 33
#Define NULL 0

Type array_integer
   iv_array As Integer Ptr
   in_array As String
End Type

Dim Shared iarray As array_integer

Sub IntArray()             '/* --- integer array --- */
                           '/* Basic statement: DIM an_array(3,3,3) */
   Dim As integer L = 3, W = 3, D = 3 '/* Length, Width, Depth.   */
                   '/* Note: L,W,D have to be stored somewhere for as long    */
                   '/* as this array is in use. Perhaps within the structure. */
                   '/* array's linear size: 3x3x3 = 27  */
   
   Dim As Integer size = L * W * D
   Dim As Integer ii, x
   Dim As Integer a = L, b = W, c = D
   
   iarray.in_array = "integer"    '/* give this array a name */

                 '/* now allocate memory for the array to hold 27 integers,*/
                 '/* where:  iarray. = structure, iv_array = integer array */

   iarray.iv_array = Callocate(size, sizeof(Integer))
   If iarray.iv_array = NULL Then
      Print "Could not allocate array."
      Exit Sub
   EndIf
                 '/* now fill the array with some data, (for simplicity),  */
                 '/* using the "linear" fashion: array[0]...[26]           */

   For ii = 0 To size - 1
      iarray.iv_array[ii] = (c*ii)
   Next

                 '/* Display array contents: */
   For ii = 0 To size - 1
      Print iarray.in_array & "(" & ii &") = " & iarray.iv_array[ii]
   Next
                '/* Basic statement: x = an_array(1,1,1)
                                       ' or (a,b,c),

                '/* here a 'C' routine would interpret the above Basic   */
                '/* statement and make the assignments to a,b,c.         */

   a = 1      '/* 0 to 2 */
   b = 1      '/* feel free to change the values of: */
   c = 1      '/* a,b,c to see the results. */

               '/* the algorithm to calculate 3-Dimensional array offset */

   
   x = iarray.iv_array[c+D*(b+W*a)]                  '/* that's it !!! */
   
   Print
   Print "Index a = " ; a
   Print "Index b = " ; b
   Print "Index c = " ; c
   Print "Value = " ; x
End Sub
'/*--------- end integers ------------*/

IntArray
Sleep
If iarray.iv_array <> NULL Then
   DeAllocate iarray.iv_array
End If

 6 
 on: Today at 12:26:53 PM 
Started by E.K.Virtanen - Last post by E.K.Virtanen
Pjot: Noticed  Wink

 7 
 on: Today at 12:26:32 PM 
Started by E.K.Virtanen - Last post by E.K.Virtanen
uh, this is getting out of hobby programmer wisdom  Embarrassed

 8 
 on: Today at 12:07:58 PM 
Started by E.K.Virtanen - Last post by rdc
DIM a[4]
-create integer array with 4 elements -> 0,1,2,3  zero based
i think that i need create 4 pointers... i think like:
a[0],a[1],a[2],a[3]
as you see there is 4 elements stored uder one array name....
what you think about this option...?

Yes, you could implement arrays using a linked list. Just insert as many items as you need in the list corresponding to the number of elements in the array. The addressing formulas that Steve and I presented resolve to a single index, so it should work just fine for a linked list. The problem will be accessing an particular element; you'll have to traverse the list to correct position to retrieve and set a value, so it will be a bit slower than random access. But it will certainly work.

 9 
 on: Today at 11:57:53 AM 
Started by E.K.Virtanen - Last post by Pjot
Hi E.K,

I have replied here: http://www.allbasic.info/forum/index.php?topic=12.msg53#msg53

Also some code. Hope it helps!

Peter

 10 
 on: Today at 11:55:54 AM 
Started by Pjot - Last post by Pjot
John, I have sent a picture by mail. Thanks for adding BaCon to the list!

Peter

Pages: [1] 2 3 ... 7
Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!