first char of stack
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
first char of stack
Hi
Another small issue
Is it possible to identify a stack with only the first charater of the name
eg literally:
stack whose first character begins with an L.
Pascal
Another small issue
Is it possible to identify a stack with only the first charater of the name
eg literally:
stack whose first character begins with an L.
Pascal
Re: first char of stack
Hi Pascal,
this is more a logical that a Livecode problem
Programming is about finding a solutiuon to a logical problem first and THEN
translate this solution to a language that your machine will understand.
Try to solve the problem WITHOUT a computer first, instead pretend to only have
a piece of paper, with a list of (stack) names on it***, one name per line, and a pencil.
' This list is MANDATORY for this problem!
Now how do you elimintate all nems (lines) that do not begin with an L?
Exactly, you can
1. strike out all names/lines that do NOT begin with an L
or
2. immediately pick the name that begins with L
Well, this is the problem and its solution, now you need to translate this into Livecode.
Hints: Use filter (1) or "lineoffset" (2) to extract the correct LINE from your list
Check also my little "Memory" stack to see another example of this "real life" logical approach to a problem:
http://www.major-k.de/xtalk.html
Scroll down to "simple_memory1"
Best
Klaus
this is more a logical that a Livecode problem

Programming is about finding a solutiuon to a logical problem first and THEN
translate this solution to a language that your machine will understand.
Try to solve the problem WITHOUT a computer first, instead pretend to only have
a piece of paper, with a list of (stack) names on it***, one name per line, and a pencil.
' This list is MANDATORY for this problem!
Now how do you elimintate all nems (lines) that do not begin with an L?
Exactly, you can
1. strike out all names/lines that do NOT begin with an L
or
2. immediately pick the name that begins with L
Well, this is the problem and its solution, now you need to translate this into Livecode.
Hints: Use filter (1) or "lineoffset" (2) to extract the correct LINE from your list

Check also my little "Memory" stack to see another example of this "real life" logical approach to a problem:
http://www.major-k.de/xtalk.html
Scroll down to "simple_memory1"
Best
Klaus
Re: first char of stack
Hi Klaus
It is true that I was not very accurate.
I'm still working on the links between stacks them.
I seek only the means to go to a stack whose first Character name is a L.
For the proposed link to
Pascal
It is true that I was not very accurate.
I'm still working on the links between stacks them.
I seek only the means to go to a stack whose first Character name is a L.
For the proposed link to
Sorry, i can't read files with .mcCheck also my little "Memory" stack to see another example of this "real life" logical approach to a problem:
Pascal
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: first char of stack
In LC, use File->Open Stack.pascalh4 wrote:Sorry, i can't read files with .mc
While double-clicking a .mc file may not always launch LC, the filters used in the menu item include .mc in both the Commercial and Community editions.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: first char of stack
Yep, or simply change the MC file suffix to REV or LIVECODE 

Re: first char of stack
hi
Thank you I opened the file, I will read it and see if " je trouve mon bonheur". (French expression that means: I find what I want)
and for the topic "text adapt", can you advise me where to look.
Pascal.
Thank you I opened the file, I will read it and see if " je trouve mon bonheur". (French expression that means: I find what I want)
and for the topic "text adapt", can you advise me where to look.
Pascal.
Re: first char of stack
Bonjour Pascal.
OK, to be clear, my little Memory stack has nothing to do with your current problem here!
Did you understand my example with a piece of paper & pencil? No?
Best
Klaus
OK, to be clear, my little Memory stack has nothing to do with your current problem here!
Did you understand my example with a piece of paper & pencil? No?
Best
Klaus
Re: first char of stack
hi late, ... or early
yes I think I understand.
The cutting portion of reasoning help me to code better.
In your example, this is more difficult for me, but I understood the logic of progress.
Back to my problem: Identifying by the first character of a stack, allows me to create a loop for copying, in two mainstack (the first character as constant and the other characters, numbers, allows me to classify the stack: with the principle discussed in the topic "previous next stack")
Soon
Pascal
yes I think I understand.
The cutting portion of reasoning help me to code better.
In your example, this is more difficult for me, but I understood the logic of progress.
Back to my problem: Identifying by the first character of a stack, allows me to create a loop for copying, in two mainstack (the first character as constant and the other characters, numbers, allows me to classify the stack: with the principle discussed in the topic "previous next stack")
Soon
Pascal
Re: first char of stack
there' s the "begins with" modifier that you can use with an if statement.
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Re: first char of stack
Hi,
Thank you for that, but I still can not write a decent script.
Here's what I want to do:
given:
Mainstack, name "Base" with button
Substack, name "L ...."
Action:
Button click , into stack "Base", go to stack begins with "L"
Here's what I wrote:
it does not work.
that either.
For you, the error must be clear.
But not for me.
Can you tell me, where to find explanations that help me.
Pascal
Thank you for that, but I still can not write a decent script.
Here's what I want to do:
given:
Mainstack, name "Base" with button
Substack, name "L ...."
Action:
Button click , into stack "Base", go to stack begins with "L"
Here's what I wrote:
Code: Select all
on mouseUp
if name of stack into this stack begins with "S" then
go to stack it
end if
end mouseUp
Code: Select all
if name of stack into this stack begins with "S" then
on mouseUp
go to stack it
end mouseUp
end if
For you, the error must be clear.
But not for me.
Can you tell me, where to find explanations that help me.
Pascal
Re: first char of stack
in the help menu, there's an entry called "user guide". It opens a pdf. I suggest you read that.
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Re: first char of stack
hi,
I've downloaded it and I've looked, but the chapter 5.7.1 "If ... then ... else" doesn't help me much.
Pascal
I've downloaded it and I've looked, but the chapter 5.7.1 "If ... then ... else" doesn't help me much.
Pascal
Re: first char of stack
Hi Pascal,
what Björnke means, is that you are missing the most basic things of Livecde
but they are very neccessary to be able to use Livecode!
Do not use any syntax if you are not sure what it does, or if it even exists!
Check these stacks to get the basics about stacks, substacks, cards, objects etc...:
Please do in you own interest!
OK, I will explain the "real life" analogy from my first posting here:
1. The list of stacks is MANDATORY as I wrote, and I guess you mean the SUBSTACKS** of your mainstack, right?
** C'est le mot magique ici!
The you can:
...
put the substacks of stack"Base" into tSubStackList
## Now you have a CR delimited list of all the substacks of your mainstack (Base) in the variable
...
2. See which of these lines start with an L or whatever character:
...
put "L" into tFirstCharacter
## You can use LINEOFFSET or FILTER
## I use FILTER here, which will remove ALL lines that do NOT begin with that character
filter tSubStackList with (tFirstCharacter & "*")
## If you have prepared everything correctly (NOT 2 substacks with the same first character in name etc...) you can now:
go stack tSubStackList
## the list should only contain ONE line -> the name of the substack that begins with L
...
3. Now all together for your button script:
See how the logical principles of "real life" can be "tranlsated" into Livecode easily?
But you need to analyze and understand them first AND to underatand the language
of Livecode to be able to tranlate them at all!!
If you do not know the word for that round leather thing that you can kick with your foot,
then you cannot translate it into another language
Try to digest and UNDERSTAND what I am doing here.
After you "got" it, we will create a FUNCTION for this,
where you only need to supply the first desired chracter.
But not now!
Best
Klaus
what Björnke means, is that you are missing the most basic things of Livecde
but they are very neccessary to be able to use Livecode!
if name of stack into this stack begins with "S" then
Do not use any syntax if you are not sure what it does, or if it even exists!

Check these stacks to get the basics about stacks, substacks, cards, objects etc...:
Code: Select all
http://www.hyperactivesw.com/revscriptconf/scriptingconferences.html
OK, I will explain the "real life" analogy from my first posting here:
1. The list of stacks is MANDATORY as I wrote, and I guess you mean the SUBSTACKS** of your mainstack, right?
** C'est le mot magique ici!

The you can:
...
put the substacks of stack"Base" into tSubStackList
## Now you have a CR delimited list of all the substacks of your mainstack (Base) in the variable
...
2. See which of these lines start with an L or whatever character:
...
put "L" into tFirstCharacter
## You can use LINEOFFSET or FILTER
## I use FILTER here, which will remove ALL lines that do NOT begin with that character
filter tSubStackList with (tFirstCharacter & "*")
## If you have prepared everything correctly (NOT 2 substacks with the same first character in name etc...) you can now:
go stack tSubStackList
## the list should only contain ONE line -> the name of the substack that begins with L
...
3. Now all together for your button script:
Code: Select all
on mouseup
put the substacks of stack"Base" into tSubStackList
put "L" into tFirstCharacter
filter tSubStackList with ("*" & tFirstCharacter)
## Better check once to much thatn getting an error!
if tSubStackList = empty then
exit mouseup
end if
## Finally go to the stack:
go stack tSubStackList
end mouseup
But you need to analyze and understand them first AND to underatand the language
of Livecode to be able to tranlate them at all!!
If you do not know the word for that round leather thing that you can kick with your foot,
then you cannot translate it into another language

Try to digest and UNDERSTAND what I am doing here.
After you "got" it, we will create a FUNCTION for this,
where you only need to supply the first desired chracter.
But not now!

Best
Klaus
Re: first char of stack
Thank you to everyone and everything
I'll try (mouliner) dissect these informations.
I also downloaded LC University PE, I think the explanation is quite simple (and it's good for my spoken English, too). If it suits me, I buy a full version.
Soon
But now I think I have (du boulot sur la planche) work to be done.
Pascal
I'll try (mouliner) dissect these informations.
I also downloaded LC University PE, I think the explanation is quite simple (and it's good for my spoken English, too). If it suits me, I buy a full version.
Soon
But now I think I have (du boulot sur la planche) work to be done.
Pascal
Re: first char of stack
Hi Klaus
or not 2 with the same name ?
If I can not use more than once substack with the same first character, there is no point to take it as a reference! No?
Is it the variable that we must place first (as in the explanation and not the code)?
Pascal
not 2 with the same first character in nameIf you have prepared everything correctly (NOT 2 substacks with the same first character in name etc...) you can now:
or not 2 with the same name ?
If I can not use more than once substack with the same first character, there is no point to take it as a reference! No?
In your code## I use FILTER here, which will remove ALL lines that do NOT begin with that character
filter tSubStackList with (tFirstCharacter & "*")
on mouseup
put the substacks of stack"Base" into tSubStackList
put "L" into tFirstCharacter
filter tSubStackList with ("*" & tFirstCharacter)
Is it the variable that we must place first (as in the explanation and not the code)?
Pascal