Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Arrays within custom data types.

Author
Message
Athas
22
Years of Service
User Offline
Joined: 8th Aug 2003
Location:
Posted: 23rd Oct 2003 17:55
Does anyone know of a way to put array's into types. I'll show you what I mean




Note this isn't my real code but its similar so pardon if there are any mistakes.

Basically I can't seem to create a type which contains an array as above.

I'd like to be able to use it like
Code:




Are there any workarrounds for more flexible data types. Maby using memblocks and ponters???
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Oct 2003 20:16
No, because you can't do it.

The standard advice I give is to use a parallel array

Athas
22
Years of Service
User Offline
Joined: 8th Aug 2003
Location:
Posted: 24th Oct 2003 15:38
Thanks Ian,

Any chance of that getting added in a future patch or is that asking too much. Oh the other function I would like to see added is MOD its really quite usefull for the maths. (I've actually got my own function for MOD ) but it does seem a strange omission when WrapValue( ) or whatever its called is included.
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 24th Oct 2003 15:41
MOD already exists!

print 10 mod 3

If your mansion house needs haunting, just call Rentaghost!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Oct 2003 15:47
Quote: "Any chance of that getting added in a future patch"


Don't ask me - I'm just an 'interested party' that likes to help out

Arrays are a difficult question really. What most people don't know is that an array (for DBPro) isn't just a few pigeon holes in memory - it's a whole 60+byte structure that changes sizes depending on how many items it holds.

What we may end up with is a restricted type of array for types that cannot be resized and cannot hold strings or types with strings (to avoid cascading copies) - what we finally do get will be up to Lee


mod - just one of the few undocumented functions/commands

Athas
22
Years of Service
User Offline
Joined: 8th Aug 2003
Location:
Posted: 24th Oct 2003 15:50
Are there many undocumented functions? Sorry I'm really new to DBPRO I used to use Classic quite a bit and VB an awfull lot.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Oct 2003 16:02
There are local/global keywords for scope

dims outside of a function are always global, dims within functions are always local

Accessing an array like this 'x()' with no index accesses the 'current' cell (see NEXT ARRAY INDEX/PREVIOUS ARRAY INDEX)

Prefixing a number with a zero causes DBPro to deal with it as octal (not just a prefix of 0c as stated in the help)

Constants are textual substitutes, so the following code doesn't quite work as expected



Reading/writing from memory using pointers - not going to go there , but I have a set of rules that seem to work well for me.

Maybe others that I can't think of right now
Athas
22
Years of Service
User Offline
Joined: 8th Aug 2003
Location:
Posted: 24th Oct 2003 16:14
Thanks ian hey constants being textual substitutions could actually be very usefull in some circumstances I'm going to have a play I actually used to use DARKEDIT in that way. defineing bits of text I wanted though I would never have guessed that DBPRO opperated in the same way.

Very helpful,
Thanks again
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Oct 2003 16:22
I have actually used the constants as a crude conditional compilation - extracted from my A* code in CodeBase

Athas
22
Years of Service
User Offline
Joined: 8th Aug 2003
Location:
Posted: 2nd Nov 2003 21:38 Edited at: 2nd Nov 2003 21:38
Quote: "
No, because you can't do it.

The standard advice I give is to use a parallel array

"


Hey I was just wondering if you could add a line saying


if they are just textual substitutions
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 3rd Nov 2003 01:15
@ IanM

This mod command - could you say a = (10 mod 3)?
DrakeX
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location:
Posted: 3rd Nov 2003 02:10
umm yeah. you can also use %% for mod, if you're used to C's % operator for mod.

stop looking at me!
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 4th Nov 2003 01:10
@ DrakeX and IanM - pls explain.... it make no sense to me (IQ of tepid glass of lemonwater...)

could you give some workable examples of Mod in DBPro?
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Nov 2003 01:16
Sorry, but you seemed to know what it does ...

print 10 mod 3

this would print 1 as the answer, so ...

a = 10 mod 3

would put the value 1 into variable a
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 5th Nov 2003 00:21
@ IanM,

Thanks - knew what Mod did from my old Amos days but wanted to see how it was implimented in DBPro - ta

Login to post a reply

Server time is: 2026-07-26 20:17:00
Your offset time is: 2026-07-26 20:17:00