News:

Please note new Forum URL: forum.designcad.com

Main Menu

The use of the T_TEXT Parameter

Started by Gymbo, June 09, 2019, 03:45:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Gymbo

I have a BasicCAD script that goes the and finds 16 letters and changes them to numbers using 'Change T_Text'. It works almost perfectly, but there are a couple of problems.

1. After running the macro a few times I get an invalid syntax error "Change T_Text, a$". I restart DesignCAD (ver 23, 2D) and it work fine for a few more times, and yes I update after the change.

2. probably not related to T_Text, it works perfectly for the first 15 letters but gives a false number for number 16. So I'm having trouble troubleshooting this problem because of all the interruptions with the error.
Regards,

Jim

DrollTroll

Hey Gymbo, would need to see your BasicCAD script, and maybe a 'before' sample of text to be able to provide any meaningful input.

25 years with DesignCAD

Gymbo

Thanks DT, I'll attach the part that changes the text.

for i = 1 to 16
if asc(ltr$) = ltrV(i) then
'break-> "%s, %d", ltr$, ltrV(i)
'Query T_Text, ltr$
if ltr$ = chr$(ltrV(i)) then
a$ = num(i)
end if

if ltr$ = "B" or ltr$ = "F" _
or ltr$ = "I" or i > 10 then
putattr j, 13, 0, 2, 0, 0, 0
end if
exit for
end if
next

here:
break-> "%d", i
'if ltr$ = "#" then a$ = n

Change T_Text, a$
'break-> "%d, %s, %s", num(i), ltr$, a$ 'chr$(num(i))
update
Regards,

Jim

Gymbo

Now I get the error everytime, restarting DC and even tried restarting Windows 10.

I've attached the complete macro, probably cause more questions.
Regards,

Jim

Lar


The Query line be is commented out, is that intentional? (only looked at the code insert, didn't download the file)


Lar

Lar


In the downloaded macro:


...Try putting an entity j above the Change T_Text, a$. Maybe the first (and only) entity statement is being lost somewhere in all the if/then's.


Also, like DT said, if you also post an example of the dcad file someone maybe can track down the problem.


Lar

Gymbo

Quote from: Lar on June 09, 2019, 05:20:29 PM

The Query line be is commented out, is that intentional? (only looked at the code insert, didn't download the file)


Lar
Yes I tested it both ways, didn't make a difference, should it be there?
Regards,

Jim

Lar


I realized you probably had it there for testing.


Did you try the entity thing (from my 2nd post)?


Lar

Gymbo

Quote from: Lar on June 09, 2019, 06:29:46 PM

I realized you probably had it there for testing.


Did you try the entity thing (from my 2nd post)?


Lar

Yes, it still produced the error.
Regards,

Jim

Lar

Post an example of the file you're reading from.

Gymbo

Regards,

Jim

DrollTroll

#11
I think I see your problem. Try changing your DIM statements up at the top to 16 rather than 15. You're running past the end of the arrays you've allocated when you hit 16.
In some versions of Basic, there's a '0'-indexed value, so DIM to 15 would actually give you 16 items (0-15). However, BasicCAD arrays are one-based, not zero-based, so you need to DIM to the maximum index you plan to hit.

DT
25 years with DesignCAD

Gymbo

FWIW, I rewrote the script, much simplified, and it now works, don't have a clue why it didn't, this needs a lot more work to get it to do what I want but now Change T_Text works.

'star puzzle.d3m
'6/8/2019
dim num(15)

INCLUDE "dcadalias.d3i"
Precision 0

open "I", 1, "N:\star.txt"
for i = 1 to 16
input #1, num(i)
next
i = 1
for j = 27 to 42 'sys(9)
GetAttr, j, t
entity j
ltr$ = sys$(1)
a$ = num(i)
Change T_Text, a$
update
i = i + 1
next
>FitToWindow
{
}
anykey

end
Regards,

Jim

Gymbo

Quote from: DrollTroll on June 11, 2019, 08:58:26 AM
I think I see your problem. Try changing your DIM statements up at the top to 16 rather than 15. You're running past the end of the arrays you've allocated when you hit 16.
In some versions of Basic, there's a '0'-indexed value, so DIM to 15 would actually give you 16 items (0-15). However, BasicCAD arrays are one-based, not zero-based, so you need to DIM to the maximum index you plan to hit.

DT

That did get rid of the error, thanks, I had no idea about the one-base DIM.
Regards,

Jim

DrollTroll

As a kind of fail-safe, no matter what 'flavor' of Basic I'm using, I usually DIM to the number of items I plan to use; for zero-based DIMs this may give me one extra item, but that's always better than one too few.
25 years with DesignCAD