2 weeks ago
Hello everyone!
I'm new in gdl programing and I need your help.
Is there any way to convert string into parameter name?
I want to generate variable names with "for loop" (cell_1_1, cell_1_2, cell_2_1, cell_2_2 and go on) and next use them to render text paragraphs as value of that parameters.
2 weeks ago - last edited 2 weeks ago
Have you considered using an array instead? Your naming suggests the concept of an array. Then you can just step the row.
Also, what do you mean by "as value of that parameter"? They are empty or generated based on some naming logic? If you are using the naming you have suggested to generate values, even more reason to your an array.
Ling.
AC22-28 AUS 3001 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win10 | R5 2600 | 16GB | GTX1660 |
2 weeks ago
I tried something like that:
Is array can handle it?
! Parametry podstawowe
dx = cell_width ! Szerokość komórki
dy = cell_height ! Wysokość komórki
define style{2} "JA_font_style_1" Arial, gs_font_size*5, 1
style "JA_font_style_1"
result = 1
! Rysowanie siatki tabeli
for r = 1 to row_num
for c = 1 to col_num
! Pozycje wierzchołków komórki
x1 = (c - 1) * dx
y1 = (r - 1) * dy
x2 = c * dx
y2 = r * dy
pen cell_pen
poly2 4, 5,
x1, -y1,
x2, -y1,
x2, -y2,
x1, -y2
! Generowanie nazwy parametru
param_name = "cell_" + str(c, 1, 0) + "_" + str(r, 1, 0)
! Pobranie wartości parametru za pomocą request
content = ""
result = request("parameter", param_name, content)
! Jeśli parametr istnieje i ma wartość
if result < 1 & content = "" then
! Tworzenie paragrafu
paragraph "para_" + param_name 1, 0,
0, 0, 1
pen text_pen
style "JA_font_style_1"
! Zapisujemy faktyczną wartość parametru
content
endparagraph
! Tworzenie tekstbloku
textblock "block_" + param_name 0, 7, 0, 1, 1, 0,
"para_" + param_name
! Wyświetlenie tekstu w środku komórki
richtext2 x1 + dx / 2, -y1 - dy / 2, "block_" + param_name
endif
next c
next r
2 weeks ago - last edited 2 weeks ago
So your user defines a table size, and your object draws said table and populates the cells with user defined values. Array type parameters can be used for this, and you can get it to populate to as many rows and columns as you want. Given your parameter values reflect the position within the table, it should be relatively simple to generate those too. You will also need to utilise the GLOB_MODPAR_NAME command if you want the array size to be dynamic.
*Actually, I'm not sure how you would STEP letters without resorting to manually relating each number to a letter.
AC22-28 AUS 3001 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win10 | R5 2600 | 16GB | GTX1660 |
2 weeks ago
You can not access parameters by string reference. GDL has no concept of that. It always needs to be by literal.
Some commands allow the use of strings, but those commands are mostly in the UI (see the difference between ui_infield{2}
and ui_infield{3}
as an example).
But in other contexts this is not possible.
! cell_1 => param with value of '1.5'
pname = "cell_1"
result = pname + 2.5
! ERROR
Here "pname" is just a string with the content of "cell_1". It is not a reference to the parameter with that name.
I suggest using variable sized Arrays as well.