Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 18:32 10 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : string array csub/cfunction generator

Author Message
Nathan
Regular Member

Joined: 10/01/2016
Location: Germany
Posts: 49
Posted: 03:41pm 26 Nov 2017
Copy link to clipboard 
Print this post

Hi,

I have written a small exe(win10) file,
which generates cfunctions/csubs based on a simple
text(ascii) input file.

The program is in an early stage and everyone, who helps
to debug is welcome.

Please run a visrus scan on it, before you use it.
2017-11-27_012413_stringArrayFunGen.zip


I'm really looking for feedback.
Is the executable running on your system?
(MinGW, gcc was used and I'm not sue if the executable need some libs of MinGW)
(powershell?)

Now the details:

stringArrayFunGen.exe
generates a Csub or Cfunction basic block, which can be included
into your program.

The input is a simple ASCII text file. Every line generates a new
array entry, wich can be accessed by user index entry.

There are up to 6 replacement entries possible.
The following entries are used as repleament sequence specifiers within yout text: @0 @1 @2 @3 @4 @5

1.)
Example: test.txt
This is the first line
This is the secondline

stringArrayFunGen.exe -t test.txt -p test.bas

generate the following output file test.bas:

'constString (index,outString)
CSub constString integer string
0000000C
'getFPCx
27BDFFE8 10800003 AFBF0014 10000005 03E41023 3C049D00 24840024 0411FFF8
00000000 8FBF0014 03E00008 27BD0018
'm
27BDFFE0 AFBF001C AFB10018 AFB00014 00808021 00A08821 00002021 0411FFEC
00000000 3C039D00 246300D0 00621021 12000016 94430000 16200003 8E040000
10000012 AE030000 24840001 0083282B 0085180B 00031840 00431821 94630000
00431821 90650000 00052882 00001021 8C640000 AE240000 24420001 24630004
00A2202B 1080FFFA 26310004 8FBF001C 8FB10018 8FB00014 03E00008 27BD0020
'.rodata
00080002 00000020 69685416 73692073 65687420 72696620 6C207473 00656E69
69685416 73692073 65687420 63657320 6C646E6F 00656E69
End CSub

Example usage:
DIM my$
constString(0,my$)
print my$
constString(1,my$)
print my$
------------------------------------------------------------------------------

2.)
Example: test.txt
This is the first line
This is the secondline

stringArrayFunGen.exe -t test.txt -p testFunction.bas -cfunction

generates the following output file testFunction.bas:

'outString = constString (index)
CFunction constString (integer) string
0000000C
'getFPCx
27BDFFE8 10800003 AFBF0014 10000005 03E41023 3C049D00 24840024 0411FFF8
00000000 8FBF0014 03E00008 27BD0018
'm
27BDFFE0 AFBF001C AFB10018 AFB00014 00808021 00002021 0411FFED 00000000
3C119D00 263100EC 02228821 1200001D 96220000 8E030000 24630001 0043202B
10800004 00031840 AE020000 00401821 00031840 02231821 94620000 02228821
92300000 00108082 3C029D00 8C420040 0040F809 24040100 00402021 00001821
8E250000 AC850000 24630001 26310004 0203282B 10A0FFFA 24840004 10000003
8FBF001C 00001021 8FBF001C 8FB10018 8FB00014 03E00008 27BD0020
'.rodata
00080002 00000020 69685416 73692073 65687420 72696620 6C207473 00656E69
69685416 73692073 65687420 63657320 6C646E6F 00656E69
End CFunction

Example usage:
DIM my$
my$ = constString(0)
print my$
my$ = constString(1)
print my$

--------------------------------------------------------------------------------------

1.)
Example: test.txt
This @0 the @1 line
This @0 the @1 line

Generation flow is the same as above. The generated functions are a little bit
different

Example usage(csub):
DIM my$
constString(0,my$,"is","first")
print my$
constString(1,my$,"was","last")
print my$

Example usage (cfunction):
DIM my$
my$ = constString(0,"is","first")
print my$
my$ = constString(1,"was","last")
print my$

The followings shows the help page of the program
>stringArrayFunGen.exe

stringArrayFunGen.exe V0.9 Copyright 2017 by Nathan

WARNING: ***** unstable evaluation version *****


Usage:
stringArrayFunGen.exe <-textin <file>> <-progout <file>> [-cfunction] [-help]

-(t)extin <file> read ascii input file
-(p)rogout <file> write basic function file
-cfunction create cfunction instead of csub
-help show this page


.abnormal end



 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1671
Posted: 04:01pm 26 Nov 2017
Copy link to clipboard 
Print this post

Hi Nathan,

NEAT! Thanks a lot.

I've tested the first example with Win 7 and I get the identical result.
I will further examine ...

I think this can be a useful replacement for the time and space-consuming DATA-READ procedure in Basic be.

Regards
Michael


causality ≠ correlation ≠ coincidence
 
Nathan
Regular Member

