Search found 703 matches

by grindstone
Jun 30, 2020 21:54
Forum: General
Topic: Open program by dragging file "onto it"
Replies: 15
Views: 302

Re: Open program by dragging file "onto it"

No problem, with only a litte more effort you can evaluate any line of text you dropped onto the (console-) window of a running FB program: Dim As String text, g Dim As boolean flag text = "" flag = FALSE Do g = InKey If Len(g) Then flag = TRUE text += g EndIf If g = "" AndAlso f...
by grindstone
Jun 30, 2020 21:16
Forum: General
Topic: Open program by dragging file "onto it"
Replies: 15
Views: 302

Re: Open program by dragging file "onto it"

Why that complicated? It can be done with just one single line of code:

Code: Select all

Shell Chr(34) & Command(1) & Chr(34)
by grindstone
Jun 21, 2020 12:47
Forum: Beginners
Topic: Any suggestions on the best way to set up a linked list?
Replies: 24
Views: 702

Re: Any suggestions on the best way to set up a linked list?

What I find most frustrating is that I used to know this stuff, though I didn't realise quite what a can of worms I was opening when I started. Welcome to the club! And now use that worms to get a big fish. ;-) If it wasn't for the idea of being able to put things in things etc the implementation w...
by grindstone
Jun 20, 2020 11:40
Forum: Beginners
Topic: Any suggestions on the best way to set up a linked list?
Replies: 24
Views: 702

Re: Any suggestions on the best way to set up a linked list?

The list doesn't necessarily have to be organized as a chain or a tree. Here an example of 6 rooms arranged in a 3-by-2 - grid: Enum N E S W End Enum Type tRoom Dim As tRoom Ptr door(3) 'contains the pointer of the room you get to if you walk through the door Dim As String text Dim As Integer number...
by grindstone
Jun 19, 2020 20:44
Forum: Beginners
Topic: Any suggestions on the best way to set up a linked list?
Replies: 24
Views: 702

Re: Any suggestions on the best way to set up a linked list?

Alright, let's do it step by step. As a start a very basic first approach to create and handle a double linked list representing a tree structure. You can create an arbitrary number of rooms and walk through them: Type tRoom Dim As Integer level Dim As Integer roomNumber Dim As tRoom Ptr parent 'poi...
by grindstone
Jun 18, 2020 23:04
Forum: Beginners
Topic: Any suggestions on the best way to set up a linked list?
Replies: 24
Views: 702

Re: Any suggestions on the best way to set up a linked list?

Looks like you're working to write an adventure game, right? In this case, using a linked list would be a pretty good idea.
by grindstone
Jun 18, 2020 22:42
Forum: General
Topic: Duplicates
Replies: 34
Views: 919

Re: Duplicates

One (serious) question: Is it really faster to make CRC16 hashes of two strings and compare the hashes than directly comparing the strings for equality?
by grindstone
Jun 18, 2020 4:06
Forum: General
Topic: Duplicates
Replies: 34
Views: 919

Re: Duplicates

MrSwiss wrote:In the upcoming FBC 1.08.0 (currently DEV state) that functionality is implemented.
Thank you, that's good news.
by grindstone
Jun 17, 2020 21:47
Forum: General
Topic: Duplicates
Replies: 34
Views: 919

Re: Duplicates

Ok, I think that's a passable way to solve that task (if you find any bugs, please let me know): Dim As ZString*2 h Dim As String src, dst, testfile, g Dim As Integer filepointer1, filepointer2, readfrom, writeto, x, y, endofdata testfile = "C:\testfile.txt" 'create testfile Open testfile ...
by grindstone
Jun 17, 2020 19:12
Forum: General
Topic: Duplicates
Replies: 34
Views: 919

Re: Duplicates

From the coding point of view it's not a big deal: Dim As String src, dst, oldfile, newfile Dim As Boolean duplicate oldfile = "C:\oldfile.txt" 'replace with the desired file names newfile = "C:\newfile.txt" Open oldfile For Input As #1 Open newfile For Output As #2 'copy the 1st...
by grindstone
Jun 07, 2020 21:01
Forum: General
Topic: Optimum sum of a set of numbers
Replies: 18
Views: 540

Re: Optimum sum of a set of numbers

@UEZ: You're right, thank you for testing. I've fixed it.
by grindstone
Jun 07, 2020 20:21
Forum: General
Topic: Optimum sum of a set of numbers
Replies: 18
Views: 540

Re: Optimum sum of a set of numbers

Without having analyzed it: Although the result is correct, this Rosetta code seems to be quite ineffective. It does 986409 iterations, while there are only 2^10 - 1 = 1023 possible combinations of the values. Here another approach, with a recursive called sub and without limitation of the number of...
by grindstone
Jun 06, 2020 17:42
Forum: General
Topic: Optimum sum of a set of numbers
Replies: 18
Views: 540

Re: Optimum sum of a set of numbers

So welcome back at coding. *smile*
by grindstone
Jun 06, 2020 16:36
Forum: General
Topic: Optimum sum of a set of numbers
Replies: 18
Views: 540

Re: Optimum sum of a set of numbers

Thank you. I wonder if there's a more elegant method than brute force.
by grindstone
Jun 06, 2020 16:14
Forum: General
Topic: Optimum sum of a set of numbers
Replies: 18
Views: 540

Re: Optimum sum of a set of numbers

Brute force and limited to 64 values: Dim As Integer number(0 To ...) = {175, 250, 79, 325, 652, 125, 410, 519, 10, 701} Dim As ULongInt mask, x, optmask Dim As Integer y, sum, optsum, maxsum = 1000 Print 'without this PRINT I get a false positive from COMODO virus scanner For x = LBound(number) To ...

Go to advanced search