Page 1 of 1

Script that outlets the date of the current day (year, month, day)

Posted: 11 Feb 2021, 09:29
by creal
Hello,

I saw some scripting functions (here: https://www.brainmodular.com/manuals/hh4/en/scripting ) about the current date and I'm wondering if anyone already has scripted a patch with 3 outlets (year, month, day), be it strings or integers, please?

creal.

Re: Script that outlets the date of the current day (year, month, day)

Posted: 14 Feb 2021, 10:10
by creal
Hello,

I tried to make a script but I'm really a noob even if years ago I learnt several languages on a basic level. Unfortunately, I just don't have the time to dive into.

I attached the script as well as a screenshot of date and time functions, taken from the official script references of Usine, available here: https://www.brainmodular.com/manuals/hh4/en/scripting

If someone has the time to tell me what's wrong with my code, I would be grateful.

Thanks,

creal.

Re: Script that outlets the date of the current day (year, month, day)

Posted: 15 Feb 2021, 09:53
by senso
hello,
No chance to compile.
A script should have an 'INIT' and a 'PROCESS' procedure

Here is the correct script, I hop it will help.

Code: Select all

//////////////////////////
// Decode date 
/////////////////////////
// declaration   


var year,month,day : Tparameter;   

// decode                                   
procedure Init;   
begin                    
 year:=CreateParam('year',ptDataField,pioOutput);
 year.MinMaxNoLimit(true);
 month:=CreateParam('month',ptDataField,pioOutput);                    
 month.MinMaxNoLimit(true);
 day:=CreateParam('day',ptDataField,pioOutput);
 day.MinMaxNoLimit(true);               
end;  
        
//PROCESS                            
PROCEDURE PROCESS();
var y,m,d : uInt16;
BEGIN   
  DecodeDate(Date,y,m,d); 
  year.asinteger(y);
  month.asinteger(m);
  day.asinteger(d);
  
END;    

Re: Script that outlets the date of the current day (year, month, day)

Posted: 15 Feb 2021, 11:57
by creal
Hello,

Thank you very much. Now I think I understand how a simple script works. It works perfectly well.

Here is the final patch for people who need it.

creal

Re: Script that outlets the date of the current day (year, month, day)

Posted: 15 Feb 2021, 12:29
by senso
tanks++++