Joined: 10/01/2016
Location: Germany
Posts: 49
Posted: 05:21pm 26 Nov 2017
Copy link to clipboard 
Print this post

Hi Michael,
Hallo Michael,

thanks for the test.
danke fuer den Test.

What do you think does it make sense to implement
something similar for integer input?
Was meinst Du macht es Sinn etwas aehnliches fuer
Integer zu integrieren?

At the moment I'm thinking about the following:
Im Moment denke ich ueber folgendes nach:

:<identifier> -- start of new data segement ":"

<identifier> <b> byte, <s> short_16, <i> int_32, <l> int_64

:<s> 122, 33, 44, 56, 554, 666, 777, 888,
8888 ...
:<b> 56, 445, 77, 88, 99, 99, @0, @2, ...

The data would be copied into an c%-array.
Die Daten wuerden dann in ein c%-Array kopiert.

Does this make sense?
Macht das Sinn?

Nathan
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1671
Posted: 05:37pm 26 Nov 2017
Copy link to clipboard 
Print this post

Hi Nathan,

there is no need to translate to german! Thanks anyway!
  Quote  What do you think does it make sense to implement
something similar for integer input?

Yes, I didn't dare to ask for it!
If you store numbers into a cfunction you can save a lot of memory!
Espacially the different number formats are a very good idea.

:<b> 56, 445, 77, 88, 99, 99, @0, @2, ...

What stands the "@" for?

hmm (superior attitude)
"445" would not fit into a byte.

Why not implement a binary number format too?



Edited by twofingers 2017-11-28
causality ≠ correlation ≠ coincidence
 
Nathan
Regular Member

Joined: 10/01/2016
Location: Germany
Posts: 49
Posted: 06:02pm 26 Nov 2017
Copy link to clipboard 
Print this post

Hi Michael,

>hmm (superior attitude)
>"445" would not fit into a byte.
you haven't seen my bytes
Of course that's an mistake in specification.
Say someone: I'm a typical german

  twofingers said  

What stands the "@" for?



The @ is a place holder with an index, similar is already available
for the strings (please take a look ono the end of the first blog entry).

For Example:

:<s> 1, 2, 3, @0, @1, 3, 2, 1

The cfunction/csub have the following additional fields:
cfunction ..., @0, @1, @2, @3, @4, @5
so in total 6 values can be inserted automatically.

cfunction ..., 99, 300

would generate the following

1, 2, 3, 99, 300, 3, 2, 1

If the specification was:
:<s> 1, 2, 3, @0, @1, @0, 2, 1

then you would get:
1, 2, 3, 99, 300, 99, 2, 1

Nathan

Edited by Nathan 2017-11-28
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1671
Posted: 06:14pm 26 Nov 2017
Copy link to clipboard 
Print this post

Hmm, I understand but I see a lot of problems about the error handling.
What's happened if the numbers not fit for that number format?
I'm not sure if this is a desirable feature for numbers. For strings it makes sense.
But it's of course your decision.
causality ≠ correlation ≠ coincidence
 
Nathan
Regular Member

Joined: 10/01/2016
Location: Germany
Posts: 49
Posted: 06:31pm 26 Nov 2017
Copy link to clipboard 
Print this post

Hi Michael,

>I'm not sure if this is a desirable feature for numbers. For strings it makes sense.
>But it's of course your decision.
I have some RS232 modules, which requires embeded controls inside of the send
data.

>Hmm, I understand but I see a lot of problems about the error handling.
>What's happened if the numbers not fit for that number format?
Good point, I thought already about it, but did not found a good solution.
I will need some additional information
- endian.., split number ...
The C-Code will get to big and this is my problem at the moment.

So any implementation idea is welcome.

First implementation will be without @.

Nathan
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1671
Posted: 06:42pm 26 Nov 2017
Copy link to clipboard 
Print this post

Hi Nathan,

did you see my edit above?
  Quote  Why not implement a binary number format too?

This could be useful for example for a signal generator or to control output pins etc.

  Nathan said  

>I'm not sure if this is a desirable feature for numbers. For strings it makes sense.
>But it's of course your decision.
I have some RS232 modules, which requires embeded controls inside of the send
data.
I see, accepted!
causality ≠ correlation ≠ coincidence
 
Nathan
Regular Member

Joined: 10/01/2016
Location: Germany
Posts: 49
Posted: 10:12pm 01 Dec 2017
Copy link to clipboard 
Print this post

  twofingers said   Hi Nathan,

did you see my edit above?
  Quote  Why not implement a binary number format too?

This could be useful for example for a signal generator or to control output pins etc.



Hi,

sorry I was offline over the week.

I'm still coding.

The following number format will be supported:
Positiv numbers
0b00000111111 - binary
0x000000000ff - hex
03 - octal number starts with 0
32222 - normal integer
negative numbers
-0b0000001111
-0xfff0000000
-03
-322222

At the moment I'm in trouble with the following numbers
0xffffffffffffffff
0x7fffffffffffffff

So it will take a little bit till a test version will be available.

Nathan

 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025