View previous topic :: View next topic |
Author |
Message |
manekinen
Joined: 21 Oct 2007 Posts: 34
|
Posted: Wed Jul 13, 2011 3:10 pm Post subject: String2 at string1 overlay |
|
|
Hi.
It is possible to overlay one string at another?
I try to do this like this:
Code: | Dim main_str as string *14
Dim 3_char as string * 1 at main_str +2 overlay
Dim 7_char as string * 4 at main_str +6 overlay |
But it returns me error
Code: | Address out of bounds [3_char] |
I have a main_str with a name from which i must get chars: 3,7,8,9,10 and paste them together in other string, and add some other chars after this "shortened" name.
How to do this in other way? But i need to do this economically, using as small amount of flash memory as possible. _________________ µProg – tiny, fast, portable AVR programmer with SD - bascom powered |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Wed Jul 13, 2011 3:47 pm Post subject: |
|
|
Compiles fine here and works with 2.0.7.0 and 1.12.0.0.
Code: |
$regfile = "m168def.dat"
$crystal = 20000000
$baud = 115200
$hwstack = 200
$swstack = 200
$framesize = 200
Dim Main_str As String * 14
Dim 3_char As String * 1 At Main_str + 2 Overlay
Dim 7_char As String * 4 At Main_str + 6 Overlay
Main_str = "HelloWorld!!"
Print 3_char
Print 7_char
End
|
_________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
manekinen
Joined: 21 Oct 2007 Posts: 34
|
Posted: Wed Jul 13, 2011 4:05 pm Post subject: |
|
|
Ok, it was a just a typo
It compiles ok, but these overlayed strings does not contains end marks.
So, if main_str = "abcdefghijklmn"
Then Print 3_char returns "cdefghijklmn"
And Print 7_chars returns "ghijklmn"
But i want to get:
Print 3_char "c"
Print 7_char "ghjk"
To be easily added like this:
result_string = 3_char + 7_char + "-" + Str(number) to get 8 char name with number.
For example, "cghjk-64"
I have seen SPLIT and INSTR and i can do this with these or familiar string functions but code will be too big. I search for a simple solution.
Or is there any function which allow me to copy a char from string from selected position? _________________ µProg – tiny, fast, portable AVR programmer with SD - bascom powered |
|
Back to top |
|
|
manekinen
Joined: 21 Oct 2007 Posts: 34
|
|
Back to top |
|
|
|