×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

declare variable so can be uased as

declare variable so can be uased as

declare variable so can be uased as

(OP)
is it possible to declare a variable so it can hold text or number?
I thought "dim variablename as variable" would work but it seems not?

thank you
smiler44

RE: declare variable so can be uased as

Hi,

As VARIANT

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: declare variable so can be uased as

(OP)
Variant, thank you Skip. Could you give me some more advice? Is it possible to get a number that is stored in a variable that has been declared as a string to be reconized in another variable as a number by going something like

dim firstvar as string
dim secndvar as variant
dim thiordvar as integer


firstvar = "12"

secondvar = firstvar

thirdvar = secondvar - 6


smiler44

RE: declare variable so can be uased as

Did you try it, and if so, what were your results?

Keep in mind, however, that the data that your get from your screen is ALL TEXT. Yes, there are numeric characters, but they are characters, and not numbers.

Those areas of your screen that do represent numeric data, can then be converted to numbers of whatever type is appropriate, if you need to use them for arithmetic calculations.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: declare variable so can be uased as

(OP)
Skip this is the weakest excuse you will hear but is true. I broke my glasses and my screen is to small to read without glasses. should get new pair this week and so can try it then.

smiler44

RE: declare variable so can be uased as

Well try not to make a spectacle of yourself. winky smile

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: declare variable so can be uased as

skip,

very funny!

RE: declare variable so can be uased as

(OP)
I'm not sure if my method of going from string to variant to integer works.

I'm using

nameofstring = Sess0.screen.Getstring(9, 12, 3)

my string is the "number" 218 but the integer is 14287066

I seem to recall integers are a bit funny but can you help?

thanks
smiler44

RE: declare variable so can be uased as

Quote:

my string is the "number" 218 but the integer is 14287066

your string is the digits or characters "218"

how did you get from "218" to 14287066???

Where is your code?

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: declare variable so can be uased as

(OP)
skip,
i'll post over the weekend. have shut laptop down now but please.... watch this space

smiler44

RE: declare variable so can be uased as

(OP)
this is how I have tried to convert a string to integer
Sess0.Screen.GetString(9, 64, 3) gets 218 from the screen. when I stop trough the code and move off of newp = newppp
newp changes from 218 to 14287066??? No idea what's going wrong

smiler44


my code is

Global declarations
dim newpp as string
dim newppp as variant
dim newp as integer


newpp = Sess0.Screen.GetString(9, 64, 3)
newpp = trim(newpp)
newppp = newpp
newp = newppp

RE: declare variable so can be uased as

What happens when you view the value of newpp just before you assign newppp?

I used your code, but I just assigned "218" rather than GetString and got 218 in all variables!!!

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: declare variable so can be uased as

(OP)
I have stepped through the code. newpp = "218" newppp = 218 and newp = 218

My user wants to look through all the pages of notes to find a word. They type the required word at the top of the screen. The macro captures the word, works out how many pages there are and then starting at the last page steps through each page looking for the word. when it finds 20 instances or gets to the first page it then displays its findings. This all works ok. if there are more then 20 instances the user can select to look at the next lot of instances, i'm refining this but it did work


The user can select which instance they want to look at. On the order I am playing with there are 218 pages of notes to look through. if the user selects an instance of the required word that is on page 50, the macro goes to the last page, page 218 and then pages backwards to page 50. this is time consuming. there is a way to show the notes, with I think 13 notes per page. By pressing the PF8 key the next page of 13 notes is selected. the user can them select the spicefic note they want to see. I am trying to get the macro to work that as there are 218 pages of notes and 13 listed notes to a page, it has to press the f8 key 14 times, select the top note which I think is note 49 then press pf8 once to get to not 50.

It is this working out I am stuck on.
stepping through the code below when it steps past the line of code secondfound = newp for some reason firstfound = newp changes from firstfound being 218 to 14287066. I have not gone beyond this point.



I have taken to posting all of the code below.

smiler44

' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$


dim totalpages as string ' total number of pages of notesvar as strin
dim currentnote as string 'INTEGER current note
dim lastnote as string 'integer
dim foundonpage as string
dim lwtf as string ' word to find before timmed to remove right spaces
dim wtf as string ' word to find one trimmed
Dim mycol as string
dim screenrow as string ' row word found used for preparedialog sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dim ltp as string 'long total page
dim stp as string 'short total page, after ltp has been trimmed

