Author Topic: The use of the T_TEXT Parameter  (Read 100 times)

Gymbo

  • Jr. Member
  • **
  • Posts: 88
The use of the T_TEXT Parameter
« on: June 09, 2019, 03:45:54 PM »
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

  • Kindly Curmudgeon
  • Administrator
  • *****
  • Posts: 4263
Re: The use of the T_TEXT Parameter
« Reply #1 on: June 09, 2019, 03:55:03 PM »
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

  • Jr. Member
  • **
  • Posts: 88
Re: The use of the T_TEXT Parameter
« Reply #2 on: June 09, 2019, 04:02:03 PM »
Thanks DT, I'll attach the part that changes the text.

Code: [Select]
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

  • Jr. Member
  • **
  • Posts: 88
Re: The use of the T_TEXT Parameter
« Reply #3 on: June 09, 2019, 04:32:24 PM »
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

  • Hero Member
  • *****
  • Posts: 2890
Re: The use of the T_TEXT Parameter
« Reply #4 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

Lar

  • Hero Member
  • *****
  • Posts: 2890
Re: The use of the T_TEXT Parameter
« Reply #5 on: June 09, 2019, 06:17:01 PM »

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

  • Jr. Member
  • **
  • Posts: 88
Re: The use of the T_TEXT Parameter
« Reply #6 on: June 09, 2019, 06:20:42 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

  • Hero Member
  • *****
  • Posts: 2890
Re: The use of the T_TEXT Parameter
« Reply #7 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

Gymbo

  • Jr. Member
  • **
  • Posts: 88
Re: The use of the T_TEXT Parameter
« Reply #8 on: June 10, 2019, 08:27:40 AM »

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

  • Hero Member
  • *****
  • Posts: 2890
Re: The use of the T_TEXT Parameter
« Reply #9 on: June 10, 2019, 09:19:00 AM »
Post an example of the file you're reading from.

Gymbo

  • Jr. Member
  • **
  • Posts: 88
Re: The use of the T_TEXT Parameter
« Reply #10 on: June 10, 2019, 09:32:47 AM »
No problem.
Regards,

Jim

DrollTroll

  • Kindly Curmudgeon
  • Administrator
  • *****
  • Posts: 4263
Re: The use of the T_TEXT Parameter
« Reply #11 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
« Last Edit: June 11, 2019, 09:00:42 AM by DrollTroll »
25 years with DesignCAD

Gymbo

  • Jr. Member
  • **
  • Posts: 88
Re: The use of the T_TEXT Parameter
« Reply #12 on: June 11, 2019, 09:04:15 AM »
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.

Code: [Select]
'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

  • Jr. Member
  • **
  • Posts: 88
Re: The use of the T_TEXT Parameter
« Reply #13 on: June 11, 2019, 09:08:23 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

  • Kindly Curmudgeon
  • Administrator
  • *****
  • Posts: 4263
Re: The use of the T_TEXT Parameter
« Reply #14 on: June 11, 2019, 09:50:49 AM »
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