## Search found 5878 matches

Aug 03, 2019 10:56
Forum: Tips and Tricks
Topic: StringArray Sort (case independent)
Replies: 87
Views: 7603

### Re: StringArray Sort (case independent)

Example of DOS sort for a million lines of a mixed bag of text characters 60 to 90 digits long. Function StringSplit(s_in As String,chars As String,result() As String) As Long Dim As Long ctr,ctr2,k,n,LC=Len(chars) Dim As boolean tally(Len(s_in)) #macro check_instring() n=0 While n<Lc If chars[n]=s_...
Aug 01, 2019 20:05
Forum: Tips and Tricks
Topic: StringArray Sort (case independent)
Replies: 87
Views: 7603

### Re: StringArray Sort (case independent)

I did some speed tests.
The dos sort was by far the fastest (3.2 seconds for one million shortish strings)
Standard Quicksort was about eight seconds.
The C runtime was about ten seconds.
Jul 31, 2019 23:40
Forum: General
Topic: Squares
Replies: 6886
Views: 402995

### Re: Squares

Try the byte mode. ' highest count 255 = 227 , so we could use 228 and up for the every other byte that wrong above 200... screen 19 dim as longint count1=0 , count2=0 ,v1 dim as ubyte m , d , outs , ans print "input" , "outs" , "ans" For a As Longint = 0 To 255 Step 1 ...
Jul 31, 2019 19:40
Forum: General
Topic: The text and attribute pages in gfx mode ?
Replies: 3
Views: 938

### Re: The text and attribute pages in gfx mode ?

I only know of screencontrol returning grapics colours. screen 20,32 color rgb(10,203,12),rgb(200,40,2) cls dim as integer x,y screencontrol(13,x,y) locate 5,5 print x,y print cptr(ubyte ptr,@x)[2],cptr(ubyte ptr,@x)[1],cptr(ubyte ptr,@x)[0] print cptr(ubyte ptr,@y)[2],cptr(ubyte ptr,@y)[1],cptr(uby...
Jul 31, 2019 16:28
Forum: General
Topic: Squares
Replies: 6886
Views: 402995

### Re: Squares

Looks like an interesting subject. I had to do morse code, but not fast morse code for keying, but sufficient for an aldis lamp. https://en.wikipedia.org/wiki/Signal_lamp Albert Going to it's simplest form, taking a number, it's mod and it's div by two. You need one variable to hold the mod and the ...
Jul 30, 2019 12:45
Forum: General
Topic: Using "PRINT #" and "INPUT ()" on binary files
Replies: 24
Views: 2447

### Re: Using "PRINT #" and "INPUT ()" on binary files

dev_file_open.c looks like one of the main (file device) files in the rtl source. Mostly the "b" string (binary) is used e.g. case FB_FILE_MODE_OUTPUT: /* will create the file if it doesn't exist */ openmask = "wb"; break; I think the b is always recommended for windows. I am uns...
Jul 29, 2019 23:35
Forum: General
Topic: Using "PRINT #" and "INPUT ()" on binary files
Replies: 24
Views: 2447

### Re: Using "PRINT #" and "INPUT ()" on binary files

We can no longer search the forum code blocks, so searching for examples used by experienced coders is not now possible.
But I remember a post by grindstone.
https://www.freebasic.net/forum/viewtopic.php?f=3&t=27482&p=259028#p259028
(For it's simplicity)
Jul 29, 2019 22:55
Forum: General
Topic: Using "PRINT #" and "INPUT ()" on binary files
Replies: 24
Views: 2447

### Re: Using "PRINT #" and "INPUT ()" on binary files

That is perfectly OK IMO This works for the whole file function load(filename as string) as string If FileExists(filename)=0 Then Print filename;" not found":Sleep:exit function var f=freefile Open filename For Binary Access Read As #f function= Input(Lof(f),#f) Close #f end function
Jul 29, 2019 22:08
Forum: General
Topic: Using "PRINT #" and "INPUT ()" on binary files
Replies: 24
Views: 2447

### Re: Using "PRINT #" and "INPUT ()" on binary files

The c runtime provides a fast way to save a string (fb string) without messing around. #include "crt.bi" #include "file.bi" sub save(filename as string,text as string) Dim As file Ptr f=fopen((filename),"wb") fwrite(@text[0],len(text),1,f) fclose(f) end sub Function loa...
Jul 29, 2019 21:21
Forum: Game Dev
Topic: Rubik cube
Replies: 9
Views: 2314

### Re: Rubik cube

Hi Makoto.
I could maybe store all moves in a string and reverse everything done, back to the original.
But it wouldn't be the most direct way to the solution.
Jul 29, 2019 21:17
Forum: General
Topic: Squares
Replies: 6886
Views: 402995

### Re: Squares

try this screen 19 for a as longint = 0 to 255 ' print a, ', (a or 2) mod (a or 1) ' how to reverse the OR MOD ??? var x=(a or 2) mod (a or 1) print x ,(x or 2) mod (x or 1)-(x =1) if a > 0 and a mod 16 = 0 then print "press a key for next 16" : sleep if inkey = chr(27) then exit for next ...
Jul 29, 2019 12:55
Forum: General
Topic: Return pointer to an array from a function
Replies: 13
Views: 1327

### Re: Return pointer to an array from a function

You can manipulate from outside by a pointer. But you are not able to delete the static array. sub show(byref p as double ptr=0) static a(...) as double = {10.1,20.2,30.3} p=@a(0) for n as ulong=lbound(a) to ubound(a) print "a(";n;") ";a(n) next print end sub dim p as double ptr ...
Jul 28, 2019 12:26
Forum: General
Topic: How to draw simple scatterplot with GSL
Replies: 8
Views: 1209

### Re: How to draw simple scatterplot with GSL

Freebasic has it's own gfx graphics. You can produce any type of plot on the fly. Simple scatterplot. Function map(a As Double,b As Double,x As Double,c As Double,d As Double) As Double Return ((d)-(c))*((x)-(a))/((b)-(a))+(c) End Function Function GetMin(array() As Double) As Integer Dim As Double ...
Jul 27, 2019 18:24
Forum: General
Topic: No warning if a select case as const value are out of range compiler crash !
Replies: 12
Views: 1524

### Re: No warning if a select case as const value are out of range compiler crash !

Hi SARG.
Well after a coffee and a scone it still wasn't compiled.
I had to go to my other fbide (for 64 bits) with

Code: Select all

` shell "taskkill /F /IM "+ "fbc.exe  /T"`

And put this file into the fb directory.
It killed it stone dead, but I won't be re-trying your snippet anytime soon.
Jul 27, 2019 17:53
Forum: Tips and Tricks
Topic: StringArray Sort (case independent)
Replies: 87
Views: 7603

### Re: StringArray Sort (case independent)

Using the standard quicksort with the option of producing dos style string sort (case independent) or sort as the array stands.(comment out lcase) i.e. #define casetype 'lcase #define datatype string #define casetype lcase Sub sort(array() As DataType,begin As Long=0,Finish As Long=-1) If begin>fini...