I would like to create custom variable for theos. In example ##DATECREATED## to print current date for my tweak deceptions (I'm soooo bored to edit it manually :D)
Like ##FULLPROJECTNAME## prints out tweak name in control and Makefile...
Edit: I did it with adding this to my nic.pl:
use DateTime;
$NIC->variable("DATECREATED") = DateTime->now->strftime('%d/%m/%Y');
Is it possible to do it without editing original nic.pl?
Thanks for suggestions!
I have found a solution for it!
I had to put this code inside control.pl in my theos template:
use DateTime;
NIC->variable("DATECREATED") = DateTime->now->strftime('%d/%m/%Y');
Related
I'm using pykeepass to do bulk modification on several hundred keepass files and I'd like to add some additional attributes to the keepass entries.
I tried to do it like this:
def updateRecord(record, recordParent, recordGrandparent, recordGreatGrandparent, kdbxHandle):
record.custom_properties["keepass2"] = recordGrandparent
record.custom_properties["keepass3"] = recordGreatGrandparent
kdbxHandle.save()
return record
but this has zero effect (no error message no nothing). From my understanding record.custom_properties is a dict which I should be able to modify.
What do I have to do, to add additional attributes to a keepass file with pykeepass?
Thank you!
Ok I can answer my own question - setting a custom property is done like this:
record.set_custom_property("keepass2", recordGrandparent)
I am trying to create snippet where must be displayed the name of the current file
I tried to do this:
<content><![CDATA[Hello, this is a $file_name]]></content>
But it does not work
I found the answer. I did it like this:
<content><![CDATA[Hello, this is a $TM_FILENAME]]></content>
I am dynamically displaying sermons from a MYSQL database, and I want to create a dynamic page for each sermon series. Because the series titles have spaces in them, and I want to avoid that in my URLs, I have done str_replace:
(Series name)
That works great. But then of course on the dynamically-created page, I need a way to revert back to the original series name in order to fetch the actual sermon data, and I haven't figured out to how to accomplish that. I've tried this:
$series = $_GET['series'];
$str = $series;
$str = str_replace("-"," ",$str);
... ahead of my prepare & execute statements (I'm using PDO), but that doesn't really look right, and in any case doesn't work.
Is there actually a way to this?
I just needed to change one variable. The lead variable of the third line needed to be $series, not $str:
$series = $_GET['series'];
$str = $series;
$series = str_replace("-"," ",$str);
I have a mathematical model and I want to run it 10 times automatically with different data sets which are generated randomly(when the first model stops, start another model automatically). for this purpose I have written the solve statement in a loop . I want to see the result of these 10 models in different sheets of an excel file. how can I do it? is it possible to correct my code?
set k/sheet1*sheet10/;
loop(k,
data generation....
solve statement....
execute_unload 'RESULT.gdx'
execute 'gdxxrw.exe RESULT.gdx o=RESULT.xlsx var=x.l rng='k.t1:0'!a1'
);
I really appreciate your kind helps
Actually, you are pretty close already, you just need to use 'put_utility' instead of 'execute' to make use of the 'k.tl' syntax (note: it is .tl, not .t1):
*dummy put file
file fx; put fx;
set k/sheet1*sheet10/;
loop(k,
solve statement....
execute_unload 'RESULT.gdx'
put_utility 'exec' / 'gdxxrw.exe RESULT.gdx o=RESULT.xlsx var=x.l rng='k.tl:0'!a1';
);
I hope that helps!
Best regards,
Lutz
I need my [[+idx]] tv to start at 0 instead of 1 so I tried this:
[[+idx:decr]] or [[+idx:substract=1]] but it gives me -1 (minus one).
Does anyone know another way to obtain 0?
Thank you
Using this in chunk for getImageList works (at least for me):
[[+idx:decr]]
It gives: 0,1,2,3 ....
P.S. using modx revo 2.3.1
set your template variable default to 0 when you create the variable.
What are you trying to do, your question is vague at best.
UPDATE
ok - what I think will work for you is to write a snippet to do the math... where ever you call the [[+idx]] instead write a snippet
[[!FixIDX? &itemindex=`[[+idx]]`]]
then in your FixIDX snippet just do the math with php and return the corrected index. Though perhaps a custom output modifier would be the better way to go: http://rtfm.modx.com/display/revolution20/Input+and+Output+Filters+(Output+Modifiers)
Though looking at the docs, your code should certainly work - I see no reason for it not to.