[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
Pete's QBASIC Site Discuss QBasic, Freebasic, QB64 and more 2021-01-23T16:55:54-05:00 http://www.petesqbsite.com/phpBB3/app.php/feed/topic/14854 2021-01-23T16:55:54-05:00 2021-01-23T16:55:54-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39043#p39043 <![CDATA[Re: structure array within a structure]]> Statistics: Posted by mikefromca — Sat Jan 23, 2021 4:55 pm


]]>
2021-01-21T03:25:02-05:00 2021-01-21T03:25:02-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39042#p39042 <![CDATA[Re: structure array within a structure]]> this topic for shared variables.) It's dirty but there's no other way that I'm aware of:

Code:

DIM SHARED mdStoreName AS STRING * 30DIM SHARED mdEmployees(10) AS employeeDIM SHARED mdProducts(100) AS product
If you need to have variable-length content or arrays in a user-defined type for some other purpose, I'd recommend an indexing system for the type and a shared array for its content, something like:

Code:

TYPE vec2x AS INTEGERy AS INTEGEREND TYPETYPE shapenumPts AS INTEGERfirstPt AS INTEGEREND TYPEDIM SHARED ptList(31) AS vec2DIM shp AS shapeshp.numPts = 2shp.firstPt = 0ptList(0).x = 10  ' 1st point, index 0ptList(0).y = 15ptList(1).x = 20  ' 2nd point, index 1ptList(1).y = 100
Or you could tell QB to free some memory, reserve it again via a DOS interrupt, and craft a custom routine to write and read data to/from memory (since pointers are not exactly available in QB;) this way you could reserve as much or as little memory as you need for your types and keep track of it via its segment and offset (would be static since QB cannot mess with it.) The obvious downside is that you'll have to use your custom routines to access that data and will have to create temporary structures to display or manipulate its content (fill structure from memory, manipulate the data, write the structure back to memory.) For simplicity's sake I'd rather go for the indexed system...

Statistics: Posted by MikeHawk — Thu Jan 21, 2021 3:25 am


]]>
2021-01-19T20:39:01-05:00 2021-01-19T20:39:01-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39041#p39041 <![CDATA[structure array within a structure]]>
I'm making a routine in assembly that will extract multiple name-value pairs back to Qbasic but I'd like to receive it in a special type structure but I don't know if it can be doable in Qbasic. I'll explain in Qbasic code what I'm trying to do:

Code:

Type employee    FirstName as string * 30    LastName as string * 30    Age as integerEnd TypeType product    ProductName as string * 30    ProductPrice as DoubleEnd TypeType maindata    StoreName as string * 30    employees(10) as employee    products(100) as productEnd TypeDim datatoasm as maindata'setup namedatatoasm.StoreName="Valu Mart"'setup first employeedatatoasm.employees(1).FirstName="John"datatoasm.employees(1).LastName="Smith"datatoasm.employees(1).Age=66'setup 2nd employeedatatoasm.employees(2).FirstName="Jack"datatoasm.employees(2).LastName="Daniels"datatoasm.employees(2).Age=77
I hope my code explains it better. But When I try to execute it in Qbasic, it complains at the code here:

Code:

    employees(10) as employee    products(100) as product
and highlights the word "as" and shows as an error "Expected end-of-statement".

Is there a way around this without me having to do this...

Code:

    employee1 as employee    employee2 as employee    ...    employee10 as employee    product1 as product    product2 as product    product3 as product    ...    product99 as product        product100 as product    

Statistics: Posted by mikefromca — Tue Jan 19, 2021 8:39 pm


]]>