What is the hh Pascal equivalent of chr()?
I'm trying to build a string from an array of ascii values using scripting. When I try to use the standard Pascal chr() function to convert the integers in my array, hh throws an "Unknown declaration "chr"" error. (BTW I do know that in hh a string is an arrays of chars.)
Thanks for your help!
Thanks for your help!
Regards,
Scott
Scott
Hi,
I'm fact you treat the char as single
Var currentChar: single
...
currentChar := GetdataArrayvalue(input, Idx );
...
SetdataArrayvalue (output, Idx, currentChar) ;
I'm fact you treat the char as single
Var currentChar: single
...
currentChar := GetdataArrayvalue(input, Idx );
...
SetdataArrayvalue (output, Idx, currentChar) ;
http://oli-lab.org
Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces
follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social
Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces
follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social
Thanks oli. What I am trying to do is build a complete string within the script before outputting it. Something like s:=s+chr(char_arr).
Thanks again.
Thanks again.
Regards,
Scott
Scott
Concatenation works - the '+' operator.
In case you missed it, there's a very handy page on strings in the scripting language tutorial:
http://www.sensomusic.org/wiki3/doku.ph ... tutorial05
Look at the examples towards the bottom.
In case you missed it, there's a very handy page on strings in the scripting language tutorial:
http://www.sensomusic.org/wiki3/doku.ph ... tutorial05
Look at the examples towards the bottom.
Address the process rather than the outcome. Then, the outcome becomes more likely. - Fripp
Thanks shawn. Yes I am familiar with this section of the tutorial. Appending chars to strings is clear to me. Maybe I'm missing something though.
To recap : I have an array of singles where each value represents an acsii character. I'm trying to convert this to a string. So I read each value in the array, round()ing it as I go. Now I want to convert each integer value to a char so I can append it to a string. In Pascal proper I'd use the chr() function but in hh that's not available. I guess my question really is how do I convert a single to a char.
To recap : I have an array of singles where each value represents an acsii character. I'm trying to convert this to a string. So I read each value in the array, round()ing it as I go. Now I want to convert each integer value to a char so I can append it to a string. In Pascal proper I'd use the chr() function but in hh that's not available. I guess my question really is how do I convert a single to a char.
Regards,
Scott
Scott
I don't do a lot of string manipulation, so I can only tell you what I'd try...
There are three approaches I'd experiment with...
(1) Your example with a recast along the way... s := s+inttostr(char_arr);
(2) Loop StrSet's, e.g., StrSet(char_arr, x, s); Don't forget to do a SetLength somewhere in there
(3) Declare char_arr as a string to begin with
Dealing with small integers you may need to recast using trunc() or int() somewhere along the line...
Shawn
There are three approaches I'd experiment with...
(1) Your example with a recast along the way... s := s+inttostr(char_arr);
(2) Loop StrSet's, e.g., StrSet(char_arr, x, s); Don't forget to do a SetLength somewhere in there
(3) Declare char_arr as a string to begin with
Dealing with small integers you may need to recast using trunc() or int() somewhere along the line...
Shawn
Address the process rather than the outcome. Then, the outcome becomes more likely. - Fripp
Maybe simply
S := S + ArrChar ?
S := S + ArrChar ?
http://oli-lab.org
Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces
follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social
Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces
follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social
shawnb:
1) appends the ascii value to my string rather than the acsii character
2) StrSet() looks interesting however hh throws an "Unknown declaration "StrSet"" error. Maybe this procedure hasn't been implement in hh?
3) char_arr is, by functional requirement, an array of singles though the values at the relevant index are always converted to integers (as they are ascii vals)
oli:
Same problem as #3 above. The array values are singles and can't be added to a string.
Thanks again for your suggestions. I do appreciate them.
1) appends the ascii value to my string rather than the acsii character
2) StrSet() looks interesting however hh throws an "Unknown declaration "StrSet"" error. Maybe this procedure hasn't been implement in hh?
3) char_arr is, by functional requirement, an array of singles though the values at the relevant index are always converted to integers (as they are ascii vals)
oli:
Same problem as #3 above. The array values are singles and can't be added to a string.
Thanks again for your suggestions. I do appreciate them.
Regards,
Scott
Scott
I remember having trouble with char and string with script in the past, I think I find it easier with the sdk.
I'll check in my archive for script I made using char and string...
I'll check in my archive for script I made using char and string...
http://oli-lab.org
Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces
follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social
Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces
follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social
hi,
you're right the CHR is missing in the script engine. It will be corrected in the next major release.
the work arround is to create the CHR function yourself like bellow. Fully customizable
senso+++
you're right the CHR is missing in the script engine. It will be corrected in the next major release.
the work arround is to create the CHR function yourself like bellow. Fully customizable
senso+++
Code: Select all
function MyCHR(i:integer):Char;
const S ='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
begin
result := S[i-40];
end;
//////////////////////////////
// main proc
//////////////////////////////
Procedure Process;
begin
writeln(MyChr(41)+MyChr(42));
end;Olivier Sens
www.brainmodular.com
www.brainmodular.com
Thanks oli and Olviier. I've worked around the issue by writing the chrs to, then reading them back from, a ptString output.
Regards,
Scott
Scott
Who is online
Users browsing this forum: No registered users and 48 guests
