Plot 的命名

  •   274 
  • 最後發表   steatng  2022 四月 28
steatng 發文於   2022/04/14

Hi 各位前輩

我目前是透過以下方式去畫多條線

Array: test[20](0);
Vars: for_index(0);

For for_index = 1 to 20
Begin
    test[for_index] = for_index+for_index;
End;

For for_index = 1 to 20
Begin
    IF test[for_index] > 10 then
    Begin
        IF for_index = 1 then plot(1, test[for_index], "第1條線");
        IF for_index = 2 then plot(2, test[for_index], "第2條線");
        .
        .
        .
        IF for_index = 20 then plot(20, test[for_index], "第20條線");
    End;
End;

但是下方畫線的部分有點繁瑣,我希望可以透過 For 迴圈的特性簡化成以下方式

Array: test[20](0);
Vars: for_index(0);

For for_index = 1 to 20
Begin
    test[for_index] = for_index+for_index;
End;

For for_index = 1 to 20
Begin
    IF test[for_index] > 10 then
    Begin
        IF for_index = 1 then plot(for_index, test[for_index], "第"for_index"條線");
    End;
End;

 

但是我目前遇到兩個問題

第一個問題

如果我將 plot(1, tes.... 的數字改成變數。例如 plot(for_index, tes.... 。 編譯會發生錯誤,錯誤訊息為「函數 plot: 第1個參數必須介於 1 到 999。」,沒辦法將數字用變數代替,請問有相關解法嗎 ?

第二個問題

是字串的相連,像是 ... est[for_index], "第"for_index"條線")... 我想要將 「"第"for_index"條線"」相連起來,假設 for_index 現在的值是19 那該跟線就會被命名稱 「第19條線」,請問有相關解法嗎?

 

謝謝

排序方式: 標準 | 最新
XQ小幫手 發文於   2022/04/21

Hello steatng,

 

1.就小幫手所知,這應該沒辦法,只能用直接輸入的方式。(ex. plot(1, value1, "畫出value1的值"))

 

2.您可以使用 text 函數。

steatng 發文於   2022/04/21

Hi 小幫手

Text 似乎沒辦法使用在 Plot 

我使用過兩種方式帶入

1. 直接將 Text() 帶入 plot 內

plot(1, 123, Text("a", "b", 123));

錯誤訊息為:顯示 plot 參數錯誤: Text(a, b, 123)。

2. 透過變數傳入

Vars: str("");

str = Text("a", "b", 123);

plot(1, 123, str);

錯誤訊息為:顯示 plot 參數錯誤: 。

 

請問該如何修正呢?

 

XQ小幫手 發文於   2022/04/28

Hello steatng,

 

您可以使用 text 函數來達到字串相連的結果。

但是就小幫手所知plot命名的參數只能是一個固定字串,必須用直接輸入的方式。

所以沒辦法使用 text 來組合。

發表回覆
Close