Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Kitty Hello

Pages: [1] 2 3 ... 702
1
For a quick fix, please write (old style) self.m[] = matArray[] // <-- the final braces are the problem. Don't omit so far.

2
GPC - GLBasic Precompiler V.17.312
Your code compiled fine, here.

3
Announcements / Re: Comming up features
« on: 2021-Mar-16 »
I replied in the bug-reports. Get the latest beta, it should be fixed.

4
Off Topic / Re: DLB/GLB
« on: 2021-Mar-16 »
If it's based on GLBasic, why not make it an Add-On that required GLBasic? Win-win?

5
The packing was broken. Packed content was longer than the original -> buffer overflow. Get the new beta, it's fixed.

6
Off Topic / Re: DLB/GLB
« on: 2021-Mar-16 »
I think, you have to explain it to me, because at the moment it looks like you want to re-wrap GLBasic in colourful paper, add a ribbon and sell it?

7
Code: (glbasic) [Select]
FUNCTION GetWidgetID%: name$
LOCAL i%, w AS TWidget
FOREACH w IN self.w[]
NEXT

Both, the compiler and you happen to be right. The error message is quite bad, though.
You declare a variable 'w' of type TWidget, which shadows the variable self.w[] of type DGArray<TWidget>. Remove the 'LOCAL w AS TWidget', please.

I fixed this bug in the compiler, but I hope I'm not adding other bugs with this. I'll add it to the beta as an update, soon.

8
Math / Re: Hex To Decimal and Decimal to Hex
« on: 2021-Mar-15 »
Ah. Try this:
Code: (glbasic) [Select]
IMPORT "C" int strtol(const char* str, int endptr, int base)
LOCAL str$ = "ff"
LOCAL n% = strtol(str$, 0, 16)

9
Fixed in current beta. Can you try?

10
Announcements / Re: Comming up features
« on: 2021-Mar-13 »
Get the beta branch. The Shoebox bug is fixed. You need to recreate the SBX files, though.

11
Shoebox compression is totally broken. I'm trying to fix, but I think I will have to reimplement another compression library, making your old sbx files broken. I'll add a header to give you a warning.
I'm sorry. This is a lot of work and I hope to find time for it, soon. I spend a few hours just to track the bug...

12
GLBasic - en / Re: Windows - Universal App?
« on: 2021-Mar-13 »
I found a way to make appx packages for the Windows App Store. Are you interested?

13
Math / Re: Hex To Decimal and Decimal to Hex
« on: 2021-Mar-13 »
There is a builtins HEX$(), are you aware of that?

14
Off Topic / Re: DLB/GLB
« on: 2021-Mar-13 »
What programming language would you use for the final product?

15
Userlibs [ *.gbal] / Dictionary, SortedList
« on: 2021-Feb-05 »
Here's an improved version of the Dictionary and a Sorted List for strings. I'll include that into the GLBasic Samples folder, because it's very handy, okay?
Code: (glbasic) [Select]
// --------------------------------- //
// Project: T_Dictionary
// Start: Friday, August 16, 2019
// IDE Version: 16.252

TYPE T_DictionaryPair
key$
val$
ENDTYPE

TYPE TDictionary
pairs[] AS T_DictionaryPair

// ------------------------------------------ //
//! Get string at given key
// ------------------------------------------ //
FUNCTION get$: key$
LOCAL i% = _index(key$, FALSE)
IF i>=0 THEN RETURN self.pairs[i].val$
RETURN ""
ENDFUNCTION

// ------------------------------------------ //
//! Set string at given key
// ------------------------------------------ //
FUNCTION set%: key$, val$
LOCAL i% = _index(key$, TRUE)
self.pairs[i].val$ = val$
ENDFUNCTION

// ------------------------------------------ //
//! Get index in pairs[] for given string
// ------------------------------------------ //
FUNCTION _index%: BYREF name$, create%=TRUE
LOCAL up%, dn%, mid%
up=0; dn=LEN(self.pairs[])-1
WHILE up < dn
mid = (up+dn) / 2
IF self.pairs[mid].key$ > name$
dn=MAX(mid-1, up)
ELSE
IF self.pairs[mid].key$ < name$
up=MIN(dn, mid+1)
ELSE
RETURN mid // not bigger, not smaller, guess what!?
ENDIF
ENDIF
WEND

IF LEN(self.pairs[]) AND self.pairs[up].key$ = name$ THEN RETURN up

// not found. But must be at [up].
IF create%
dn = LEN(self.pairs[]) // one below last
REDIM self.pairs[dn+1]
FOR mid = dn TO up+1 STEP -1
self.pairs[mid] = self.pairs[mid-1]
NEXT
IF dn>0 AND self.pairs[up].key$ < name$ THEN up=up+1

ALIAS where AS self.pairs[up]
where.key$ = name$
where.val$ = ""
RETURN up
ENDIF
RETURN -1
ENDFUNCTION
ENDTYPE


TYPE TSortedSet
keys$[]

// ------------------------------------------ //
//! Get string at given key
// ------------------------------------------ //
FUNCTION isSet%: key$
LOCAL i% = _index(key$, FALSE)
IF i>=0 THEN RETURN TRUE
RETURN FALSE
ENDFUNCTION

// ------------------------------------------ //
//! Set string at given key
// ------------------------------------------ //
FUNCTION insert%: key$
_index(key$, TRUE)
ENDFUNCTION

// ------------------------------------------ //
//! Get index in pairs[] for given string
// ------------------------------------------ //
FUNCTION _index%: BYREF name$, create%=TRUE
LOCAL up%, dn%, mid%
up=0; dn=LEN(self.keys$)-1
WHILE up < dn
mid = (up+dn) / 2
IF self.keys$[mid] > name$
dn=MAX(mid-1, up)
ELSE
IF self.keys$[mid] < name$
up=MIN(dn, mid+1)
ELSE
RETURN mid // not bigger, not smaller, guess what!?
ENDIF
ENDIF
WEND

IF LEN(self.keys$[]) AND self.keys$[up] = name$ THEN RETURN up

// not found. But must be at [up].
IF create%
dn = LEN(self.keys$[]) // one below last
REDIM self.keys$[dn+1]
FOR mid = dn TO up+1 STEP -1
self.keys$[mid] = self.keys$[mid-1]
NEXT
IF dn>0 AND self.keys$[up] < name$ THEN up=up+1

self.keys$[up] = name$
RETURN up
ENDIF
RETURN -1
ENDFUNCTION
ENDTYPE


Test program
Code: (glbasic) [Select]
LOCAL sose AS TSortedSet

sose.insert("cat")
sose.insert("mouse")
sose.insert("dog")
sose.insert("bird")
STDOUT "isset dog " + sose.isSet("dog") + "\n"
STDOUT "isset rat " + sose.isSet("rat") + "\n"
FOREACH k$ IN sose.keys$[]
STDOUT "-" + k$ + "\n"
NEXT

STDOUT "------------------\n"

LOCAL dict AS TDictionary

dict.set("cats", 5)
dict.set("mice", 7)
dict.set("dogs", "many")
dict.set("birds", "any")
STDOUT "dogs: " + dict.get$("dogs") + "\n"
STDOUT "rats: " + dict.get$("rats") + "\n"
FOREACH p IN dict.pairs[]
STDOUT "-" + p.key$ + " = " + p.val$ + "\n"
NEXT
KEYWAIT


Here's the output
Code: (glbasic) [Select]
isset dog 1
isset rat 0
-bird
-cat
-dog
-mouse
------------------
dogs: many
rats:
-birds = any
-cats = 5
-dogs = many
-mice = 7

Pages: [1] 2 3 ... 702