Search found 154 matches

by fzabkar
Dec 28, 2023 22:45
Forum: Beginners
Topic: DIM-ing a constant string
Replies: 6
Views: 578

Re: DIM-ing a constant string

That's very clever. Many thanks once again.
by fzabkar
Dec 28, 2023 19:05
Forum: Beginners
Topic: DIM-ing a constant string
Replies: 6
Views: 578

DIM-ing a constant string

I would like to Dim a constant 512-byte string consisting of 256 repetitions of "Er". This pseudocode is essentially what I want: Dim sErrorSec as Const String * 512 = "Er" * 256 ... but this is the only code I can come up with: Dim sErrorSec As String Dim i As uByte sErrorSec = ...
by fzabkar
Jul 23, 2023 4:36
Forum: Beginners
Topic: Searching for bytes in a block of memory
Replies: 3
Views: 1465

Re: Searching for bytes in a block of memory

This is what I ended up with. Dim bHINxPtr As UByte Ptr Dim qwFFblock( 0 To 3 ) As ULongInt = { &HFFFFFFFFFFFFFFFF, &HFFFFFFFFFFFFFFFF, &HFFFFFFFFFFFFFFFF, &HFFFFFFFFFFFFFFFF} Dim wdBytOfst As UShort Dim wdUCodeLoc As UShort wdUCodeLoc = 0 For wdBytOfst = 0 To ( &H200 - 32 ) If m...
by fzabkar
Jul 22, 2023 23:19
Forum: Beginners
Topic: Searching for bytes in a block of memory
Replies: 3
Views: 1465

Searching for bytes in a block of memory

I have an allocation of memory which contains a block of data consisting of 32 repetitions of 0xFF. I would like to search this memory for this block and position the pointer at the following byte. However, I can't come up with a "clean" solution. Is there a built-in function, or a C funct...
by fzabkar
Jul 19, 2023 1:11
Forum: Beginners
Topic: Passing string parameters to subroutine
Replies: 5
Views: 1700

Re: Passing string parameters to subroutine

Among other things, my conceptual problem was that I did not understand that a string pointer had a length property associated with it.

Thanks again.
by fzabkar
Jul 16, 2023 2:58
Forum: Beginners
Topic: Passing string parameters to subroutine
Replies: 5
Views: 1700

Re: Passing string parameters to subroutine

Thanks. I had wondered whether that was the solution, but it seems I never properly understood byref versus byval.
by fzabkar
Jul 15, 2023 22:22
Forum: Beginners
Topic: Passing string parameters to subroutine
Replies: 5
Views: 1700

Passing string parameters to subroutine

I have a main program which reads a ROM image file of size dwROMsiz into a large string, sROMdata. I want to be able to parse this string with Instr in a subroutine. I would prefer that the variables are not Shared, so that the subroutine would be portable. That is, I want to be able to insert the s...
by fzabkar
Jun 01, 2023 15:39
Forum: Beginners
Topic: Macro for Print + Print #
Replies: 9
Views: 2291

Re: Macro for Print + Print #

I was originally using Version 1.07.1. Command executed: "C:\FreeBASIC\fbc.exe" "C:\FreeBASIC\FBIDE\FBIDETEMP.bas" Compiler output: C:\FreeBASIC\FBIDE\FBIDETEMP.bas(27) error 42: Variable not declared, stuff in 'print "TEST:" '' screen only' C:\FreeBASIC\FBIDE\FBIDETEMP...
by fzabkar
May 31, 2023 21:45
Forum: Beginners
Topic: Macro for Print + Print #
Replies: 9
Views: 2291

Re: Macro for Print + Print #

Just FYI, this macro trick doesn't work in earlier versions of the compiler, so I expect that it is not guaranteed to work in future versions.
by fzabkar
May 28, 2023 17:56
Forum: Beginners
Topic: Macro for Print + Print #
Replies: 9
Views: 2291

Re: Macro for Print + Print #

Thanks. Very clever. Actually, redefining the Print command will be very useful to me. That's because my software usually parses firmware modules, and the structure of these modules changes as new versions emerge. These new versions will usually break my code. Unfortunately, if my program crashes, t...
by fzabkar
May 27, 2023 17:20
Forum: Beginners
Topic: Macro for Print + Print #
Replies: 9
Views: 2291

Re: Macro for Print + Print #

I want to write the same "stuff" to both the console and the specified file. I have a program which writes updates to a log file, and I want these updates to be echoed on the screen while the program is running.
by fzabkar
May 26, 2023 20:00
Forum: Beginners
Topic: Macro for Print + Print #
Replies: 9
Views: 2291

Re: Macro for Print + Print #

This works:

Code: Select all

#macro PrintC( a, b... )

 Print a, b
 Print b

#endmacro

Dim bdata as byte = 41
dim f as long

f = freefile

open "c:\temp\junk.txt" for output as #f

PrintC( #f, "text"; "text2" & "text3", bdata )

close #f

sleep
by fzabkar
May 26, 2023 9:18
Forum: Beginners
Topic: Macro for Print + Print #
Replies: 9
Views: 2291

Macro for Print + Print #

Would it be possible to define a macro, PrintC, such that this ... PrintC #f, "text"; "text2" & "text3", data ... resolves to ... Print #f, "text"; "text2" & "text3", data Print "text"; "text2" & "text3&...
by fzabkar
May 25, 2023 18:30
Forum: Beginners
Topic: (mis)understanding Isalnum
Replies: 2
Views: 1692

Re: (mis)understanding Isalnum

Thank you for the detailed explanation.

I would argue that the behaviour of this function is counterintuitive. In any case, it's inappropriate for my application, so I've had to write my own trivial 7-bit ASCII version.

Thanks again.
by fzabkar
May 24, 2023 19:23
Forum: Beginners
Topic: (mis)understanding Isalnum
Replies: 2
Views: 1692

(mis)understanding Isalnum

Why does the Isalnum function in crt/ctype.bi not return 0 for all ubyte values greater than 0x7F? Why is it not limited to 7-bit ASCII characters? This table lists Hex(ubytvar) and Hex(Isalnum(ubytvar)): 00 00 01 00 02 00 03 00 04 00 05 00 06 00 07 00 08 00 09 00 0A 00 0B 00 0C 00 0D 00 0E 00 0F 00...