Welcome to %s forums

BrainModular Users Forum

Login Register

display in Hexadecimal !

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

Unread post by oli_lab » 09 Jul 2014, 01:10

Hi all !
I know that one is a far cry, but would anyone had already made a script that translate decimal numbers into HEX?
I'm experimenting with RFID tags...

thanks

Olivar
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

caco
Member
Posts: 306
Contact:

Unread post by caco » 11 Jul 2014, 22:11

How about this? Note that it will round your input down to an integer prior to the conversion to hex so you may lose some precision..

Code: Select all

//////////////////////////////////////////////////////
// Int to Hex 
//////////////////////////////////////////////////////

//////////////////////////////////////////////////////
// Paramters declaration
//////////////////////////////////////////////////////
var input : Tparameter;
var output: Tparameter;

//////////////////////////////////////////////////////
// initialisation procedure
//////////////////////////////////////////////////////
procedure init;
begin  
 input := CreateParam('input', ptDatafader);
 SetIsOutput(input,false);
 SetMin(input, 0); 
 SetMax(input, 2048);                                
 SetSymbol(input,'');
 SetDefaultValue(input,10);
 SetValue(input,10);

 output := CreateParam('output',ptTextField);
 SetIsInput(output,false);
 SetMin(output,0);      
 SetMax(output,100);
 SetSymbol(output,'');
 SetDefaultValue(output,10);
                                                    
end;                      

// Global Variables
var inval : single;

//////////////////////////////////////////////////////
// Main Loop procedure
//////////////////////////////////////////////////////
Procedure Callback(N:integer);
begin              
 inval := getValue(input);
 setstringvalue(output, IntToHex(Trunc(inval)));
end;

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

Unread post by oli_lab » 12 Jul 2014, 11:17

Thanx 0xFFFF times !

Now I can display the RFID tag in HEX, just like on my phone !

Those RFID Tags will be used to change patches and preset in Hollyhock

Code: Select all

//////////////////////////
// Array values (INTEGERS) to HEX commaText
/////////////////////////          
CONST MAX_ITEMS = 8;
var ArrayIn, CommaOUT: Tparameter;
var SL1: TstringList;
/////////////////////////////
procedure init;
var i: integer;                      
begin                        
  SetModuleColor($808080+302060);   
  ArrayIn:= CreateParam('ArrayIn', PtArray);
  SetIsOutput(ArrayIn,False); SetMin(ArrayIn,0); setMax(ArrayIn,MAXINT);

  CommaOUT:= CreateParam('CommaOUT',PtTextField);
  setisINPUT(commaOut,false);
   
  SL1.create;
                    
END;//INIT
///////////////////////////////////////////
Procedure Callback(N:integer);                      
var i, L: integer; 
var s : string; 
begin         
                  
      if (n=ArrayIn)        
      then begin                                   
         SL1.Clear;      
         L:= getLength(ArrayIn);     
         if L< MAX_ITEMS 
         then begin
            For i&#58;= 0 to L-1 
            do begin
               s &#58;= IntToHex&#40;trunc&#40;getDataArrayValue&#40;ArrayIn,i&#41;&#41;&#41;;
               SL1.add&#40;s&#41;;                     
            end;                                                        
         setStringValue&#40;CommaOut,SL1.GetCommatext&#41;;   
       end;                                   
      end;
END;//CB
////////////////////////////////////////
Procedure Destroy;
begin
SL1.free;
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

Post Reply

Who is online

Users browsing this forum: No registered users and 85 guests