Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2 questions (Q1: script not working and Q2: dynamic vars)
#1
I have 2 questions.

Question 1:
I have a script that outputs "a" to "z" strings, in the following way

a
.
.
z
==== next cycle
aa
ab
.
.
az
==== next cycle
aba
abc
abd
.
.
abz
==== somewhere in final cycle
abcde
abcde
abcde

But somewhere in the final cycle the string misses characters, it should be

abcdea
abcdeb
.
.
abcdez

My script:

Macro Macro17
Code:
Copy      Help
str s="abcdefghijklmnopqrstuvwxyz"
int i t1 t2
str x=" "

;;Each letter in charactercode array
ARRAY(int) b.create(s.len)
for(i 0 b.len)
,b[i]=s[i]

;;to output window strings:  
;;a...z, aa ab ac...az, aba abc abd... abz,  ...etc

for t1 0 7
,for t2 0 b.len        
,,if(t1=0)
,,,x[0]=b[t2]                
,,else
,,,x.fix(x.len+1)
,,,x[t1-1]=b[t1-1]
,,,x[t1]=b[t2]
,,out x


Is it because 'x.fix' ?
Quote:Must not exceed the number of bytes in the string buffer (nc property).




Question 2:
is it possible to dynamically create variables and arrays:

Macro Macro19
Code:
Copy      Help
int i
for i 0 3
,str si

I should have 3 variables: s0, s1, s2

Macro Macro19
Code:
Copy      Help
int i
for i 0 3
,ARRAY(str) si

I should have 3 arrays: s0, s1, s2

The code off course is totally wrong, but I only want to clarify the question.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)