Welcome to %s forums

BrainModular Users Forum

Login Register

letter with accent

I need help on a Patch
Post Reply
User avatar
oli_lab
Member
Posts: 1266
Location: Brittany, France
Contact:

Unread post by oli_lab » 25 Feb 2015, 00:31

Hi
I'm making a morse code encoder...

I have trouble with accentuated letter as à, é, è, as well as with the question mark...

it is ok with an 'a' or an 'A' but could no detect the à (neither '&agrave')

any idea ?

he is a except of the script :

procedure Callback(N:integer);
//var st : string;
//var stout : string;
var i : integer;
var c : char;
var size : integer;
Var tab1 : array of integer;
var arraysize : integer
begin
SetStringValue(output, '');
st := (GetStringValue(Input));
size := Length(st);
//sTrace('size');
//iTrace(size);
for i := 0 to size do begin
c := st;
//sTrace(c);
//iTrace(i);
if ((c = 'a' )OR(c = 'A')OR(c = 'à')) then
begin
sTrace('detecte un a');
SetStringValue(output,GetStringValue(output) + '1010111000');
end
else if ((c = 'b' )OR(c = 'B')) then
begin
//sTrace('detecte un b');
SetStringValue(output,GetStringValue(output) + '111010101000');
end
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

User avatar
oli_lab
Member
Posts: 1266
Location: Brittany, France
Contact:

Unread post by oli_lab » 10 Mar 2015, 17:15

As I understand it, à é etc... are not ainsi char so they are not reconized if the var is declared as a char...

solution for me is to use an array as the input string :

/////////////////////

/////////////////////////////////////////////
// encode morse code !
////////////////////////////////////////////

// parameters declaration
var input : Tparameter;
var output : Tparameter;
var reset : Tparameter;
var setStr : Tparameter;
//var s1 : String;
var st : string;
var stout : string;


// destroy
procedure Destroy;
begin
//s1.free;

end;

// initialisation : create parameters
procedure init;
begin
SetModuleColor($FFFF80);
Input := CreateParam('text',ptArray);
SetIsOutPut(Input,false);
reset := CreateParam('reset',ptDataField);
SetIsOutPut(reset,false);
setStr := CreateParam('set',ptDataField);
SetIsOutPut(setStr,false);
output := CreateParam('code morse sequence',ptTextField);
SetIsInPut(Output,false);
//S1.Create;

end;


procedure Callback(n:integer);
//var st : string;
//var stout : string;
var i : integer;
var c : single;
var size : integer;
Var tab1 : array of integer;
var arraysize : integer

begin
if (n = 2)AND(GetValue(setStr) = 1) then begin
//SetStringValue(output, '');
SetStringValue(output,GetStringValue(output) + '000000000');
size := GetLength(input);
//sTrace('size');
//iTrace(size);
for i := 0 to size do begin
c := getDataArrayValue(input,i);
//sTrace(c);
//iTrace(i);
if (c = 83 ) then
begin
//sTrace('detecte un ?');
SetStringValue(output,GetStringValue(output) + '101011101110101000');
end
else if ((c = 65 )OR(c = 97)OR(c = 224)) then
begin
//sTrace('detecte un a');
SetStringValue(output,GetStringValue(output) + '1010111000');
end

else if ((c = 66 )OR(c = 98)) then
begin
//sTrace('detecte un b');
SetStringValue(output,GetStringValue(output) + '111010101000');
end

else if ((c = 67 )OR(c = 99)OR(c = 231)) then
begin
SetStringValue(output,GetStringValue(output) + '11101011101000');
end

else if ((c = 68 )OR(c = 100)) then
begin
SetStringValue(output,GetStringValue(output) + '1110101000');
end

else if ((c = 69 )OR(c = 101)OR(c = 233)OR(c = 232)OR(c = 234)) then
begin
SetStringValue(output,GetStringValue(output) + '1000');
end

else if ((c = 70 )OR(c = 102)) then
begin
SetStringValue(output,GetStringValue(output) + '101011101000');
end

else if ((c = 71 )OR(c = 103)) then
begin
SetStringValue(output,GetStringValue(output) + '111011101000');
end

else if ((c = 72 )OR(c = 104)) then
begin
SetStringValue(output,GetStringValue(output) + '1010101000');
end

