jw_cad 外部変形 - (996) gccで線種を取得する(lt) -

外部変形は データのやり取りをテキストファイルで行うので プログラム言語は 自由に選ぶことができます。図形は機能的かつシンプルなため、数多くのユーザーに受け入れられています。

 

gccで線種を取得する(lt)

:gccで線種を取得する(lt)
@echo off
if not exist %~dpn0.exe (
  for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
    more +%%n %0 > %~dpn0.c
    gcc -Os %~dpn0.c -o %~dpn0.exe -s
  )
)
%~dpn0
goto:eof

REM #jww
REM #e

#!この次の行からプログラムを書いてください
#include "jw.h"
int main(void)
{
  FILE *f;
  int n;
  char S_[256], *F[20];
  char lt[4], plt[4];
  int flg = 0;
  if ( (f = fopen("jwc_temp.txt", "r")) != NULL) {
    while (fgets(S_, 256, f) != NULL) {
      split(chomp(S_), F);
      if (strncmp(S_, "lt", 2) == 0) {
        n = strlen(S_);
        substr(S_, 2, n-1, plt);
        if (flg == 0) { strcpy(lt, plt); flg = 1; }
      }
    }
  } else {
    exit(MISSING_JWC_TEMP_TXT);
  }
  fclose(f);
  f = fopen("jwc_temp.txt", "w");
  fprintf(f, "h#lt=%s\n", lt);
  fclose(f);
  return 0;
}