dim lcn as string ' long current note
dim scn as string 'short current note

dim lln as string ' long last note
dim sln as string ' short last note

dim lfop as string ' long found on page
dim sfop as string 'short found on page

'''''''''''''''''''''''''''''''''''''''''''''''''''''

dim newpp as string
dim newppp as variant
dim newp as integer ' found on page used to help go to the users chosen page
dim ppage as integer ' total number ofpages



dim firstfound as integer
dim secondfound as integer
dim thirdfound as integer
dim fourthfound as integer
dim fifthfound as integer
dim sixthfound as integer
dim seventhfound as integer
dim eighthfound as integer
dim ninthfound as integer
dim tenthfound as integer
dim eleventhfound as integer
dim twelfthfound as integer
dim thirteenth as integer
dim fourteenthfound as integer
dim fifteenthfound as integer
dim sixteenthfound as integer
dim seventeenthfound as integer
dim eighteenthfound as integer
dim nineteenthfound as integer
dim twentiethfound as integer


dim firstpagefound as string
dim secondpagefound as string
dim thirdpagefound as string
dim fourthpagefound as string
dim fifthpagefound as string
dim sixthpagefound as string
dim seventhpagefound as string
dim eighthpagefound as string
dim ninthpagefound as string
dim tenthpagefound as string
dim eleventhpagefound as string
dim twelfthpagefound as string
dim thirteenthpagefound as string
dim fourteenthpagefound as string
dim fifteenthpagefound as string
dim sixteenthpagefound as string
dim seventeenthpagefound as string
dim eighteenthpagefound as string
dim nineteenthpagefound as string
dim twentiethpagefound as string

dim firstrowfound as string 'what row the word was found on
dim secondrowfound as string
dim thirdrowfound as string
dim fourthrowfound as string
dim fifthrowfound as string
dim sixthrowfound as string
dim seventhrowfound as string
dim eighthrowfound as string
dim ninthrowfound as string
dim tenthrowfound as string ' what page the found was found on
dim eleventhrowfound as string
dim twelfthrowfound as string
dim thirteenthrowfound as string
dim fourteenthrowfound as string
dim fifteenthrowfound as string
dim sixteenthrowfound as string
dim seventeenthrowfound as string
dim eighteenthrowfound as string
dim nineteenthrowfound as string
dim twentiethrowfound as string

dim sentance as string
dim firstsentance as string
dim secondsentance as string
dim thirdsentance as string
dim fourthsentance as string
dim fifthsentance as string
dim sixthsentance as string
dim seventhsentance as string
dim eighthsentance as string
dim ninthsentance as string
dim tenthsentance as string
dim eleventhsentance as string
dim twelfthsentance as string
dim thirteenthsentance as string
dim fourteenthsentance as string
dim fifteenthsentance as string
dim sixteenthsentance as string
dim seventeenthsentance as string
dim eighteenthsentance as string
dim nineteenthsentance as string
dim twentiethsentance as string



dim page as string 'chosen page/note to look at
dim row as string 'chosen note to look at

dim w as integer 'width of dialog box
dim h as integer 'height of dialog box

declare sub prepair() 'keeps a note of what page and row the word was found on
declare sub userchoice() 'gos to the page the usr has selected
declare sub create()
declare sub resetv()


Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions

If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
g_HostSettleTime = 500 '1000 ' milliseconds

OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If

' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)


Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object

Set Sys = CreateObject("EXTRA.System")
' Assumes an open session
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen



' This section of code contains the woking code




resetv ' resets the values of variables


Sess0.Screen.Sendkeys ("<Home>")

lwtf = Sess0.Screen.Getstring(1, 2, 6) ' word to find

if lwtf = " " then
msgbox (" No word has been entered, search can not continue")

exit sub
end if


wtf = trim(lwtf) ' trims the missing spaces from the right

' convert to upper case
wtf = UCase(wtf) 'convets to upper case


Sess0.Screen.Sendkeys ("<Home>")
Sess0.Screen.Sendkeys("<ERASEEOF>")
Sess0.Screen.Sendkeys ("daj<Enter>")
Sess0.Screen.Sendkeys ("s<Home>")
Sess0.Screen.Sendkeys ("ln<enter>")
Sess0.Screen.Sendkeys ("s<enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
totalpages = Sess0.Screen.GetString(9, 71, 3)
totalpages = trim(totalpages)


currentnote = Sess0.Screen.GetString(9, 64, 3)
currentnote = trim(currentnote)

do until currentnote = totalpages ' makes sure you go to last page before searching

if currentnote < totalpages then
Sess0.Screen.Sendkeys("<Pf8>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
currentnote = Sess0.Screen.GetString(9, 64, 3)

end if
loop


do until currentnote = "1" ' works from last page to page 1

' This will find the location of the searched for word

Set MyArea = MyScreen.Search(wtf) 'finds first instance of word to find
MyScreen.MoveTo MyArea.Bottom, MyArea.Right - 1 ' as system is 6 charectors long this pust the cusrosor at 1st charector

Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
if myscreen.col = 1 then ' word not found

Sess0.Screen.Sendkeys("<Home><Pf7>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
currentnote = Sess0.Screen.GetString(9, 64, 3)
currentnote = trim(currentnote)

lastnote = Sess0.Screen.GetString(9, 64, 3)
lastnote = trim(lastnote)
else
screenrow = myscreen.row
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
sentance = Sess0.Screen.GetString(screenrow, 8, 68)


currentnote = Sess0.Screen.GetString(9, 64, 3)
currentnote = trim(currentnote)
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

''''''''''''''''''''''''''''''
newpp = Sess0.Screen.GetString(9, 64, 3)
newpp = trim(newpp)
newppp = newpp
newp = newppp

'''''''''''''''''''''''''''''''''

prepair 'sub routinne that keeps a note of what page and row the word was found on


Sess0.Screen.Sendkeys("<Home><Pf7>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
currentnote = Sess0.Screen.GetString(9, 64, 3)
currnetnote = trim(currentnote)

lastnote = Sess0.Screen.GetString(9, 64, 3)
lastnote = trim(lastnote)

Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
end if

if lastnote = "1" then
create
exit sub
end if

loop

System.TimeoutValue = OldSystemTimeout

msgbox "Finished"

end sub







Sub prepair()
' this keeps track of what page and row the word was found on


if firstpagefound = "" then
firstpagefound = currentnote
firstrowfound = screenrow
firstsentance = sentance
firstfound = newp
exit sub
end if

if secondpagefound = "" then
secondpagefound = currentnote
secondrowfound = screenrow
secondsentance = sentance
secondfound = newp
exit sub
end if

if thirdpagefound = "" then
thirdpagefound = currentnote
thirdrowfound = screenrow
thirdsentance = sentance
thirdfound = newp
exit sub
end if

if fourthpagefound = "" then
fourthpagefound = currentnote
fourthrowfound = screenrow
fourthsentance = sentance
fourthfound = newp
exit sub
end if

if fifthpagefound = "" then
fifthpagefound = currentnote
fifthtrowfound = screenrow
fifthsentance = sentance
fithfound = newp
exit sub
end if

if sixthpagefound = "" then
sixthpagefound = currentnote
sixthrowfound = screenrow
sixthsentance = sentance
sixthfound = newp
exit sub
end if

if seventhpagefound = "" then
seventhpagefound = currentnote
seventhrowfound = screenrow
seventhsentance = sentance
seventhfound = newp
exit sub
end if

if eighthpagefound = "" then
eighthpagefound = currentnote
eighthtrowfound = screenrow
eighthsentance = sentance
eighthfound = newp
exit sub
end if


if ninthpagefound = "" then
ninthpagefound = currentnote
ninthrowfound = screenrow
ninthsentance = sentance
ninthfound = newp
exit sub
end if

if tenthpagefound = "" then
tenthpagefound = currentnote
tenthrowfound = screenrow
tenthsentance = sentance
tenthfound = newp
exit sub
end if

if eleventhpagefound = "" then
eleventhpagefound = currentnote
eleventhrowfound = screenrow
eleventhsentance = sentance
eleventh = newp
exit sub
end if

if twelfthpagefound = "" then
twelfthpagefound = currentnote
twelfthtrowfound = screenrow
twelfthsentance = sentance
twelfthfound = newp
exit sub
end if

if thirteenthpagefound = "" then
thirteenthpagefound = currentnote
thirteenthrowfound = screenrow
thirteenthsentance = sentance
thirteenthfound = newp
exit sub
end if

if fourteenthpagefound = "" then
fourteenthpagefound = currentnote
fourteenthhrowfound = screenrow
fourteenthsentance = sentance
fourteenthfound = newp
exit sub
end if

if fifteenthpagefound = "" then
fifteenthpagefound = currentnote
fifteenthrowfound = screenrow
fifteenthsentance = sentance
fifteenthfound = newp
exit sub
end if

if sixteenthpagefound = "" then
sixteenthpagefound = currentnote
sixteenthrowfound = screenrow
sixteenthsentance = sentance
sixteenthfound = newp
exit sub
end if

if seventeenthpagefound = "" then
seventeenthpagefound = currentnote
seventeenthrowfound = screenrow
seventeenthsentance = sentance
seventeenthfound = newp
exit sub
end if

if eighteenthpagefound = "" then
eighteenthpagefound = currentnote
eighteenthrowfound = screenrow
eighteenthsentance = sentance
eighteenthfound = newp
exit sub
end if

if nineteenthpagefound = "" then
nineteenthpagefound = currentnote
nineteenthrowfound = screenrow
nineteenthsentance = sentance
nineteenthfound= newp
exit sub
end if

if twentiethpagefound = "" then
twentiethpagefound = currentnote
twentiethrowfound = screenrow
twentiethsentance = sentance
twentiethfound = newp
create
exit sub
end if

end sub




sub create()


' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."'
STOP
End If
Set Sessions = System.Sessions

If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If

Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

w = 485 'width of dialog
h = 400 '75 ' height of dialog




Begin Dialog Userdialog1 w, h, "Choose which note to check"

'Groupbox 5, 4, 97, 47, "" ' this puts a box around all the options
Optiongroup .Optiongroup1


'Optionbutton 16,12,67,8,"Page " + firstpagefound + " " + "Row " + firstrowfound + " " + "firstsentance ", .OptionButton1 '116 poistion from left,16 position from top, 46 width of label, 12 not sure
Optionbutton 16,12,370,8,"Page " + firstpagefound + " " + "Row " + firstrowfound + " " + (firstsentance), .OptionButton1
Optionbutton 16,30,370,8,"Page " + secondpagefound + " " + "Row " + secondrowfound + " " + (secondsentance), .OptionButton2
Optionbutton 16,48,370,8,"Page " + thirdpagefound + " " + "Row " + thirdrowfound + " " + (thirdsentance), .OptionButton3
Optionbutton 16,66,370,8,"Page " + fourthpagefound + " " + "Row " + fourthrowfound + " " + (fourthsentance), .OptionButton4
Optionbutton 16,84,370,8,"Page " + fifthpagefound + " " + "Row " + fifthrowfound + " " + (fifthsentance), .OptionButton5
Optionbutton 16,102,370,8,"Page " + sixthpagefound + " " + "Row " + sixthrowfound + " " + (sixthsentance), .OptionButton6
Optionbutton 16,120,370,8,"Page " + seventhpagefound + " " + "Row " + seventhrowfound + " " + (seventhsentance), .OptionButton7
Optionbutton 16,138,370,8,"Page " + eighthpagefound + " " + "Row " + eighthrowfound + " " + (eighthsentance), .OptionButton8
Optionbutton 16,156,370,8,"Page " + ninthpagefound + " " + "Row " + ninthrowfound + " " + (ninthsentance), .OptionButton9
Optionbutton 16,174,370,8,"Page " + tenthpagefound + " " + "Row " + tenthrowfound + " " + (tenthsentance), .OptionButton10
Optionbutton 16,192,370,8,"Page " + eleventhpagefound + " " + "Row " + eleventhrowfound + " " + (eleventhsentance), .OptionButton11
Optionbutton 16,210,370,8,"Page " + twelfthpagefound + " " + "Row " + twelfthrowfround + " " + (twelfthsentance), .OptionButton12
Optionbutton 16,228,370,8,"Page " + thirteenthpagefound + " " + "Row " + thirteenthrowfound + " " + (thirteenthsentance), .OptionButton13
Optionbutton 16,246,370,8,"Page " + fourteenthpagefound + " " + "Row " + fourteenthrowfound + " " + (fourteenthsentance), .OptionButton14
Optionbutton 16,264,370,8,"Page " + fifteenthpagefound + " " + "Row " + fifteenthrowfound + " " + (fifteenthsentance), .OptionButton15
Optionbutton 16,282,370,8,"Page " + sixteenthpagefound + " " + "Row " + sixteenthrowfound + " " + (sixteenthsentance), .OptionButton16
Optionbutton 16,300,370,8,"Page " + seventeenthpagefound + " " + "Row " + seventeenthrowfound + " " + (seventeenthsentance), .OptionButton17
Optionbutton 16,318,370,8,"Page " + eighteenthpagefound + " " + "Row " + eighteenthrowfound + " " + (eighteenthsentance), .OptionButton18
Optionbutton 16,336,370,8,"Page " + nineteenthpagefound + " " + "Row " + nineteenthrowfound + " " + (nineteenthsentance), .OpionButton19
Optionbutton 16,354,370,8,"Page " + twentiethpagefound + " " + "Row " + twentiethrowfound + " " + (twentiethsentance), .OptionButton20


ButtonGroup .bg
PushButton 395, 50, 54, 14,"Page Fwd" ' 125 from left. 46, down, 54 width, 14 height
PushButton 395, 70, 54, 14,"Page Bwd"
Pushbutton 395, 90, 54, 14,"Next"

okbutton 395, 10, 54, 14
cancelbutton 395, 30, 54, 14



end dialog


dim mydialog1 as userdialog1
dialogStatus = Dialog(mydialog1)

if dialogStatus = 0 then
msgbox"Macro Ended"
exit sub
end if

radioOpt = mydialog1.optiongroup1 + 1 '0=pagefp, 1 = pagesp
whichButton=dialogStatus
if whichButton > 0 then radioOpt = 0 ' if a button was pressed ignore radio button



if radioOpt = 1 then
page = firstpagefound
row = firstrowfound
ppage = firstfound
userchoice
exit sub

Elseif radioOpt = 2 then
page = secondpagefound
row = secondrowfound
ppage = secondfound
userchoice
exit sub

Elseif radioOpt = 3 then
page = thirdpagefound
row = thirdrowfound
ppage = thirdfound
userchoice
exit sub

Elseif radioOpt = 4 then
page = fourthpagefound
row = fourthrowfound
ppage = fourthfound
userchoice
exit sub

Elseif radioOpt = 5 then
page = fifthpagefound
row = fifthtrowfound
ppage = fifthfound
userchoice
exit sub

Elseif radioOpt = 6 then
pagefound = sixthpagefound
row = sixthrowfound
ppage = sixthfound
userchoice
exit sub

Elseif radioOpt = 7 then
page = seventhpagefound
row = seventhrowfound
ppage = seventhfound
userchoice
exit sub

Elseif radioOpt = 8 then
page = eighthpagefound
row = eighthtrowfound
ppage = eighthfound
userchoice
exit sub

Elseif radioOpt = 9 then
page = ninethpagefound
row = ninethrowfound
ppage = ninethfound
userchoice
exit sub

Elseif radioOpt = 10 then
page = tenthpagefound
row = tenthrowfound
ppage = tenthfound
userchoice
exit sub

Elseif radioOpt = 11 then
page = eleventhpagefound
row = eleventhrowfound
ppage = eleventhfound
userchoice

Elseif radioOpt = 12 then
page = twelthpagefound
row = twelthtrowfound
ppage = twelthfound
userchoice
exit sub

Elseif radioOpt = 13 then
page = thirteenthpagefound
row = thirteenthrowfound
ppage = thirteenthfound
userchoice
exit sub

Elseif radioOpt = 14 then
page = fourteenthpagefound
row = fourteenthrowfound
ppage = fourteenthfound
userchoice
exit sub

Elseif radioOpt = 15 then
page = fifteenthpagefound
row = fifteenthrowfound
ppage = fifteenthfound
userchoice
exit sub

Elseif radioOpt = 16 then
page = sixteenthpagefound
row = sixteenthrowfound
ppage = sixteenthfound
userchoice
exit sub

Elseif radioOpt = 17 then
page = seventeenthpagefound
row = seventeenthrowfound
ppage = seventeenthfound
userchoice
exit sub

Elseif radioOpt = 18 then
page = eighteenthpagefound
row = eighteenthrowfound
ppage = eighteenthfound
userchoice
exit sub

Elseif radioOpt = 19 then
page = nineteenthpagefound
row = nineteenthrowfound
ppage = nineteenthfound
userchoice
exit sub

Elseif radioOpt = 20 then
page = twentiethpagefound
row = twentiethtrowfound
ppage = twentiethfound
userchoice
exit sub

end if


if whichButton=1 then


Sess0.screen.Sendkeys("<Pf8>") 'page forward
create
elseif whichButton = 2 then
Sess0.Screen.Sendkeys("<pf7>") 'page backward
create
elseif whichButton = 3 then
resetv
end if
end sub



sub userchoice()

' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."'
STOP
End If
Set Sessions = System.Sessions

If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If


' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)




Sess0.Screen.Sendkeys("<Home>")
Sess0.Screen.Sendkeys("<ERASEEOF>")
Sess0.Screen.Sendkeys("<tab>")
Sess0.Screen.Sendkeys("<ERASEEOF>")
Sess0.Screen.Sendkeys("<Home>")
Sess0.Screen.Sendkeys ("daj<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys ("s<Home>")
Sess0.Screen.Sendkeys ("ln<enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
do until newp <= ppage
if ppage > newp then
Sess0.Screen.Sendkeys("<Pf8>")
ppage = ppage - 14
end if
loop


Sess0.Screen.Sendkeys ("s<enter>")
currentnote = Sess0.Screen.GetString(9, 64, 3)
currentnote = trim(currentnote)

do until currentnote = page
if currentnote > page then
Sess0.Screen.Sendkeys("<Pf7>")
currentnote = Sess0.Screen.GetString(9, 64, 3)
currentnote = trim(currentnote)
elseif currentnote < page then
Sess0.Screen.Sendkeys("<Pf7>")
currentnote = Sess0.Screen.GetString(9, 64, 3)
currentnote = trim(currentnote)
end if
loop

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
msgbox "See Row" + " " + row

create

end sub



sub resetv() 'resets the variables to nothing

newvar = totalpages

firstpagefound = ""
secondpagefound = ""
thirdpagefound = ""
fourthpagefound = ""
fifthpagefound = ""
sixthpagefound = ""
seventhpagefound = ""
eighthpagefound = ""
ninthpagefound = ""
tenthpagefound = ""
eleventhpagefound = ""
twelfthpagefound = ""
thirteenthpagefound = ""
fourteenthpagefound = ""
fifteenthpagefound = ""
sixteenthpagefound = ""
seventeenthpagefound = ""
eighteenthpagefound = ""
nineteenthpagefound = ""
twentiethpagefound = ""

firstrowfound = ""
secondrowfound = ""
thirdrowfound = ""
fourthrowfound = ""
fifthrowfound = ""
sixthrowfound = ""
seventhrowfound = ""
eighthrowfound = ""
ninthrowfound = ""
tenthrowfound = ""
eleventhrowfound = ""
twelfthrowfound = ""
thirteenthrowfound = ""
fourtheenthowfound = ""
fifteenthrowfound = ""
sixteenthrowfound = ""
seventeenthrowfound = ""
eighteenthrowfound = ""
nineteenthrowfound = ""
twentiethrowfound = ""

sentance = ""
firstsentance = ""
secondsentace = ""
thirdsentance = ""
fourthsentance = ""
fifthsentance = ""
sixthsentance = ""
seventhsentance = ""
eighthsentance = ""
ninthsentance = ""
tenthsentance = ""
eleventhsentance = ""
twelfthsentance = ""
thirteenthsentance = ""
fourteenthsentance = ""
fifteenthsentance = ""
sixteenthsentance = ""
seventeenthsentance = ""
eighteenthsentance = ""
nineteenthsentance = ""
twentiethsentance = ""

firstfound = 0 'helps with selecting the page the uesr has chosen
secondfound = 0
thirdfound = 0
fourthfound = 0
fifthfound = 0
sixthfound = 0
seventhfound = 0
eighthfound = 0
ninthfound = 0
tenthfound = 0
eleventhfound = 0
twelfthfound = 0
thirteenth = 0
fourteenthfound = 0
fifteenthfound = 0
sixteenthfound = 0
seventeenthfound = 0
eighteenthfound = 0
nineteenthfound = 0
twentiethfound = 0

end sub

RE: declare variable so can be uased as

Ugly!!!

I'd use arrays rather than individual variables.

I'd use at least one For...Next loop. You could shrink your code by 80% I'm guessing.

Where is your problem code? I'm not going to wade thru it all.

Personally I hate Extra Basic & the Extra VB editor. I do all my Attachmate coding in Excel VBA. I don't like driving a Yugo. Much rather a Caddilac. Works real well as I read data from Excel to access data thru the emulator an scrape the screen, returning data to Excel.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: declare variable so can be uased as

(OP)
blush I'm not trained and finding reading material for attachmate is not as easy as finding stuff for Excel. Array, think I've seen one once, no idea how it worked

this is where it goes wrong
stepping through the code, when it steps past the line of code secondfound = newp for some reason first found which is firstfound = newp changes. firstfound which contains 218 changes to to 14287066.

smiler44

RE: declare variable so can be uased as


What happens if your do this instead of using newp, newpp, newppp

CODE

firstfound = trim(Sess0.Screen.GetString(9, 64, 3)) 

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: declare variable so can be uased as

(OP)
Skip,
I replaced firstfound = newp with firstfound = trim(Sess0.Screen.GetString(9, 64, 3)) but get a complie error.
I'm going to try do do the conversion in the prepair routine instead of the main routine, see if that makes any difference.

smiler44





The compile error problem may be because the prepair sub routine does not have this code in it.


' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."'
STOP
End If
Set Sessions = System.Sessions

If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If

Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

RE: declare variable so can be uased as

shouldn't some of your dim statements be global?

RE: declare variable so can be uased as

just a thought, instead of calling the subroutine prepair(),
can you try something like this instead

CODE

found = 0  'place this line at the very beginning of your code
    
   'the rest goes after your word is found 
    found = found + 1

    newp = trim(sess0.screen.getstring(9,64,3))
    currentnote = trim(Sess0.Screen.GetString(9, 64, 3))
    sentance = Sess0.Screen.GetString(screenrow, 8, 68)

    select case found
        case 1 
            firstpagefound = currentnote
            firstrowfound = screenrow
            firstsentance = sentance
            firstfound = newp
        case 2
            secondpagefound = currentnote
            secondrowfound = screenrow
            secondsentance = sentance
            secondfound = newp   
        '..etc...    
        
    
    end select 

ignore my previous statment about the global dim. it does not matter. sad

RE: declare variable so can be uased as

(OP)
I have been told that to convert a string to integer it is

dim firstvariable as string
dim secondvariable as integer

firstvariable = "12"

secondvariable = val(firstvariable)


although I still have the problem already mentioned, my number 218 stored seems to go from the number 218 and changes to 14287066. I really don't know why. I'm changing the code but so far its still doing the same.

remy988 I'll try your suggestion of found

smiler44

RE: declare variable so can be uased as

why is there a need to convert to integer?

RE: declare variable so can be uased as

(OP)
my customer orders all have varying number of pages, can be over 200 page or as little as 30. the macro is for the user to enter a word at the top of the screen that they wish to find in the 200 or so pages. the macro starts at the last page and works to page 1. if it finds a match it notes the page number, row number and they whole row of text that the word was found in. Once the macro has found 20 instances or gets to note 1 it allows the user to choose which instance they want to look at

If for example I have 200 pages, the user selects to look at an instance on page 100. I don't want to go to the last page and page backwards to page 100. All this I can do with strings.

Looking at the "index" of notes there are 14 notes per page. By going to the next page there will be another 14 rows of notes. The user can select any note to read.

I want to work out how many pages there are in total, 200 in this example. I may then need to minus 14 and see if the result is more, less or equal to 100. if more, then I need to go to the next page of 14 notes and again minus 14 again. is the result more, less, equal to 100 and so on. eventually I think I will end up with 96. at this point I will select a note. if this note is less then 100 I will page forward one page at a time to page 100. it is for this working out that I think I need to use an integer


smiler44

RE: declare variable so can be uased as

(OP)
found out it is best not to declare a variable as integer but long.

I have now changed by variables from integers to long, this seems to have solved the problem
smiler44

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close