else if ((c = 73 )OR(c = 105)) then
begin
SetStringValue(output,GetStringValue(output) + '101000');
end

else if ((c = 74 )OR(c = 106)) then
begin
SetStringValue(output,GetStringValue(output) + '1011101110111000');
end

else if ((c = 75 )OR(c = 107)) then
begin
SetStringValue(output,GetStringValue(output) + '111010111');
end

else if ((c = 76 )OR(c = 108)) then
begin
SetStringValue(output,GetStringValue(output) + '101110101000');
end

else if ((c = 77 )OR(c = 109)) then
begin
SetStringValue(output,GetStringValue(output) + '1110111000');
end

else if ((c = 78 )OR(c = 110)) then
begin
SetStringValue(output,GetStringValue(output) + '11101000');
end

else if ((c = 79 )OR(c = 111)) then
begin
SetStringValue(output,GetStringValue(output) + '11101110111000');
end

else if ((c = 80 )OR(c = 112)) then
begin
SetStringValue(output,GetStringValue(output) + '10111011101000');
end

else if ((c = 81 )OR(c = 113)) then
begin
SetStringValue(output,GetStringValue(output) + '1110111010111000');
end

else if ((c = 82 )OR(c = 114)) then
begin
SetStringValue(output,GetStringValue(output) + '1011101000');
end

else if ((c = 83 )OR(c = 115)) then
begin
SetStringValue(output,GetStringValue(output) + '10101000');
end

else if ((c = 84 )OR(c = 116)) then
begin
SetStringValue(output,GetStringValue(output) + '111000');
end

else if ((c = 85 )OR(c = 117)) then
begin
//sTrace('detecte un u');
SetStringValue(output,GetStringValue(output) + '1010111000');
end

else if ((c = 86 )OR(c = 118)) then
begin
SetStringValue(output,GetStringValue(output) + '101010111000');
end

else if ((c = 87 )OR(c = 119)) then
begin
SetStringValue(output,GetStringValue(output) + '101110111000');
end

else if ((c = 88 )OR(c = 120)) then
begin
SetStringValue(output,GetStringValue(output) + '11101010111000');
end

else if ((c = 89 )OR(c = 121)) then
begin
SetStringValue(output,GetStringValue(output) + '1110101110111000');
end

else if ((c = 90 )OR(c = 122)) then
begin
SetStringValue(output,GetStringValue(output) + '11101110101000');
end

else if (c = 48 ) then
begin
SetStringValue(output,GetStringValue(output) + '10111010111010111000');
end

else if (c = 44 ) then
begin
SetStringValue(output,GetStringValue(output) + '1110111010101110111000');
end

else if (c = 47 ) then
begin
SetStringValue(output,GetStringValue(output) + '1110101011101000');
end

else if (c = 64 ) then
begin
SetStringValue(output,GetStringValue(output) + '10111011101011101000');
end

else if (c = 49 ) then
begin
SetStringValue(output,GetStringValue(output) + '10111011101110111000');
end

else if (c = 50 ) then
begin
SetStringValue(output,GetStringValue(output) + '101011101110111000');
end

else if (c = 51 ) then
begin
SetStringValue(output,GetStringValue(output) + '1010101110111000');
end

else if (c = 52 ) then
begin
SetStringValue(output,GetStringValue(output) + '10101010111000');
end

else if (c = 53 ) then
begin
SetStringValue(output,GetStringValue(output) + '101010101000');
end

else if (c = 54 ) then
begin
SetStringValue(output,GetStringValue(output) + '11101010101000');
end

else if (c = 55 ) then
begin
SetStringValue(output,GetStringValue(output) + '111011101010101000');
end

else if (c = 56 ) then
begin
SetStringValue(output,GetStringValue(output) + '111011101110101000');
end

else if (c = 57 ) then
begin
SetStringValue(output,GetStringValue(output) + '11101110111011101000');
end

else if (c = 48 ) then
begin
SetStringValue(output,GetStringValue(output) + '1110111011101110111000');
end

else if (c = 32 ) then
begin
SetStringValue(output,GetStringValue(output) + '0000');
end

else

SetStringValue(output,GetStringValue(output));

end;

end;

if (n = 1) then begin
SetStringValue(output, '');
end;

//SetStringValue(Output,stout);

end;

// no process bloc

///////////////
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

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests