Gluing together a set of window Template files
|
Is there a scriptable method for joining a set of window Template files into one? I can obviously drag one of them into WinEd (or WinEdit, depending on the platform) then drag the rest in, saving the result, but I would like to be able to do this from a Makefile if possible. |
|
You could turn them into text and use CCres. |
|
Ooh, yeah |
|
Alas, ccres suffers from the gccsdk-stuffing-up-under-amu’s-taskwindow problem for me. [Edit: But PD3 builds so quickly I can just invoke amu -f Makefile26 in an Obey file – et voila!] |
|
The file format looks trivial. Seems like it’d be a doddle to do. 35 minutes… not bad… 7 runs to make it work… although admittedly I’ve only tested it on merging the !Chars templates with the !Paint templates and merely eyeballed the output file but… you’re cleverer than me so you’ll probably find whether there’s problems with it easily… Shove a command line parser on it and you’re good… No promises it’ll do the job – as I say, I’ve only glanced over the output in a binary editor and it looked sane. If your template file contains ‘compressed’ indirected text that shares values between windows, it’ll almost certainly fail. If it contains font handles, it’ll fail (but you wouldn’t do that anyhow ‘cos it’s impossible to guarantee it’d work). If it contains anything other than a window object, it’ll fail. REM >TemplateJoin REM Minimalist template joining program REM REALLY quickly hacked together ON ERROR ERROR EXT ERR, REPORT$+" at line "+STR$ERL max_templates%=256 DIM template_data%(max_templates%) DIM template_datalen%(max_templates%) DIM template_name$(max_templates%) DIM temp% 24 used_templates% = 0 PROCloadfile("template1") PROCloadfile("template2") PROCsavefile("newtemplate") END DEFPROCloadfile(filename$) SYS "OS_File", 5, filename$ TO ,,,,len% DIM buf% len% SYS "OS_File", 255, filename$, buf% IF buf%!0 <> -1 THENERROR 0, "Template files shouldn't have font data in" : p%=buf% + 16 WHILE !p% <> 0 name$="" data%=buf%+p%!0 size%=p%!4 IF p%!8 <> 1 THENERROR 0, "Template contains non-window? Maybe this should be silently ignored" x%=p%+12 FORI=0TO11 IF x%?I <= 32 THENI=12 ELSEname$+=CHR$(x%?I) NEXT PROCaddtemplate(data%, size%, name$) p%+=24 ENDWHILE ENDPROC DEFPROCaddtemplate(data%, size%, name$) template_data%(used_templates%) = data% template_datalen%(used_templates%) = size% template_name$(used_templates%) = name$ used_templates% += 1 ENDPROC DEFPROCsavefile(filename$) o%=OPENOUT(filename$) IF o%=0 THEN ERROR 0, "Nope, file didn't write" REM Header temp%!0 = -1 temp%!4 = 0 temp%!8 = 0 temp%!12 = 0 SYS "OS_GBPB", 2, o%, temp%, 16 dataptr% = 16 + 24 * used_templates% + 4 REM Index entries FOR I = 0 TO used_templates%-1 temp%!0 = dataptr% temp%!4 = template_datalen%(I) temp%!8 = 1 $(temp%+12) = template_name$(I) SYS "OS_GBPB", 2, o%, temp%, 24 dataptr% += template_datalen%(I) NEXT REM Index terminator temp%!0=0 SYS "OS_GBPB", 2, o%, temp%, 4 REM Each template block FOR I = 0 TO used_templates%-1 SYS "OS_GBPB", 2, o%, template_data%(I), template_datalen%(I) NEXT CLOSE#o% SYS "OS_File", 18, filename$, &FEC ENDPROC |
|
Works a treat – thank you! |
|
Thank you for introducing me to ccres.
I don’t have this problem with my ARMX6…. |
|
Thanks, I’ll give that a whirl when I am back in there… Compiling with Norcroft will help. It’s what I have to do with sed to get that to work under !Amu. [Edit: Jean-Michel’s ccres build works well for me – thank you!] |